Moved the pagecreate handler registration for controlgroups to the init IIFE so it's executed after all required widgets have registered theirs

This commit is contained in:
Ghislain Seguin 2012-01-20 09:35:36 -08:00
parent b0d261ebe0
commit fe29c2adf7
2 changed files with 11 additions and 5 deletions

View file

@ -47,11 +47,8 @@ $.fn.controlgroup = function( options ) {
});
};
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
$( ":jqmData(role='controlgroup')", e.target ).controlgroup({ excludeInvisible: false });
});
// The pagecreate handler for controlgroup is in jquery.mobile.init because of the soft-dependency on the wrapped widgets
})(jQuery);
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});

View file

@ -154,6 +154,15 @@ define( [ "jquery", "jquery.mobile.core", "jquery.mobile.navigation", "jquery.mo
// so if it's 1, use 0 from now on
$.mobile.defaultHomeScroll = ( !$.support.scrollTop || $(window).scrollTop() === 1 ) ? 0 : 1;
// TODO: Implement a proper registration mechanism with dependency handling in order to not have exceptions like the one below
//auto self-init widgets for those widgets that have a soft dependency on others
if ( $.fn.controlgroup ) {
$( document ).bind( "pagecreate create", function( e ){
$( ":jqmData(role='controlgroup')", e.target ).controlgroup({ excludeInvisible: false });
});
}
//dom-ready inits
if( $.mobile.autoInitializePage ){
$.mobile.initializePage();