olance / jQuery-switchButton

jQuery UI iPhone-like switch button
111 stars 102 forks source link

Underlying checkbox "checked" attribute does not change even though redraw occurs #10

Closed jthartika closed 10 years ago

jthartika commented 10 years ago

Hi!

I noticed that jquery.switchButton.js doesn't update the underlying checkbox "checked" attribute even though the event triggering the UI animation is fired. The "examples" site seems to suffer from this:

http://olance.github.io/jQuery-switchButton/

So the underlying input should change to checked="checked" but at the moment it does not.

It appears that the .change() event does not properly fire. I'm not sure why this happens, with Chrome Inspector's JS debugger this.element property "checked" is true :(

I'm using Wicket 6.9.1 with JQueryUI 1.9.1 and jQuery 1.10.1 in my project.

jthartika commented 10 years ago

Apparently, replacing

this.element.prop("checked", true).trigger("change");
this.element.change();

with

this.element.click();

works around the problem for me, but it would be nice to know what the root cause was..

olance commented 10 years ago

I am not sure how you're testing, because on the demo site I do have checkboxes that update...

To check it out, run this in the console: $('input').css("display", "inline") All underlying checkboxes will show next to the switch button, and will have the proper state.

jthartika commented 10 years ago

Thanks for the reply. I think this was my mistake, as the change event was hooked somewhere else and was not fired properly :)

olance commented 10 years ago

okay :)