Skip to content

Commit 50acf2e

Browse files
committed
fix to use options defined on page widget to determing domCache settings
1 parent 7a6b28d commit 50acf2e

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

js/jquery.mobile.listview.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,20 +260,22 @@ $.widget( "mobile.listview", $.mobile.widget, {
260260

261261
//on pagehide, remove any nested pages along with the parent page, as long as they aren't active
262262
if( hasSubPages && parentPage.data("page").options.domCache === false ){
263+
var newRemove = function( e, ui ){
264+
var nextPage = ui.nextPage, npURL;
265+
266+
if( ui.nextPage ){
267+
npURL = nextPage.jqmData( "url" );
268+
if( npURL.indexOf( parentUrl + "&" + $.mobile.subPageUrlKey ) !== 0 ){
269+
self.childPages().remove();
270+
parentPage.remove();
271+
}
272+
}
273+
};
274+
275+
// unbind the original page remove and replace with our specialized version
263276
parentPage
264277
.unbind( "pagehide.remove" )
265-
.bind( "pagehide.remove", function( e, ui ){
266-
var nextPage = ui.nextPage,
267-
npURL;
268-
269-
if( ui.nextPage ){
270-
npURL = nextPage.jqmData( "url" );
271-
if( npURL.indexOf( parentUrl + "&" + $.mobile.subPageUrlKey ) !== 0 ){
272-
self.childPages().remove();
273-
parentPage.remove();
274-
}
275-
}
276-
});
278+
.bind( "pagehide.remove", newRemove);
277279
}
278280
},
279281

js/jquery.mobile.navigation.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,12 +693,16 @@
693693
.attr( "data-" + $.mobile.ns + "url", path.convertUrlToDataUrl( fileUrl ) )
694694
.appendTo( settings.pageContainer );
695695

696-
// when dom caching is not enabled bind to remove the page on hide
697-
if( !page.jqmData("domCache") ){
698-
page.bind( "pagehide.remove", function(){
699-
$(this).remove();
700-
});
701-
}
696+
// wait for page creation to leverage options defined on widget
697+
page.one('pagecreate', function(){
698+
699+
// when dom caching is not enabled bind to remove the page on hide
700+
if( !page.data("page").options.domCache ){
701+
page.bind( "pagehide.remove", function(){
702+
$(this).remove();
703+
});
704+
}
705+
});
702706

703707
enhancePage( page, settings.role );
704708

0 commit comments

Comments
 (0)