Closing jQuery Mobile Panel

后端 未结 2 1580
庸人自扰
庸人自扰 2020-12-19 09:13

I have a panel with links like this

Page1
Page2
Page3

If I am currently on Page1 and open the panel, the panel i

相关标签:
2条回答
  • 2020-12-19 09:40

    You do something like this

    $(document).on("pageinit", function () {
      $("[data-role=panel] a").on("click", function () {
        if($(this).attr("href") == "#"+$.mobile.activePage[0].id) {
          $("[data-role=panel]").panel("close");
        }
      });
    });
    

    Update: For jQM >= 1.4 use $.mobile.pageContainer.pagecontainer("getActivePage") instead of $.mobile.activePage.

    Demo: http://jsfiddle.net/Palestinian/k89A5/1/

    0 讨论(0)
  • 2020-12-19 09:42

    only add data-rel="close"

     <li class="liPanel"><a href="javascript:void(0);" **data-rel="close"** class="ui-btn ui-shadow ui-corner-all ui-btn-icon-right ui-icon-info">Faqs</a>
    </li>
    
    0 讨论(0)
提交回复
热议问题