diff --git a/templates/js/ui.atk4_loader.js b/templates/js/ui.atk4_loader.js
index <HASH>..<HASH> 100644
--- a/templates/js/ui.atk4_loader.js
+++ b/templates/js/ui.atk4_loader.js
@@ -177,6 +177,7 @@ $.widget('ui.atk4_loader', {
 				// with existing element. In this case we will be copying contents of
 				// provided element
 				n=n.contents();
+				el.triggerHandler('remove');
 			}else{
 				// otherwise we will be copying all the elements (including text)
 				if(reload){
@@ -184,7 +185,6 @@ $.widget('ui.atk4_loader', {
 				}
 				n=source.contents();
 			}
-			el.triggerHandler('remove');
 		   	// http://forum.jquery.com/topic/jquery-empty-does-not-destroy-ui-widgets-whereas-jquery-remove-does-using-ui-1-8-4
 
 			el.empty();
Fix problem with dialogURL

Dialogs were opening and disapearing. This was due to recent change in the loader,
which destroys widget when reloading it. However if it's not the widget which
is being reloaded, but widget contents, then we will not call destruction of
that widget.