因爲沒有人願意回答我的問題,所以我挖掘了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只隱藏了cont當你關閉窗口時,它不會卸載它。
要獲得simpleModal的未修改源,只需點擊下面放置的鏈接即可下載它。
simpleModal
注:這是完整的,未壓縮的源代碼,爲發展宗旨。完成編輯後,我建議您使用此網站進行壓縮:JavascriptCompressor
嘗試放置示例代碼以着色您的問題,它會更具吸引力。 –
沒有示例代碼。代碼位於插件中,我無法在此處發佈所有代碼,而其他任何代碼我都可以發表id,因爲它與我的問題沒有任何關係。我可以給包含我的問題的例子的網站提供鏈接,但這是我所能做的 –