javascript - Override colorbox onClose - Stack Overflow

I am using the following which works great. I am just wondering if it would be possible to override the

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 badges
Add a ment  | 

3 Answers 3

Reset to default 3

You 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;
        }
    };

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745626860a4636859.html

相关推荐

  • javascript - Override colorbox onClose - Stack Overflow

    I am using the following which works great. I am just wondering if it would be possible to override the

    22天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信