Lance
Lance

Reputation: 1

Jquery simple modal close window and update parent

I want to execute some code inside a modal window that validates the data entered, if the data is saved successfully, I want to automatically close the modal window and refresh the parent window.

I've tried to call the modal close function, but no results.

<script>jQuery(function() {jQuery.modal.close();});</script>

Upvotes: 0

Views: 1573

Answers (1)

SeanCannon
SeanCannon

Reputation: 77966

Try this - in your main js:

// Open modal
$(foo).dialog(); 

// Listen for a trigger and close dialogue
$(foo).live('data_saved',function(){
    $(this).dialog('close'); // close modal
}

In your modal js:

// Inside modal, save your data - execute a trigger 
..whatever.trigger('data_saved');

Upvotes: 2

Related Questions