simpleModal 中 nivo-slider 的问题

发布于 2024-12-06 22:58:18 字数 550 浏览 4 评论 0原文

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

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

simpleModal

Nivo Slider

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

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

The nivo-slider displays and works fine, the problem I'm having is that if you close the modal window, and then re-open it, the nivo-slider is then broken. It stays stuck on the first picture and all the buttons related to nivo-slider are unresponsive.

Is there a way I can append the way simpleModal closes so it won't break nivo-slider?

simpleModal

Nivo Slider

Note: This probably happens because nivo-slider is runs on pageload, however, simpleModal unloads it when the modal window is closed, so there's no way to reload itif you reopen the modal window.

So the solution to this would probably be changing simplemodal so that instead of unloading it's content when the window is closed, it simply hides it instead. The problem is that I don't know how to do that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神妖 2024-12-13 22:58:18

由于没有人愿意回答我的问题,所以我挖了 simpleModal 的源代码并自己做了。

我查看了源代码,直到找到它用于关闭模式窗口的函数,然后我查找了删除内容并将其更改为仅隐藏它们的部分。

注意: 我的修复不适用于在模式窗口中包含将由用户更改的信息的人,但它适用于像我一样使用该窗口获取静态信息的任何人。

只需将这些更改应用于源代码:

From:(此代码从 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);

to:

// 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 的未修改源代码,只需单击我在下面放置的链接即可下载。

simpleModal

注意: 这是完整的、未压缩的源代码,用于开发目的。编辑完成后,我建议您使用以下网站对其进行压缩:JavascriptCompressor

Since no one else was willing to answer my question, I dug through simpleModal's source code and did it myself.

I looked through the source until I found the function that it uses to close the modal window and I looked for the sections where it removed things and changed it to just hiding them.

Note: My fix will not work for people who have information in the modal window that is going to be changed by the user, but it will work for anyone using the window for static information like I am.

Simply apply these changes to the source code:

From: (this code starts on line 664 of the unmodified source of simpleModal version 1.4.1)

// 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);

to:

// 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);

I only changed 4 lines, but now simpleModal only hides the content when you close the window, it doesn't unload it.

To get the unmodified source for simpleModal, just click on the link I have placed below to download it.

simpleModal

Note: That is the full, uncompressed source code, for the purpose of development. After you have finished editing it, I suggest you compress it by using this website: JavascriptCompressor

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文