【问题标题】:Prevent jquery mobile panel from opening?防止jquery移动面板打开?
【发布时间】:2013-02-20 01:16:45
【问题描述】:

我有以下代码。如您所见,我已经尝试了大多数防止它打开的常用方法。

我这样做是因为在 panelbeforeopen 中我想检查用户是否已登录,然后仅在登录时才显示面板。

$(document).on('panelbeforeopen', '#right_panel', function(event){
        event.preventDefault();
        alert('test');
        return false;
        event.stopImmediatePropagation();
    });

【问题讨论】:

    标签: events jquery-mobile panel


    【解决方案1】:

    最后,我必须将事件处理程序绑定到负责打开面板的按钮。

    需要注意的是,将 a 标签自动链接到面板的代码将其事件处理程序设置为单击事件而不是点击事件。如果您使用 .on 绑定您的点击事件处理程序,它也将因任何原因不起作用。你必须像往常一样绑定它。

    js fiddle here

    $('.footer .right_panel').on('click', function (event) {        
        alert('test');
        event.stopPropagation();
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-09-03
      • 2014-01-24
      • 2016-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-20
      • 2013-05-18
      相关资源
      最近更新 更多