如果调用 pagecreate
$('#page').live('pagecreate',function(event){
$('#elem_container').page();
});
你去递归循环骑行。我编写了自己的 enhance() 函数来解决这个问题。
$('#page').live('pagecreate',function(event){
enhance($('#elem_container'));
});
该功能基本上只是将下面的代码压缩...
function enhance(dis){
dis.find( "[type='radio'], [type='checkbox']" ).checkboxradio();
dis.find( "button, [type='button'], [type='submit'], [type='reset'], [type='image']" ).not( ".ui-nojs" ).button();
dis.find( "input, textarea" ).not( "[type='radio'], [type='checkbox'], button, [type='button'], [type='submit'], [type='reset'], [type='image']" ).textinput();
dis.find( "input, select" ).filter( "[data-role='slider'], [data-type='range']" ).slider();
dis.find( "select:not([data-role='slider'])" ).selectmenu();
}
较早的帖子:
在挖掘了 jQuery 移动文件之后,我终于弄明白了......实际上很容易......
$("#select-choice-3").selectmenu();
这是我挖出来的代码块......
_enchanceControls: function() {
var o = this.options;
// degrade inputs to avoid poorly implemented native functionality
this.element.find( "input" ).each(function() {
var type = this.getAttribute( "type" );
if ( o.degradeInputs[ type ] ) {
$( this ).replaceWith(
$( "<div>" ).html( $(this).clone() ).html()
.replace( /type="([a-zA-Z]+)"/, "data-type='$1'" ) );
}
});
// enchance form controls
this.element
.find( "[type='radio'], [type='checkbox']" )
.checkboxradio();
this.element
.find( "button, [type='button'], [type='submit'], [type='reset'], [type='image']" )
.not( ".ui-nojs" )
.button();
this.element
.find( "input, textarea" )
.not( "[type='radio'], [type='checkbox'], button, [type='button'], [type='submit'], [type='reset'], [type='image']" )
.textinput();
this.element
.find( "input, select" )
.filter( "[data-role='slider'], [data-type='range']" )
.slider();
this.element
.find( "select:not([data-role='slider'])" )
.selectmenu();
}