Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

… is disabled
  • Loading branch information...
commit d427e3b0f676b1195e2da46cae964575ed8e6560 1 parent 08267c3
@redaemn redaemn authored
View
3  js/jquery.mobile.forms.slider.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,
View
30 tests/unit/slider/slider_events.js
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.