0

我正在使用 jQuery 插件Remodal为我的网站创建模式。我正在关注他们网站上的文档,但是我遇到了打开和关闭模式的问题。如果我打开模态,然后在下次页面加载时刷新我的浏览器,模态仍然会打开。我使用创建了一个模态实例var inst = $('[data-remodal-id=modal]').remodal();并做了一个console.log(inst.getState());并且模态被卡在“打开”状态。我也尝试运行该inst.close();功能,但也没有用。

这是我的代码:

$(document).ready(function() {
  var inst = $('[data-remodal-id=modal]').remodal();
  console.log(inst.getState()); //if I refresh with the modal open this will print "opening".
  //I want the modal to be closed every time the page is refreshed
  $('#div').click(function() {
     inst.open();
  });
  $(document).on('opening', '.remodal', function () {
    //when the modal opens open another jQuery plugin
    $("#gallery").unitegallery();
  });
});

在我的 html 正文中,我有以下代码:

<div data-remodal-id="modal"></div>
4

1 回答 1

0

我有同样的问题,并通过将选项设置hashTrackingfalse.

这可以直接在 HTML 中完成,通过设置data-remodal-option="hashTracking: false",或者options在从代码构造 Remodal 时使用参数指定它。另请参阅有关选项的 Remodal 文档

于 2017-01-12T15:47:01.757 回答