In my javascript code I am using the window.open method and the behavior is totally inconsistent: depending on the way I write the code it will either open a new tab or open a pop up window (which is blocked by the pop up blocker). I don't know how to work around it thanks for your help. The html code:
<a class='btn btn-success' target="_blank" onclick="quoteVisu(); return false;">Visualiser</a>
The javascript code:
function quoteVisu(){
quoteCreate(1);
}
quoteCreate is a method with an AJAX call
function quoteCreate(num_function){
var request=$.ajax({
url: url_up,
type: "POST",
beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},
data: {q_param: {
title: title,
total: total,
list: list,
client: idclient,
tax_rate: tax_rate
}},
success: function(data, textStatus, jqXHR) {
if (num_function==1){request.done(goShow(data.quote_id))};
if (num_function==0){request.done(goBack());}
},
dataType: "json"
});
return true;
}
and the goShow method:
function goShow(quote_id) {
var url_visu="/visu_pdf/quote_visu."+quote_id
window.open(url_visu, '_blank');
return true;
}
The code above gives a pop up window which is not the behavior expected. If I put the window.open in the quoteVisu method for example I will have a tab open and not a pop up which is what I want. But if I put it there I don't have the answer from the JSON which is needed for the new window url.
Thanks for your help.