diff --git a/js/jquery.mobile.forms.checkboxradio.js b/js/jquery.mobile.forms.checkboxradio.js index 61d37588..dcf4831b 100644 --- a/js/jquery.mobile.forms.checkboxradio.js +++ b/js/jquery.mobile.forms.checkboxradio.js @@ -55,6 +55,11 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { }, "touchend mouseup": function( event ){ + if ( input.is( ":disabled" ) ) + { + event.preventDefault(); + return; + } label.removeData("movestart"); if( label.data("etype") && label.data("etype") !== event.type || label.data("moved") ){ label.removeData("etype").removeData("moved"); diff --git a/tests/unit/checkboxradio/checkboxradio_core.js b/tests/unit/checkboxradio/checkboxradio_core.js new file mode 100644 index 00000000..222b70d1 --- /dev/null +++ b/tests/unit/checkboxradio/checkboxradio_core.js @@ -0,0 +1,27 @@ +/* + * mobile page unit tests + */ +module('jquery.mobile.forms.checkboxradio.js'); + +test( "widget can be disabled and enabled", function(){ + var input = $("#checkbox-1"); + var button = input.parent().find(".ui-btn"); + + input.checkboxradio("disable"); + input.checkboxradio("enable"); + ok(!input.attr("disabled"), "start input as enabled"); + ok(!input.parent().hasClass("ui-disabled"), "no disabled styles"); + ok(!input.attr("checked"), "not checked before click"); + button.trigger("mouseup"); + ok(input.attr("checked"), "checked after click"); + ok(button.hasClass("ui-btn-active"), "active styles after click"); + button.trigger("mouseup"); + + input.checkboxradio("disable"); + ok(input.attr("disabled"), "input disabled"); + ok(input.parent().hasClass("ui-disabled"), "disabled styles"); + ok(!input.attr("checked"), "not checked before click"); + button.trigger("mouseup"); + ok(!input.attr("checked"), "not checked after click"); + ok(!button.hasClass("ui-btn-active"), "no active styles after click"); +}); diff --git a/tests/unit/checkboxradio/index.html b/tests/unit/checkboxradio/index.html new file mode 100644 index 00000000..4226db16 --- /dev/null +++ b/tests/unit/checkboxradio/index.html @@ -0,0 +1,61 @@ + + + + + jQuery Mobile Page Test Suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

jQuery Mobile Page Test Suite

+

+

+
    +
+ +
+
+
+
+
+ Agree to the terms: + + +
+
+
+
+ +