Permalink
Browse files

add dependent tracking functions for jquery mobile objects

  • Loading branch information...
johnbender committed Sep 23, 2011
1 parent eb7c4d0 commit b837a49b32a544820bb60b123d31068af8dd7e27
Showing with 30 additions and 2 deletions.
  1. +21 −0 js/jquery.mobile.core.js
  2. +8 −1 js/jquery.mobile.forms.select.custom.js
  3. +1 −1 js/jquery.mobile.navigation.js
View
@@ -151,6 +151,27 @@
return $.removeData( elem, $.mobile.nsNormalize( prop ) );
};
$.fn.removeWithDependents = function() {
$.removeWithDependents( this );
};
$.removeWithDependents = function( elem ) {
var $elem = $( elem );
( $elem.jqmData('dependents') || $() ).remove();
$elem.remove();
};
$.fn.addDependent = function( newDependents ) {
$.addDependent( $(this), newDependents );
};
$.addDependent = function( elem, newDependents ) {
var dependents = $(elem).jqmData( 'dependents' ) || $();
$(elem).jqmData( 'dependents', $.merge(dependents, newDependents) );
};
// Monkey-patching Sizzle to filter the :jqmData selector
var oldFind = $.find;
@@ -200,6 +200,13 @@
return false;
}
});
self.thisPage.addDependent( this.menuPage );
self.menuPage.find(":jqmData(role='header') :jqmData(rel='back')").click(function() {
self.close();
return false;
});
},
_isRebuildRequired: function() {
@@ -265,7 +272,7 @@
// of a dialog sized custom select
if( !self.thisPage.data("page").options.domCache ){
self.thisPage.bind( "pagehide.remove", function() {
$(self).remove();
$(this).removeWithDependents();
});
}
@@ -854,7 +854,7 @@
// when dom caching is not enabled bind to remove the page on hide
if( !page.data("page").options.domCache ){
page.bind( "pagehide.remove", function(){
$(this).remove();
$(this).removeWithDependents();
});
}
});

0 comments on commit b837a49

Please sign in to comment.