From 2e86ed142527d50e6016001cef983995218586ac Mon Sep 17 00:00:00 2001 From: scottjehl Date: Wed, 27 Oct 2010 23:11:36 -0400 Subject: [PATCH] added support for enable and disable methods --- js/jquery.mobile.forms.checkboxradio.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/js/jquery.mobile.forms.checkboxradio.js b/js/jquery.mobile.forms.checkboxradio.js index d0a92d11..1879ee86 100644 --- a/js/jquery.mobile.forms.checkboxradio.js +++ b/js/jquery.mobile.forms.checkboxradio.js @@ -33,9 +33,15 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { .wrapAll( "
" ); label.bind({ + mouseover: function() { + if( $(this).parent().is('.ui-disabled') ){ return false; } + }, + mousedown: function() { + if( $(this).parent().is('.ui-disabled') ){ return false; } label.data( "state", input.attr( "checked" ) ); }, + click: function() { setTimeout(function() { if ( input.attr( "checked" ) === label.data( "state" ) ) { @@ -45,7 +51,6 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { } }); - //bind custom event, trigger it, bind click,focus,blur events input .bind({ @@ -84,6 +89,21 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { icon.removeClass( checkedicon ); icon.addClass( uncheckedicon ); } + + if( input.is( ":disabled" ) ){ + this.disable(); + } + else { + this.enable(); + } + }, + + disable: function(){ + this.element.attr("disabled",true).parent().addClass("ui-disabled"); + }, + + enable: function(){ + this.element.attr("disabled",false).parent().removeClass("ui-disabled"); } }); })( jQuery );