Skip to content

Commit d65f0db

Browse files
committed
enhanceWithin: store element sets for widgets before any enhancment takes place Fixes jquery-archive#6621 - Dynamically injected popup with header/footer not enhanced properly
1 parent 50160c8 commit d65f0db

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

js/jquery.mobile.helpers.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ define( [ "jquery", "./jquery.mobile.ns", "./jquery.ui.core" ], function( jQuery
173173

174174
// Enhance child elements
175175
enhanceWithin: function() {
176-
var widgetElements,
176+
var index,
177+
widgetElements ={},
177178
that = this;
178179

179180
// Add no js class to elements
@@ -198,7 +199,8 @@ define( [ "jquery", "./jquery.mobile.ns", "./jquery.ui.core" ], function( jQuery
198199

199200
// Add classes for fieldContain
200201
if ( $.fn.fieldcontain ) {
201-
this.find( ":jqmData(role='fieldcontain')" ).jqmEnhanceable().fieldcontain();
202+
this.find( ":jqmData(role='fieldcontain')" ).not( $.mobile.page.prototype.keepNativeSelector() )
203+
.jqmEnhanceable().fieldcontain();
202204
}
203205

204206
// Enhance widgets
@@ -208,21 +210,25 @@ define( [ "jquery", "./jquery.mobile.ns", "./jquery.ui.core" ], function( jQuery
208210
if ( constructor.initSelector ) {
209211

210212
// Filter elements that should not be enhanced based on parents
211-
widgetElements = $.mobile.enhanceable( that.find( constructor.initSelector ) );
213+
var elements = $.mobile.enhanceable( that.find( constructor.initSelector ) );
212214

213215
// If any matching elements remain filter ones with keepNativeSelector
214-
if ( widgetElements.length ) {
216+
if ( elements.length ) {
215217

216218
// $.mobile.page.prototype.keepNativeSelector is deprecated this is just for backcompat
217219
// Switch to $.mobile.keepNative in 1.5 which is just a value not a function
218-
widgetElements = widgetElements.not( $.mobile.page.prototype.keepNativeSelector() );
220+
elements = elements.not( $.mobile.page.prototype.keepNativeSelector() );
219221
}
220222

221223
// Enhance whatever is left
222-
widgetElements[ constructor.prototype.widgetName ]();
224+
widgetElements[ constructor.prototype.widgetName ] = elements;
223225
}
224226
});
225227

228+
for ( index in widgetElements ) {
229+
widgetElements[ index ][ index ]();
230+
}
231+
226232
return this;
227233
},
228234

0 commit comments

Comments
 (0)