Permalink
Browse files

Fix for issue 2315 - Flip toggle switch with change event bound, trig…

…gers multiple times

- Modified refresh() so that it checks to see if the value actually changed before firing off the "change" event.
  • Loading branch information...
jblas committed Sep 22, 2011
1 parent 114cee8 commit 4fa6ccdc0d8625f58e43e446f24bc4e65f87cb1d
Showing with 5 additions and 1 deletion.
  1. +5 −1 js/jquery.mobile.forms.slider.js
@@ -284,13 +284,17 @@ $.widget( "mobile.slider", $.mobile.widget, {
}
if ( !preventInputUpdate ) {
var valueChanged = false;
// update control"s value
if ( cType === "input" ) {
valueChanged = control.val() !== newval;
control.val( newval );
} else {
valueChanged = control[ 0 ].selectedIndex !== newval;
control[ 0 ].selectedIndex = newval;
}
if ( !isfromControl ) {
if ( !isfromControl && valueChanged ) {
control.trigger( "change" );
}
}

0 comments on commit 4fa6ccd

Please sign in to comment.