EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: arma on October 13, 2013, 10:50:10 PM



Title: Tab not unload its content on close
Post by: arma on October 13, 2013, 10:50:10 PM
I have a closable tab which contains grid and grid toolbar. One of toolbar item will show a dialog (#mydialog) on click which contains form.
In console log $('#mydialog form') will show only 1 form. I then close the tab, and reopen tab. Console log again $('#mydialog form') there would be 2 forms. The form number would be incremented everytime i close and reopen tabs.

What's the proper way to unload tab content? Do i have to remove the content in tab onClose event manually?

Edit: It seems closing tabs does not destroy the dialog, so it keeps in memory. When the tab loaded again, a new dialog will be recreated by jeasyui which will make the form become duplicated. When i submit the form the fields would be messy :(


Title: Re: Tab not unload its content on close
Post by: stworthy on October 14, 2013, 07:02:30 PM
When a dialog(inline=false) is created, it will be moved to <body>. If this dialog is created from a markup that hosted in a tab panel, it will not be destroyed automatically after the tab panel is closed. Please try the code below to solve this issue.
Code:
$('#tt').tabs({
  onBeforeClose:function(){
    $('#mydialog').dialog('destroy');
  }
});


Title: Re: Tab not unload its content on close
Post by: arma on October 15, 2013, 08:33:39 AM
It seems .dialog('destroy') is not in the jeasyui doc?

If i have dynamic tabs, how could i detect if some tab has dialog, so i could specify its dialog id and closed it onBeforeClose.