0

nivo-slider 显示和工作正常,我遇到的问题是,如果您关闭模式窗口,然后重新打开它,nivo-slider 就会损坏。它停留在第一张图片上,并且所有与 nivo-slider 相关的按钮都没有响应。

有没有办法可以附加 simpleModal 关闭的方式,这样它就不会破坏 nivo-slider?

简单模态

尼沃滑块

注意:这可能是因为 nivo-slider 在页面加载时运行,但是,simpleModal 在模态窗口关闭时卸载它,因此如果您重新打开模态窗口,则无法重新加载它。

所以解决这个问题的方法可能是改变simplemodal,以便在窗口关闭时不卸载它的内容,而是简单地隐藏它。问题是我不知道该怎么做。

4

1 回答 1

0

由于没有人愿意回答我的问题,我翻遍了 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

于 2011-09-27T16:06:39.010 回答