Skip to content

Commit

Permalink
Issue jquery-archive#2756 - flip toggle switch value can be changed w…
Browse files Browse the repository at this point in the history
…hen the switch is disabled
  • Loading branch information
redaemn committed Oct 22, 2011
1 parent 08267c3 commit d427e3b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
3 changes: 1 addition & 2 deletions js/jquery.mobile.forms.slider.js
Expand Up @@ -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,
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/slider/slider_events.js
Expand Up @@ -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 d427e3b

Please sign in to comment.