Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
moved check/uncheck event on label to touchend/mouseup. Fixes #753
Browse files Browse the repository at this point in the history
  • Loading branch information
scottjehl committed Jan 21, 2011
1 parent a1cb31a commit 38c1c24
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions js/jquery.mobile.forms.checkboxradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(){

This comment has been minimized.

Copy link
@keshin

keshin Jan 24, 2011

2 questions
1.the radio set not refresh correctly
2.how to bind the custom listener to the controller? as you won't fire any input's event in the touchend, mouseup listenter

This comment has been minimized.

Copy link
@scottjehl

scottjehl Jan 24, 2011

The recent commits should ensure things refresh properly and that you can bind to change events on the inputs.

if( $(this).parent().is('.ui-disabled') ){ return false; }
input.attr( "checked", !input.is( ":checked" ) );
self.refresh();
});

input
Expand Down

0 comments on commit 38c1c24

Please sign in to comment.