Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for issue 2345 - Flip toggle switches *ALWAYS* toggle

- We now track whether or not the user has modified the value of the switch control. If so, we don't toggle it's value on mouseup.
  • Loading branch information...
commit 191b5e04a3811adb00f411c0c6b32dab626b77d4 1 parent fd28644
Kin Blas jblas authored
Showing with 6 additions and 3 deletions.
  1. +6 −3 js/jquery.mobile.forms.slider.js
9 js/jquery.mobile.forms.slider.js
View
@@ -71,7 +71,8 @@ $.widget( "mobile.slider", $.mobile.widget, {
slider: slider,
handle: handle,
dragging: false,
- beforeStart: null
+ beforeStart: null,
+ userModified: false
});
if ( cType == "select" ) {
@@ -113,12 +114,14 @@ $.widget( "mobile.slider", $.mobile.widget, {
$( document ).bind( "vmousemove", function( event ) {
if ( self.dragging ) {
self.refresh( event );
+ self.userModified = self.userModified || self.beforeStart !== control[0].selectedIndex;
return false;
}
});
slider.bind( "vmousedown", function( event ) {
self.dragging = true;
+ self.userModified = false;
if ( cType === "select" ) {
self.beforeStart = control[0].selectedIndex;
@@ -135,7 +138,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
if ( cType === "select" ) {
- if ( self.beforeStart === control[ 0 ].selectedIndex ) {
+ if ( !self.userModified ) {
//tap occurred, but value didn't change. flip it!
self.refresh( !self.beforeStart ? 1 : 0 );
}
@@ -323,4 +326,4 @@ $( document ).bind( "pagecreate create", function( e ){
});
-})( jQuery );
+})( jQuery );
Please sign in to comment.
Something went wrong with that request. Please try again.