I’m trying to hook up a checkbox to my View, but as soon as I tick it, it stays checked, even when I click it again?
Here’s part of the View:
views.PaginatedView = Backbone.View.extend({
events: {
'click input.completedEnquiries': 'filterCompletedEnquiries'
},
filterCompletedEnquiries: function (e) {
return e.currentTarget.checked;
}
});
Heres the template:
<label>Show Completed: <input type="checkbox" class="completedEnquiries" /></label>
I’ve no idea what I’m doing wrong here?
Edit
Here is a Jsfiddle of the problem: http://jsfiddle.net/9cvVv/167/
The problem is returning
e.currentTarget.checkedfrom your event handler. Returningtrueorfalsefrom this handler will check or uncheck the box for youcomment out that return statement, and it works fine. You can still grab the info, but don’t return anything from the method.
Edit
Here’s an example, based on the conversation in the comments:
This is just one of many options you have, for making this work the way you want.