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

I'm having an issue with the following checkbox in IE 8 and below not being checked:<input type

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744063835a4552272.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信