2011-09-27 72 views
0

nivo-slider顯示並正常工作,我遇到的問題是,如果關閉模式窗口,然後重新打開它,nivo滑塊將被打破。它停留在第一張圖片上,所有與nivo-slider相關的按鈕都沒有響應。simpleModal中的nivo滑塊問題

有沒有一種方法可以追加simpleModal關閉的方式,這樣就不會破壞nivo-slider?

simpleModal

Nivo Slider

注:這可能是因爲NIVO滑塊是運行在頁面加載,但是,simpleModal卸載它時,關閉模態窗口,所以沒有辦法如果你重新打開模式窗口,重新加載它。

因此,解決方案可能會改變simplemodal,以便在窗口關閉時不卸載它的內容,而是簡單地隱藏它。問題是我不知道該怎麼做。

+0

嘗試放置示例代碼以着色您的問題,它會更具吸引力。 –

+0

沒有示例代碼。代碼位於插件中,我無法在此處發佈所有代碼,而其他任何代碼我都可以發表id,因爲它與我的問題沒有任何關係。我可以給包含我的問題的例子的網站提供鏈接,但這是我所能做的 –

回答

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只隱藏了cont當你關閉窗口時,它不會卸載它。

要獲得simpleModal的未修改源,只需點擊下面放置的鏈接即可下載它。

simpleModal

注:這是完整的,未壓縮的源代碼,爲發展宗旨。完成編輯後,我建議您使用此網站進行壓縮:JavascriptCompressor