This repository was archived by the owner on Oct 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-10
lines changed
Expand file tree Collapse file tree 3 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -131,17 +131,9 @@ $.widget( "mobile.checkboxradio", $.extend( {
131131 } ,
132132
133133 _handleInputVClick : function ( ) {
134- var $this = this . element ;
135-
136134 // Adds checked attribute to checked input when keyboard is used
137- if ( $this . is ( ":checked" ) ) {
138-
139- $this . prop ( "checked" , true ) ;
140- this . _getInputSet ( ) . not ( $this ) . prop ( "checked" , false ) ;
141- } else {
142- $this . prop ( "checked" , false ) ;
143- }
144-
135+ this . element . prop ( "checked" , this . element . is ( ":checked" ) ) ;
136+ this . _getInputSet ( ) . not ( this . element ) . prop ( "checked" , false ) ;
145137 this . _updateAll ( ) ;
146138 } ,
147139
Original file line number Diff line number Diff line change 33 */
44( function ( $ ) {
55 module ( 'jquery.mobile.forms.checkboxradio.js' ) ;
6+ test ( "Programmatic click on radio input correctly updates group" , function ( ) {
7+ var first = $ ( "#programmatic-click-test input" ) . eq ( 0 ) ,
8+ last = $ ( "#programmatic-click-test input" ) . eq ( 2 ) ;
9+
10+ last . click ( ) . checkboxradio ( "refresh" ) ;
11+ deepEqual ( first . prop ( "checked" ) , false , "First checkboxradio prop is false" ) ;
12+ deepEqual ( first . prev ( "label" ) . hasClass ( "ui-radio-off" ) , true ,
13+ "First label has class 'ui-radio-off'" ) ;
14+ deepEqual ( first . prev ( "label" ) . hasClass ( "ui-radio-on" ) , false ,
15+ "First label does not have class 'ui-radio-on'" ) ;
16+ deepEqual ( last . prop ( "checked" ) , true , "Last checkboxradio prop is true" ) ;
17+ deepEqual ( last . prev ( "label" ) . hasClass ( "ui-radio-off" ) , false ,
18+ "Last label does not have class 'ui-radio-off'" ) ;
19+ deepEqual ( last . prev ( "label" ) . hasClass ( "ui-radio-on" ) , true ,
20+ "First label has class 'ui-radio-on'" ) ;
21+ } ) ;
622
723 test ( "widget with weird label is created successfully" , function ( ) {
824 var elem = $ ( "#chk\\[\\'3\\'\\]-1" ) ;
Original file line number Diff line number Diff line change 4040 < div data-nstest-role ="page " data-nstest-theme ="b ">
4141 < div data-nstest-role ="content " id ="the-content ">
4242
43+ < div id ="programmatic-click-test ">
44+ < label > Radio 1< input type ="radio " name ="programmatic-click-test " checked > </ label >
45+ < label > Radio 2< input type ="radio " name ="programmatic-click-test "> </ label >
46+ < label > Radio 3< input type ="radio " name ="programmatic-click-test "> </ label >
47+ </ div >
48+
4349 < input type ="checkbox " id ="chk['3']-1 "> </ input >
4450 < label for ="chk['3']-1 "> Checkbox label</ label >
4551
You can’t perform that action at this time.
0 commit comments