2012-03-28 54 views
0

我正在使用以下工作很好。我只是想知道,如果箱子裝載覆蓋colorbox onClose

$.colorbox({href:"fff.html", 
    onClosed:function(){ window.parent.location.reload(true); } 
    }); 

我知道,我可以使用調整大小功能的盒子被裝載到調整後的尺寸後,將有可能覆蓋onClosed。是否有可能使用類似的關閉函數來實現我的目標?

回答

3

你可以做到這一點正是你正在嘗試

$.colorbox({href:"fff.html", 
    onClosed:function(){ 
     //This is your method that triggers onClose 
     // SO go ahead, override it 

     //You can also call multiple function on it like 

     function1(); //call function 1 
     function2(); //call function 2 
    } 
}); 

或者順便說一下,你可以通過一個函數名的onClosed()太像

$.colorbox({href:"fff.html", 
    onClosed: overrideFunction 
}); 

function overrideFunction() { 
    /your overriding function 
} 
1

雖然有可能是更清潔的解決方案,你可以做的是

// in the window scope! Can be explicitely set with 
// window.onColorboxClose without var before it. 
var onColorboxClose = function(){ 
}; 

$.colorbox({ 
    href:"fff.html", 
    onClosed:onColorboxClose 
}); 

,然後覆蓋功能之後,而不是把它當作一個封閉的顏色框的屬性。

0

另一個解決辦法是覆蓋關閉事件以獲得關閉事件處理的完整控制

var c_close = $.fn.colorbox.close; 
    // Now disable the close function 
    $.fn.colorbox.close = function(){ 

     if(confirm('Are you sure?')){ 
      c_close(); 
     } else { 
      return false; 
     } 
    };