10
10
//>>css.theme: ../css/themes/default/jquery.mobile.theme.css
11
11
12
12
define ( [ "jquery" ,
13
+ "../../navigation/path" ,
13
14
"../../jquery.mobile.core" ,
14
15
"../../jquery.mobile.widget" ,
15
16
"./reset" ] , function ( jQuery ) {
16
17
//>>excludeEnd("jqmBuildExclude");
17
18
( function ( $ , undefined ) {
18
19
20
+ var escapeId = $ . mobile . path . hashToSelector ;
21
+
19
22
$ . widget ( "mobile.checkboxradio" , $ . extend ( {
20
23
21
24
initSelector : "input:not( :jqmData(role='flipswitch' ) )[type='checkbox'],input[type='radio']:not( :jqmData(role='flipswitch' ))" ,
@@ -42,7 +45,7 @@ $.widget( "mobile.checkboxradio", $.extend( {
42
45
input
43
46
. closest ( "form, fieldset, :jqmData(role='page'), :jqmData(role='dialog')" )
44
47
. find ( "label" )
45
- . filter ( "[for='" + $ . mobile . path . hashToSelector ( input [ 0 ] . id ) + "']" )
48
+ . filter ( "[for='" + escapeId ( input [ 0 ] . id ) + "']" )
46
49
. first ( ) ,
47
50
inputtype = input [ 0 ] . type ,
48
51
checkedClass = "ui-" + inputtype + "-on" ,
@@ -186,9 +189,8 @@ $.widget( "mobile.checkboxradio", $.extend( {
186
189
// this radio button. In the case of a checkbox or a radio lacking a name
187
190
// attribute, it returns this.element.
188
191
_getInputSet : function ( ) {
189
- var formParent , inputSelector , thisPage , thisPageSelector ,
192
+ var formParent , inputSelector , thisPage , thisPageSelector , formId ,
190
193
thisElement = this . element ,
191
- formId = thisElement . attr ( "form" ) ,
192
194
outsideForm = false ,
193
195
returnValue = thisElement ,
194
196
name = thisElement [ 0 ] . name ;
@@ -198,17 +200,18 @@ $.widget( "mobile.checkboxradio", $.extend( {
198
200
if ( ! ( this . inputtype === "checkbox" || ! name ) ) {
199
201
200
202
inputSelector = "input[type='radio'][name='" + name + "']" ;
201
-
202
203
thisPageSelector = ":jqmData(role='page'), " +
203
204
":jqmData(role='dialog')" +
204
205
( $ . mobile . page ? ", :mobile-page" : "" ) +
205
206
", body" ;
206
207
thisPage = thisElement . closest ( thisPageSelector ) ;
208
+ formId = thisElement . attr ( "form" ) ;
207
209
210
+ // Establish formParent
208
211
if ( formId ) {
209
212
210
213
// This element has a form attribute. Let's find the form.
211
- formParent = thisPage . find ( "#" + formId ) ;
214
+ formParent = thisPage . find ( "#" + escapeId ( formId ) ) ;
212
215
} else {
213
216
214
217
// Are we inside a form?
@@ -225,7 +228,7 @@ $.widget( "mobile.checkboxradio", $.extend( {
225
228
// form
226
229
if ( formId ) {
227
230
returnValue = thisPage
228
- . find ( inputSelector + "[form='" + formId + "']" )
231
+ . find ( inputSelector + "[form='" + escapeId ( formId ) + "']" )
229
232
. add ( returnValue ) ;
230
233
}
231
234
} else {
0 commit comments