Permalink
Browse files

Issue #2756 - flip toggle switch value can be changed when the switch…

… is disabled
  • Loading branch information...
redaemn committed Oct 22, 2011
1 parent 55d8989 commit 396f8d019e593f8f6ae226d66ef4bb9ca1467d93
Showing with 31 additions and 2 deletions.
  1. +1 −2 js/jquery.mobile.forms.slider.js
  2. +30 −0 tests/unit/slider/slider_events.js
@@ -215,8 +215,7 @@ $.widget( "mobile.slider", $.mobile.widget, {
refresh: function( val, isfromControl, preventInputUpdate ) {
if ( this.options.disabled || this.element.attr('disabled')) {
this.slider.addClass('ui-disabled');
return;
this.disable();
}
var control = this.element, percent,
@@ -199,4 +199,34 @@
ok( control[0].selectedIndex !== currentValue, "value did change");
same( changeCount, 1, "change event should be fired once during a click" );
});
asyncTest( "toggle switch should refresh when disabled", function() {
var control = $( "#slider-switch" ),
handle = control.data( "slider" ).handle;
$.testHelper.sequence([
function() {
// set the initial value
control.val('off').slider('refresh');
},
function() {
equals(handle.css('left'), '0%', 'handle starts on the left side');
// disable and change value
control.slider('disable');
control.val('on').slider('refresh');
},
function() {
equals(handle.css('left'), '100%', 'handle ends on the right side');
// reset slider state so it is ready for other tests
control.slider('enable');
start();
}
], 500);
});
})(jQuery);

0 comments on commit 396f8d0

Please sign in to comment.