This is a migrated thread and some comments may be shown as answers.

Can't bind function to onclick of a tag

1 Answer 116 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Travis
Top achievements
Rank 1
Travis asked on 30 Apr 2013, 08:58 PM

I'm using Kendo MVVM.

I have a function on my viewModel which is determined in the show event.
So in the data-show I perform a
viewModel.set("clickFunction", clickFunction);

Then I try to bind in the view using:
<a data-bind="click: clickFunction">Click Me</a>
I have tried every way of binding the click event to the <a tag with no success.

The problem I am trying to solve is on the mobile device I need to navigate between several SPAs (Don't argue with me that it shouldn't be done this way, I have requirements which make this valid). So when trying to navigate between SPAs I have to use functionality provided by Cordova
changePage: function(url){
            window.location = url;
        }
However the url need to be built and have url parameters determined in a view show event.

If there is a better way of doing this in a listview <a styled element I am open to them.

1 Answer, 1 is accepted

Sort by
0
Accepted
Travis
Top achievements
Rank 1
answered on 02 May 2013, 01:50 AM
I was able to get this working. I had to bind to the anchor tag by setting an ID on the tag. Then I used jQuery to bind the click function in the show event. None of the other Kendo data-bind methods would work.
Tags
General Discussions
Asked by
Travis
Top achievements
Rank 1
Answers by
Travis
Top achievements
Rank 1
Share this question
or