关闭jQuery UI对话框时刷新父页面

因此,每次关闭jQuery UI中的特定对话框时,我都希望刷新父页面。 我怎样才能做到这一点。

jQuery代码:

$(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代码:

  

关闭对话框后,如何让主页面刷新/重新加载?

使用dialogclose事件( 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(); } }); 

您应该可以使用reload()函数执行此操作:

 window.location.reload(); 

在你的代码中:

 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(); } }); 

初始化对话框时,添加关闭侦听器 。

 $( ".selector" ).dialog({ close: function( event, ui ) { window.location.reload(true); } });