Reputation: 179
So every time a specific dialog box in jQuery UI is closed I want the parent page to be refreshed. How can I achieve this.
jQuery Code:
$(document).ready(function() {
var dlg=$('#createTeam').dialog({
title: 'Create a Team',
resizable: true,
autoOpen:false,
modal: true,
hide: 'fade',
width:600,
height:285
});
$('#createTeamLink').click(function(e) {
dlg.load('admin/addTeam.php');
e.preventDefault();
dlg.dialog('open');
});
});
HTML Code:
<button href="" type="button" id="createTeamLink" class="btn btn-primary custom">Create Team</button>
<div id="createTeam" class="divider"></div>
How do I get the main parent page to refresh/reload after the dialog box is closed?
Upvotes: 3
Views: 14755
Reputation: 207511
When you initialize the dialog, add the close listener.
$( ".selector" ).dialog({
close: function( event, ui ) { window.location.reload(true); }
});
Upvotes: 0
Reputation: 8831
Use the dialogclose event (http://api.jqueryui.com/dialog/#event-close).
var dlg=$('#createTeam').dialog({
title: 'Create a Team',
resizable: true,
autoOpen:false,
modal: true,
hide: 'fade',
width:600,
height:285,
close: function(event, ui) {
location.reload();
}
});
Upvotes: 13
Reputation: 1248
You should be able to do this with the reload()
function:
window.location.reload();
In your code:
var dlg=$('#createTeam').dialog({
title: 'Create a Team',
resizable: true,
autoOpen:false,
modal: true,
hide: 'fade',
width:600,
height:285,
close: function() {
window.location.reload();
}
});
Upvotes: 1