【问题标题】:Jquery swipe unbinded when open an iframe打开 iframe 时 Jquery 滑动未绑定
【发布时间】:2018-09-30 22:36:19
【问题描述】:

我正在使用JQuery.mobile-1.2.1 滑动事件和 MVC4。 我在主视图中定义了这样的事件:

$(document).ready(function() {
    $(".dummy-forswipe").on("swipeleft", swipeleftHandler); 
    $(".dummy-forswipe").on("swiperight", swiperightHandler); 
});

这很好用,但是当我打开和关闭 iframe 时会出现问题,由于某种原因,当我关闭 iframe(引导模式样式)时会丢失此事件,并且恢复事件的唯一方法是使用 div 点击class .dummy-forswipe 在主视图中恢复所有事件。

我尝试在主视图中重新绑定事件:

 $("#ModalBreach").on("hidden.bs.modal", function () {
          $(".dummy-forswipe").on("swipeleft", swipeleftHandler); 
          $(".dummy-forswipe").on("swiperight", swiperightHandler); 
   });

但是什么都没发生... 谁能帮帮我?

【问题讨论】:

    标签: jquery asp.net-mvc jquery-mobile


    【解决方案1】:

    我使用 dummy-forswipe 类模拟了对第一个 td 的点击。 我就是这样解决的:

    $("#ModalBreach").on("hidden.bs.modal", function () {
                if (typeof $('td[class^="dummy-forswipe"]')[0] != 'undefined') {
                    $('td[class^="dummy-forswipe"]')[0].click();
                }
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-04
      • 2012-02-11
      • 1970-01-01
      相关资源
      最近更新 更多