最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Checkbox not checked when clicked in IE 8 and below using knockout binding - Stack Overflow

programmeradmin1浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 12

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; } }
发布评论

评论列表(0)

  1. 暂无评论