I would like to use a Panel in a jqm site for my Choose Language component. So that component will need to be present on every page. Here is the setup for a single-page pane
I was with this problem while been using a single page template. I want only to have a div with id menu and have it to append in all pages of the single page template.
My menu panel code looks like:
And my JS code is:
$(document).on('pagebeforeshow', '[data-role="page"]', function(){
// if the page hasn't got yet a menu panel, append a new menu
if ($.mobile.activePage.find(".menu").length===0) {
$('').attr({'data-role':'panel',"class":"menu"}).appendTo($(this));
// copy the contents of the panel defined before
$.mobile.activePage.find('.menu').html($("#menu").html()).panel();
}
// if click the .showMenu button, open the menu
$(document).on('click', '.showMenu', function(){
$.mobile.activePage.find('.menu').panel("open");
});
});
This code works perfect and I'm happy to got the right answer to my problem that I have been looking for two hours or more.
Comment if worked.
Greets from Spain