From 38c1c24e5dfb584fb213550666a6c899537a3396 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Fri, 21 Jan 2011 17:45:22 -0500 Subject: [PATCH] moved check/uncheck event on label to touchend/mouseup. Fixes #753 --- js/jquery.mobile.forms.checkboxradio.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/js/jquery.mobile.forms.checkboxradio.js b/js/jquery.mobile.forms.checkboxradio.js index 269481c7..cb3898c0 100644 --- a/js/jquery.mobile.forms.checkboxradio.js +++ b/js/jquery.mobile.forms.checkboxradio.js @@ -10,7 +10,8 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { theme: null }, _create: function(){ - var input = this.element, + var self = this, + input = this.element, label = input.closest("form,fieldset,[data-role='page']").find("label[for='" + input.attr( "id" ) + "']"), inputtype = input.attr( "type" ), checkedicon = "ui-icon-" + inputtype + "-on", @@ -40,18 +41,13 @@ $.widget( "mobile.checkboxradio", $.mobile.widget, { 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: false - click: function() { - setTimeout(function() { - if ( input.attr( "checked" ) === label.data( "state" ) ) { - input.trigger( "click" ); - } - }, 1); - } + }) + .bind( $.support.touch ? "touchend" : "mouseup", function(){ + if( $(this).parent().is('.ui-disabled') ){ return false; } + input.attr( "checked", !input.is( ":checked" ) ); + self.refresh(); }); input