Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Flip toggle update error #676

Closed
naugtur opened this Issue Dec 14, 2010 · 4 comments

Comments

Projects
None yet
2 participants

naugtur commented Dec 14, 2010

Flip toggle doesn't get updated properly when javascript changes the value of the underlaying select and triggers events.

go to http://jquerymobile.com/demos/1.0a2/#docs/forms/forms-switch.html and use firebug to run:
$('#slider2').val('on').trigger('change'); //nothing happens. I expected it to work
$('#slider2').val('on').trigger('keyup'); //enlarges the "on" part, but doesn't move the slider

Contributor

johnbender commented Jan 17, 2011

Naugtur,

Thanks for taking the time to post this issue.

In the short term you might try changing the selectedIndex property of the vanilla DOM object and then triggering the change event. I was able to obtain the desired result in ff and Chrome. (sorry for the lack of a code snippet I'm posting from my phone)

Hopefully ill have a patch for this in the next day or so.

Contributor

johnbender commented Jan 17, 2011

Upon further inspection using the built-in methods .change() and/or .keyup() in place of the trigger calls also appears to work. I'll look into why trigger doesn't produce the same effect.

update:

$('#slider2').val('on').change();

The above works for me as does

$('#slider2').val('on').keyup();
Contributor

johnbender commented Jan 18, 2011

This issue is fixed in the lastest build. To verify run the above code snippets at:

http://jquerymobile.com/test/#docs/forms/forms-switch.html

naugtur commented Jan 18, 2011

Verified. Triggering the change event works fine. Thanks!

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment