admin管理员组文章数量:1434909
I am using the following which works great. I am just wondering if it would be possible to override the onClosed after the box is loaded
$.colorbox({href:"fff.html",
onClosed:function(){ window.parent.location.reload(true); }
});
I know that I can use the resize function after the box is loaded to resize the dimensions. Would it be possible to use the close functions similarly to acplish my goal?
I am using the following which works great. I am just wondering if it would be possible to override the onClosed after the box is loaded
$.colorbox({href:"fff.html",
onClosed:function(){ window.parent.location.reload(true); }
});
I know that I can use the resize function after the box is loaded to resize the dimensions. Would it be possible to use the close functions similarly to acplish my goal?
Share Improve this question edited Mar 28, 2012 at 8:48 Eyad Fallatah asked Mar 28, 2012 at 8:39 Eyad FallatahEyad Fallatah 1,9484 gold badges24 silver badges36 bronze badges3 Answers
Reset to default 3You can do it exactly the way you are attempting
$.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
}
});
Or, you can pass a function name to the onClosed() too like
$.colorbox({href:"fff.html",
onClosed: overrideFunction
});
function overrideFunction() {
/your overriding function
}
Although there might be cleaner solutions, what you could do is
// in the window scope! Can be explicitely set with
// window.onColorboxClose without var before it.
var onColorboxClose = function(){
};
$.colorbox({
href:"fff.html",
onClosed:onColorboxClose
});
and then overwrite the function afterwards rather than passing it as a closure to the properties of the colorbox.
Another work around was to override the close event to get a plete control of close event handling
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;
}
};
本文标签: javascriptOverride colorbox onCloseStack Overflow
版权声明:本文标题:javascript - Override colorbox onClose - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745626859a2667024.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论