Closing Colorbox

Dofs picture Dofs · Jul 23, 2010 · Viewed 50.5k times · Source

I have a simple popup (not an Iframe) where a user can send mail to each other. There is a submit button to send the information and a cancel button which should close the overlay.

I do have some trouble getting the close button to work.

The code looks like this:

<asp:Button runat="server" ID="btnCancel" Text="Cancel" />

<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery("#<%= btnCancel.ClientID %>").click(function () {
            jQuery.colorbox.close(); return false;
        });
    });
</script>

I have tried with both parent.jQuery.colorbox.close(), jQuery.fn.colorbox.close() but with no success.

Answer

sushil bharwani picture sushil bharwani · Jul 23, 2010

Does your colorbox have a close button at the top. [close]. In my application when i want to introduce a cancel button to close the colorbox window from a link other than already provided by colorbox.

I do a workaround like.

jQuery('#cboxClose').click();

this will click the default close button and will eventually close the colorbox.