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

This commit is contained in:
Gabriele Rabbiosi 2011-10-22 17:05:05 +02:00
parent 55d89893a2
commit 396f8d019e
2 changed files with 31 additions and 2 deletions

View file

@ -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,

View file

@ -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);