我正在使用 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>