DD.
DD.

Reputation: 22011

JQuery Mobile trigger create

I've injected a header into my DOM and I would like JQM to render the header:

<div data-role="page" id="start">
    <div data-role="header" class="header">
        <h1>TEST</h1>
    </div>
</div>

I am calling

$('body').trigger('create')

but this doesn't update the HTML and the header doesn't render properly.

What am I doing wrong?

If I do this for a button it works fine:

<div data-role="page" id="start">
    <a class="mybutton" href="javascript:;" data-role="button" id="uid-1">TEST</a>
</div>

$('body').trigger('create') updates to :

<div data-role="page" data-url="mypage" id="start" data-url="start" tabindex="0"
    class="ui-page ui-body-c ui-page-active" style="min-height: 620px;">
    <a
        class="mybutton ui-btn ui-shadow ui-btn-corner-all ui-btn-up-c"
        href="javascript:;" data-role="button" id="uid-1"
        data-corners="true" data-shadow="true" data-iconshadow="true"
        data-wrapperels="span" data-theme="c"><span class="ui-btn-inner"><span
            class="ui-btn-text">TEST</span></span></a>
</div>

Upvotes: 0

Views: 1051

Answers (1)

Omar
Omar

Reputation: 31732

Update:

Since you're injecting items dynamically into page, use

.trigger('pagecreate')

to enhance full page contents.

Upvotes: 3

Related Questions