Do I have to create a new panel for every page?

后端 未结 11 1486
Happy的楠姐
Happy的楠姐 2020-12-13 22:30

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

11条回答
  •  甜味超标
    2020-12-13 23:19

    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

提交回复
热议问题