From 631be31dcf89250ad261dfc2092ded36eb0249bf Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Fri, 4 May 2012 08:55:16 +0000 Subject: [PATCH] [-] BO : fix bug #PSCFV-341 - ajax call could be made twice for the same product tab --- .../controllers/products/helpers/form/form.tpl | 10 +++++----- js/productTabsManager.js | 10 +++++++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl index dc4b159ea..289376962 100644 --- a/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl @@ -148,15 +148,15 @@ $("#product-tab-content-"+currentId).hide(); } - if ($("#product-tab-content-"+id).hasClass('not-loaded') && !$("#product-tab-content-"+id).hasClass('loading')) - tabs_manager.display(id, true, 0, null); - else - { + // if the tab has not already been loaded, load it now + tabs_manager.display(id, true, 0, null); + + tabs_manager.onLoad(id, function(){ $("#product-tab-content-"+id).show(0, function(){ $(this).trigger('displayed'); }); $("#link-"+id).addClass('selected'); - } + }); var languages = new Array(); if (btn_name == "Combinations") diff --git a/js/productTabsManager.js b/js/productTabsManager.js index 32579cb50..e0e4cac2f 100644 --- a/js/productTabsManager.js +++ b/js/productTabsManager.js @@ -75,9 +75,13 @@ function ProductTabsManager(){ */ this.display = function (id, selected, index, stack) { - var myurl = $('#link-'+id).attr("href")+"&ajax=1"; var tab_selector = $("#product-tab-content-"+id); - // Used to check if the tab is already in the process of being loaded + + // Is the tab already being loaded? + if (!tab_selector.hasClass('not-loaded') || tab_selector.hasClass('loading')) + return; + + // Mark the tab as being currently loading tab_selector.addClass('loading'); if (selected) @@ -89,7 +93,7 @@ function ProductTabsManager(){ data = post_data; $.ajax({ - url : myurl, + url : $('#link-'+id).attr("href")+"&ajax=1", async : true, cache: false, // cache needs to be set to false or IE will cache the page with outdated product values type: 'POST',