I'm having an issue with the following checkbox in IE 8 and below not being checked:
<input type="checkbox" data-bind="event: { change: $parent.addOtherAddresses }, attr: { value: $index() + 1 }" />
I'm trying to pass an entire object to 'addOtherAddresses', which it actually does and works fine, however the browser does not show the checkbox as actually being checked.
I've tried other solutions that display the check in the checkbox but only return the id or value of the checkbox, I need the entire parent data object returned so I can do other logic based on whats been checked.
Thanks for the help.
I'm having an issue with the following checkbox in IE 8 and below not being checked:
<input type="checkbox" data-bind="event: { change: $parent.addOtherAddresses }, attr: { value: $index() + 1 }" />
I'm trying to pass an entire object to 'addOtherAddresses', which it actually does and works fine, however the browser does not show the checkbox as actually being checked.
I've tried other solutions that display the check in the checkbox but only return the id or value of the checkbox, I need the entire parent data object returned so I can do other logic based on whats been checked.
Thanks for the help.
Share Improve this question asked Feb 21, 2013 at 0:50 GPBGPB 931 silver badge14 bronze badges 2-
Does it have anything to do with the fact that you're not closing your
data-bind
attribute? Or is that a typo in this post and not copied from your code? - Edit: apparently a typo since it's fixed now. – Robin van Baalen Commented Feb 21, 2013 at 0:53 - It was just a typo from this post – GPB Commented Feb 21, 2013 at 0:55
1 Answer
Reset to default 12The problem is that the change
event handler prevents the default action by the browser because that's what Knockout does by default. If you want to allow the browser's default action, you must return true
from your handler:
event: { change: function() { $parent.addOtherAddress($data); return true; } }