// fix issue on ajax querie on adding product

// clean code
This commit is contained in:
aFolletete
2011-12-21 09:23:31 +00:00
parent be45f9f0d5
commit f6d8f403da
4 changed files with 33 additions and 28 deletions
+12 -1
View File
@@ -25,6 +25,7 @@
*/
var current_product = null;
var ajaxQueries = new Array();
$(document).ready(function() {
// Init all events
@@ -33,6 +34,14 @@ $(document).ready(function() {
$('img.js-disabled-action').css({"opacity":0.5});
});
function stopAjaxQuery() {
if (typeof(ajaxQueries) == 'undefined')
ajaxQueries = new Array();
for(i = 0; i < ajaxQueries.length; i++)
ajaxQueries[i].abort();
ajaxQueries = new Array();
}
function updateInvoice(invoices)
{
// Update select on product edition line
@@ -372,6 +381,7 @@ function init()
$('#submitAddProduct').click(function(e) {
e.preventDefault();
stopAjaxQuery();
var go = true;
if ($('input#add_product_product_id').val() == 0)
@@ -409,7 +419,7 @@ function init()
if ($('select#add_product_product_invoice').val() == 0)
query += '&'+$('tr#new_invoice select, tr#new_invoice input').serialize();
$.ajax({
var ajax_query = $.ajax({
type: 'POST',
url: admin_order_tab_link,
cache: false,
@@ -437,6 +447,7 @@ function init()
alert(data.error);
}
});
ajaxQueries.push(ajax_query);
}
}
});