由于没有人愿意回答我的问题,我翻遍了 simpleModal 的源代码并自己做了。
我查看了源代码,直到找到它用来关闭模式窗口的函数,然后我查找了它删除东西的部分并将其更改为只是隐藏它们。
注意:我的修复不适用于在模式窗口中拥有将由用户更改的信息的人,但它适用于像我一样使用窗口获取静态信息的任何人。
只需将这些更改应用于源代码:
来自:( 此代码从 simpleModal 版本 1.4.1 的未修改源的第 664 行开始)
// if the data came from the DOM, put it back
if (s.d.placeholder) {
var ph = $('#simplemodal-placeholder');
// save changes to the data?
if (s.o.persist) {
// insert the (possibly) modified data back into the DOM
ph.replaceWith(s.d.data.removeClass('simplemodal-data').css('display', s.display));
}
else {
// remove the current and insert the original,
// unmodified data back into the DOM
s.d.data.hide().remove();
ph.replaceWith(s.d.orig);
}
}
else {
// otherwise, remove it
s.d.data.hide().remove();
}
// remove the remaining elements
s.d.container.hide().remove();
s.d.overlay.hide();
s.d.iframe && s.d.iframe.hide().remove();
setTimeout(function(){
// opera work-around
s.d.overlay.remove();
// reset the dialog object
s.d = {};
}, 10);
至:
// if the data came from the DOM, put it back
if (s.d.placeholder) {
var ph = $('#simplemodal-placeholder');
// save changes to the data?
if (s.o.persist) {
// insert the (possibly) modified data back into the DOM
ph.replaceWith(s.d.data.removeClass('simplemodal-data').css('display', s.display));
}
else {
// remove the current and insert the original,
// unmodified data back into the DOM
s.d.data.hide();
}
}
else {
// otherwise, remove it
s.d.data.hide();
}
// remove the remaining elements
s.d.container.hide();
s.d.overlay.hide();
s.d.iframe && s.d.iframe.hide();
setTimeout(function(){
// opera work-around
s.d.overlay.remove();
// reset the dialog object
s.d = {};
}, 10);
我只更改了 4 行,但现在 simpleModal 仅在您关闭窗口时隐藏内容,它不会卸载它。
要获取 simpleModal 的未修改源,只需单击我在下面放置的链接即可下载它。
简单模态
注意:这是完整的、未压缩的源代码,用于开发目的。编辑完成后,我建议你使用这个网站压缩它:JavascriptCompressor