Ask your JavaScript questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

jQuery question: How can I add a callback to closeDOMWindow JavaScript


[[LINK href=""]]I'm using the code from this page. [[/LINK]]

If you click one link, then the lightbox pops up. I've got this code to set the action on the link:

if ($('#link_to_create_a_new_country_from_the_region_form')) {

If you click another link, the pop up closes. I've got this code setting the action to click for that link:

if ($('#link_to_close_new_country_form_on_region_form_page')) {
$('#link_to_close_new_country_form_on_region_form_page').closeDOMWindow( {

Only problem is, when you close the pop up, I need a lot of other stuff to happen. I need to update some form inputs.

But how do I get other stuff to happen? I have not been able to figure out how to get other code to trigger when you click that close link.

Does jQuery have an easy way to set several actions on the click? I could write some manual code to do this (I've done stuff like that using a modified version of Simon Willison's [[LINK href=""]]addLoad script[[/LINK]]) but I worry I will break something in jQuery if I do this.

Answers (3)


Jarret Minkler answers:

add this option replacing null with your fnc


and you want to remove the training commas in the {} otherwise IE will cry


Bill Hunt answers:

This doesn't directly answer the question, but that plugin doesn't really seem to be doing things the "jquery way". I'd strongly recommend using the jQuery UI library's dialog function instead, and just attach it to a click through the usual event handlers.


Eric Hamilton answers:

Add a class to the dom window close links, then do:

$('body').delegate('.my-close-links', 'click', function () {
// do stuff....
// $(this) will be the clicked link.
// You can use .parent( [ selector ] ) to find parent elements of the clicked link.

I agree that jQuery UI's built-in .dialog() might be a better solution for you. With it, you can do:

$( ".selector" ).load('someurl').dialog({
buttons: {
"Close": function () {

// Insert whatever you want here...