vespino
vespino

Reputation: 1940

Inserting dynamic panel jquery mobile

In my app I would like to re-use the panel so I call this function when opening index.html:

var add_panel=function() {
//add button
$('[data-role="header"]').append('<a href="#leftpanel" class="ui-btn ui-icon-bars ui-btn-icon-notext ui-corner-all ui-btn-left">Menu</a>');

//panel
$.get('panel.html').success(function(data) {
    $('div[data-role="page"]').append(data);
    $('#leftpanel').trigger('create');
    $('#leftpanel').panel();
});

//open panel
$('body').on('click', '.ui-icon-bars', function() {
    $("#leftpanel").panel("toggle");
});
}

This works great on the first page and when returning to this page from another page.

I had hoped to call the same function inside "pagecontainertransition" to add the panel to other pages as well, but this doesn't seem to work:

//handle page transitions
$('body').on('pagecontainertransition', function(event, ui) {
    add_panel();
});

Can this be done?

Upvotes: 0

Views: 83

Answers (0)

Related Questions