How to render jQuery Mobile UI Object boot page

I have HTML that I generate using client-side JS. I would still like to apply the style and functionality of jQuery Mobile UI to these objects. I can’t understand how, though ...

Let's say I create a:

<div data-role="fieldcontain">
    <label for="select-choice-1" class="select">Choose shipping method:</label>
    <select name="select-choice-1" id="select-choice-1">
        <option value="standard">Standard: 7 day</option>
        <option value="rush">Rush: 3 days</option>
        <option value="express">Express: next day</option>
        <option value="overnight">Overnight</option>
    </select>
</div>

And want to do it through jQuery Mobile UI inside the page ... how to do it?

I know with the standard jQuery user interface, I just need to make a line-by-line call:

$("#select-choice-1").buttonset();

Is there something similar for jQuery Mobile UI?

+5
source share
2 answers

UPDATE!

Yes! The new implementation with the event just landed!

http://jquerymobile.com/blog/2011/07/22/jquery-mobile-team-update-week-of-july-18th/

2 create, , .

faq, 2 .

, DOM, .page() . , jquery-mobile, , .

: http://jquerymobiledictionary.dyndns.org/faq.html

+2

pagecreate

$('#page').live('pagecreate',function(event){
    $('#elem_container').page();
});

. (), .

$('#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();
}
+2

All Articles