The checkbox data-binding value is not changing when i try to trigger the click event of checkbox.
I have created a jsfiddle, when i click the button i expect the value bind to change but not.
Any help?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Calling trigger(“click”) in jQuery simply triggers your “click” event handler(s). It doesn’t actually cause a click (and thereby a change of the checked state) on the checkbox – the only time it does something like that is in the case where the element has a function property named the same as the event (e.g.
form.submit()– but there’s nocheckbox.click()).But since you’re using knockout, you might as well do:
That’s pretty much the point of using knockout in the first place. Make your changes on the view model, not the view. Since the checkbox’s
checkedproperty is data bound toIsSelected, changingIsSelectedwill change thecheckedproperty of the checkbox.