Jquery UI Dialog button gets executed without clicking -
i calling jquery ui dialog success function of ajax call. code dialog -
$.ajax({ 'url': "../../controller/myclass.cfc", 'data':{ method: "generatequote", 'quoteitems':quoteitems, returnformat: "json" }, success: function(data){ $("#place_of_loading_image").hide(); newquoteid = data.tostring(); //new quote confirmation popup $( "#newquoteaddedalert" ).dialog({ autoopen: false, resize: 'auto', width: 'auto', modal: true, closeonescape: false, closetext: "close" , position: "center top", buttons: [{ text:"continue", click: function(){ $("#newquoteaddedalert").dialog("close"); }}, {text:"finish",click: function(){ $("#newquoteaddedalert").dialog("close"); //alert("shutup"); location.reload(); } }] }); //showconfirmationalert(newquoteid); },error: function( objrequest, strerror ){ } });
my problem location.reload()
inside finish button function gets called dialog loads. want executed once user has clicked finish button.
what wrong doing?
why don't try define dialog in $(document).ready block instead of in success method? in case need open dialog in success method this:
$( "#newquoteaddedalert" ).dialog('open');