简体   繁体   中英

Checkbox not checked when clicked in IE 8 and below using knockout binding

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.

The 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; } }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM