March 28, 2012

Override colorbox onClose

Question by Эџad Дьdulяңмaи

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 accomplish my goal?

Answer by Starx

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
}

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!