Reputation: 1113
I got a jquery dialog window with some tabs, dynamic data, etc. In it there´s a button, which calls another dialog. That dialog has two buttons for save and close...If I click on close, it does which is supposed to do. But if I click on save, the content is saved and dialog closed, but the parent dialog is closed also, which I don´t want. How is this usually solved? Code of child dialog is here:
$('<div id="popis" style="display:none">').dialog({
title: 'Popis rizika',
height:300,
buttons:{
'Uložit': function(){
$("#popisRizika").submit();
$(this).remove();
},
'Zrušit': function(){
$( this ).dialog( "close" );
},
},
open: function(event, ui){
$(this).load('rizika_popis.php?stupen='+<?echo $IdStStupen;?>+'&index='+i);
},
close: function(ev, ui){
$(this).remove();
},
});
Upvotes: 0
Views: 751
Reputation: 36531
that is because your are submiting the form $("#popisRizika").submit();
when save is click.. and that makes wholepage to reload and thus resulting in closing of the parent dialog and the child too.. what you need here is posting a form through $.ajax , $.post or $.get.. this will not reload the page and hence you can close the child dialog manually after success callback
something like this ,using $.post :
'Uložit': function(){
$.post(url,$("#popisRizika").serialize(),function(result){
$( this ).dialog( "close" );
})
},
Upvotes: 1