Reputation: 2731
I am calling the Jquery UI Dialog from the success function of an ajax call. The code for the Dialog is like this -
$.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 is that the location.reload()
inside the Finish Button Function gets called as soon the dialog loads. I want it to only get executed once the user has clicked the Finish Button.
What wrong am I doing?
Upvotes: 1
Views: 1265
Reputation: 311
I faced the similar kind of problem.The reason being : dialog code was copied from old page having jQuery v-1.7 & older jQuery-ui.js and the new page had jQuery-3.3.1 but older jQuery-ui.js.
So use both above scripts with latest versions.
Upvotes: 0
Reputation: 7454
I had the same weird issue. I didn't investigate much, but it started occurring when I changed
<input type="button" value="Submit" onclick="submitForm()" />
to:
<button onclick="submitForm()">Submit</button>
so I simply switched it back.
Upvotes: 0
Reputation: 5056
Why don't you try to define dialog in $(document).ready block instead of in success method? In that case you just need to open your dialog in success method like this:
$( "#newQuoteAddedAlert" ).dialog('open');
Upvotes: 1