diff --git a/js/jquery.mobile.controlGroup.js b/js/jquery.mobile.controlGroup.js index 7a4a22a3..7753f87e 100644 --- a/js/jquery.mobile.controlGroup.js +++ b/js/jquery.mobile.controlGroup.js @@ -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); }); diff --git a/js/jquery.mobile.init.js b/js/jquery.mobile.init.js index e8116d79..ed1dfbba 100644 --- a/js/jquery.mobile.init.js +++ b/js/jquery.mobile.init.js @@ -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();