[英]Closing jQuery Mobile Panel
I have a panel with links like this 我有一个这样的链接面板
Page1
第1页
Page2第2页
Page3第3页
If I am currently on Page1 and open the panel, the panel is not closed when I select Page1 again. 如果我当前在Page1上并打开面板,则当我再次选择Page1时,面板不会关闭。 I have checked jQuery mobile panel documentation , and has the same behaviour (if you open the panel an click on "Panels", the panel will stay open.
我检查了jQuery移动面板文档 ,并且具有相同的行为(如果您打开面板,单击“面板”,面板将保持打开状态。
Is there a way to close the panel if same page link is selected? 如果选择了相同的页面链接,有没有办法关闭面板?
Edit: jQuery Mobile version: 1.3.2 jQuery version: 1.9.1 编辑:jQuery Mobile版本:1.3.2 jQuery版本:1.9.1
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
. 更新:对于jQM> = 1.4,使用
$.mobile.pageContainer.pagecontainer("getActivePage")
而不是$.mobile.activePage
。
Demo: http://jsfiddle.net/Palestinian/k89A5/1/ 演示: http : //jsfiddle.net/Palestinian/k89A5/1/
only add data-rel="close" 只添加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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.