Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent colorbox instance from closing

Is it possible to prevent colorbox from being closed? I am using as a loading screen for a server side processing script and don't want it to be closed until finished.

$(function(){
    $("#songPayBtn").click(function() {

        $("#ccResultDiv").show();

$.fn.colorbox({width:"50%",
    height:"50%",
    inline:true,
    href:"#ccResultDiv",
    onClosed:function(){ <?php echo "window.location = \"http://rt.ja.com/trackdownload.php?trackid=" . $_SESSION['trackid'] . "\"";?> }
});
like image 370
user547794 Avatar asked Oct 03 '11 00:10

user547794


2 Answers

You can prevent your colorbox from closing and hide the close button by adding these options:

$("#myColorbox").colorbox({
    escKey: false, //escape key will not close
    overlayClose: false, //clicking background will not close
    closeButton: false // hide the close button
});

This will also allow you to still use the $.colorbox.close() method when you are ready to close your colorbox.

like image 157
uɥƃnɐʌuop Avatar answered Oct 30 '22 03:10

uɥƃnɐʌuop


It is indeed. You can redefine the close method before anything is initialized:

$.fn.colorbox.close = function(){};

This has to occur before the $(document).ready() function since it's during this that colorbox will take care of assigning its close method to elements and events.

like image 6
Pat Avatar answered Oct 30 '22 02:10

Pat