我正在使用以下工作很好。我只是想知道,如果箱子装载覆盖colorbox onClose
$.colorbox({href:"fff.html",
onClosed:function(){ window.parent.location.reload(true); }
});
我知道,我可以使用调整大小功能的盒子被装载到调整后的尺寸后,将有可能覆盖onClosed。是否有可能使用类似的关闭函数来实现我的目标?
我正在使用以下工作很好。我只是想知道,如果箱子装载覆盖colorbox onClose
$.colorbox({href:"fff.html",
onClosed:function(){ window.parent.location.reload(true); }
});
我知道,我可以使用调整大小功能的盒子被装载到调整后的尺寸后,将有可能覆盖onClosed。是否有可能使用类似的关闭函数来实现我的目标?
你可以做到这一点正是你正在尝试
$.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
}
虽然有可能是更清洁的解决方案,你可以做的是
// in the window scope! Can be explicitely set with
// window.onColorboxClose without var before it.
var onColorboxClose = function(){
};
$.colorbox({
href:"fff.html",
onClosed:onColorboxClose
});
,然后覆盖功能之后,而不是把它当作一个封闭的颜色框的属性。
另一个解决办法是覆盖关闭事件以获得关闭事件处理的完整控制
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;
}
};