From 64e6ef0e720a448e8862246ffeaa504ea5e8ac78 Mon Sep 17 00:00:00 2001 From: scottjehl Date: Tue, 19 Jul 2011 22:44:03 -0400 Subject: [PATCH] bound widgets to the "enhance" event, in addition to the pagecreate event. The enhance event allows developers to enhance the contents of an html fragment by triggering "enhance". --- js/jquery.mobile.buttonMarkup.js | 2 +- js/jquery.mobile.collapsible.js | 2 +- js/jquery.mobile.controlGroup.js | 2 +- js/jquery.mobile.fieldContain.js | 2 +- js/jquery.mobile.fixHeaderFooter.js | 2 +- js/jquery.mobile.forms.button.js | 2 +- js/jquery.mobile.forms.checkboxradio.js | 2 +- js/jquery.mobile.forms.select.js | 2 +- js/jquery.mobile.forms.slider.js | 2 +- js/jquery.mobile.forms.textinput.js | 2 +- js/jquery.mobile.links.js | 2 +- js/jquery.mobile.listview.js | 2 +- js/jquery.mobile.navbar.js | 2 +- js/jquery.mobile.nojs.js | 2 +- tests/unit/checkboxradio/checkboxradio_core.js | 6 ++++++ 15 files changed, 20 insertions(+), 14 deletions(-) diff --git a/js/jquery.mobile.buttonMarkup.js b/js/jquery.mobile.buttonMarkup.js index 5958e89c..06527cc2 100644 --- a/js/jquery.mobile.buttonMarkup.js +++ b/js/jquery.mobile.buttonMarkup.js @@ -140,7 +140,7 @@ var attachEvents = function() { //links in bars, or those with data-role become buttons //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( ":jqmData(role='button'), .ui-bar > a, .ui-header > a, .ui-footer > a", e.target ) .not( ".ui-btn, :jqmData(role='none'), :jqmData(role='nojs')" ) diff --git a/js/jquery.mobile.collapsible.js b/js/jquery.mobile.collapsible.js index 0c3e5e6f..7a842524 100644 --- a/js/jquery.mobile.collapsible.js +++ b/js/jquery.mobile.collapsible.js @@ -7,7 +7,7 @@ (function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( ":jqmData(role='collapsible')", e.target ).collapsible(); }); diff --git a/js/jquery.mobile.controlGroup.js b/js/jquery.mobile.controlGroup.js index c3f8c555..92bd6630 100644 --- a/js/jquery.mobile.controlGroup.js +++ b/js/jquery.mobile.controlGroup.js @@ -7,7 +7,7 @@ (function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( ":jqmData(role='controlgroup')", e.target ).controlgroup({ excludeInvisible: false }); }); diff --git a/js/jquery.mobile.fieldContain.js b/js/jquery.mobile.fieldContain.js index a79d0240..28fb39f1 100644 --- a/js/jquery.mobile.fieldContain.js +++ b/js/jquery.mobile.fieldContain.js @@ -8,7 +8,7 @@ (function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( ":jqmData(role='fieldcontain')", e.target ).fieldcontain(); }); diff --git a/js/jquery.mobile.fixHeaderFooter.js b/js/jquery.mobile.fixHeaderFooter.js index 549719a8..2899bbcd 100644 --- a/js/jquery.mobile.fixHeaderFooter.js +++ b/js/jquery.mobile.fixHeaderFooter.js @@ -8,7 +8,7 @@ (function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ if( $( ":jqmData(position='fixed')", e.target ).length ){ $( e.target ).each(function(){ diff --git a/js/jquery.mobile.forms.button.js b/js/jquery.mobile.forms.button.js index 02c1cdca..22940fde 100644 --- a/js/jquery.mobile.forms.button.js +++ b/js/jquery.mobile.forms.button.js @@ -8,7 +8,7 @@ (function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( "button, [type='button'], [type='submit'], [type='reset'], [type='image']", e.target ) .not( ":jqmData(role='none'), :jqmData(role='nojs')" ) .button(); diff --git a/js/jquery.mobile.forms.checkboxradio.js b/js/jquery.mobile.forms.checkboxradio.js index 8d19a332..eb5efb9e 100644 --- a/js/jquery.mobile.forms.checkboxradio.js +++ b/js/jquery.mobile.forms.checkboxradio.js @@ -8,7 +8,7 @@ (function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( "input[type='checkbox'],input[type='radio']", e.target ) .not( ":jqmData(role='none'), :jqmData(role='nojs')" ) .checkboxradio(); diff --git a/js/jquery.mobile.forms.select.js b/js/jquery.mobile.forms.select.js index 869d7a82..ac4566b3 100644 --- a/js/jquery.mobile.forms.select.js +++ b/js/jquery.mobile.forms.select.js @@ -8,7 +8,7 @@ (function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( "select:not(:jqmData(role='slider'))", e.target ) .not( ":jqmData(role='none'), :jqmData(role='nojs')" ) .selectmenu(); diff --git a/js/jquery.mobile.forms.slider.js b/js/jquery.mobile.forms.slider.js index 1b739da5..c58cb15d 100644 --- a/js/jquery.mobile.forms.slider.js +++ b/js/jquery.mobile.forms.slider.js @@ -8,7 +8,7 @@ ( function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ var nativeSel = ":jqmData(role='none'), :jqmData(role='nojs')"; diff --git a/js/jquery.mobile.forms.textinput.js b/js/jquery.mobile.forms.textinput.js index 9638ed64..2fae262f 100644 --- a/js/jquery.mobile.forms.textinput.js +++ b/js/jquery.mobile.forms.textinput.js @@ -8,7 +8,7 @@ (function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( "input[type='text'], input[type='search'], input[type='number'], input[type='password'], textarea", e.target ) .not( ":jqmData(role='none'), :jqmData(role='nojs')" ) .textinput(); diff --git a/js/jquery.mobile.links.js b/js/jquery.mobile.links.js index 726e1f71..c4620b1f 100644 --- a/js/jquery.mobile.links.js +++ b/js/jquery.mobile.links.js @@ -7,7 +7,7 @@ (function( $, undefined ) { -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ //links within content areas $( e.target ) diff --git a/js/jquery.mobile.listview.js b/js/jquery.mobile.listview.js index e92f89e6..38dd21ae 100644 --- a/js/jquery.mobile.listview.js +++ b/js/jquery.mobile.listview.js @@ -8,7 +8,7 @@ (function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( ":jqmData(role='listview')", e.target ).listview(); }); diff --git a/js/jquery.mobile.navbar.js b/js/jquery.mobile.navbar.js index 32b80a18..4912eac3 100755 --- a/js/jquery.mobile.navbar.js +++ b/js/jquery.mobile.navbar.js @@ -8,7 +8,7 @@ (function( $, undefined ) { //auto self-init widgets -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( ":jqmData(role='navbar')", e.target ).navbar(); }); diff --git a/js/jquery.mobile.nojs.js b/js/jquery.mobile.nojs.js index 3dfea6c4..48c49590 100644 --- a/js/jquery.mobile.nojs.js +++ b/js/jquery.mobile.nojs.js @@ -7,7 +7,7 @@ (function( $, undefined ) { -$( document ).bind( "pagecreate", function( e ){ +$( document ).bind( "pagecreate enhance", function( e ){ $( ":jqmData(role='nojs')", e.target ).addClass( "ui-nojs" ); }); diff --git a/tests/unit/checkboxradio/checkboxradio_core.js b/tests/unit/checkboxradio/checkboxradio_core.js index 6742b2ca..ccdb7695 100644 --- a/tests/unit/checkboxradio/checkboxradio_core.js +++ b/tests/unit/checkboxradio/checkboxradio_core.js @@ -109,4 +109,10 @@ ], 500); }); + + test( "checkboxradio controls will create when inside a container that receives an 'enhance' event", function(){ + ok( $("#fragment").appendTo(".ui-page-active").find(".ui-btn").length ); + }) + + })(jQuery);