// adding the dynamic loading of tabs in products

This commit is contained in:
lLefevre
2011-12-12 11:15:17 +00:00
parent eae3bc761f
commit a4b75601b6
3 changed files with 40 additions and 25 deletions
+10 -23
View File
@@ -39,26 +39,26 @@
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var toload = new Array(); var toload = new Array();
var pos_select = {$pos_select}; var pos_select = {$pos_select};
$(document).ready(function(){ $(document).ready(function(){
$('#desc-product-newCombination').hide(); $('#desc-product-newCombination').hide();
{* submenu binding *} {* submenu binding *}
$(".tab-page").click(function(e){ $(".tab-page").click(function(e){
e.preventDefault(); e.preventDefault();
// currentId is the current product tab id // currentId is the current product tab id
currentId = $(".productTabs a.selected").attr('id').substr(5); currentId = $(".productTabs a.selected").attr('id').substr(5);
// id is the wanted producttab id // id is the wanted producttab id
id = $(this).attr('id').substr(5); id = $(this).attr('id').substr(5);
// Update submit button value // Update submit button value
var split_position = id.indexOf('-') + 1; var split_position = id.indexOf('-') + 1;
var btn_name = id.substr(split_position); var btn_name = id.substr(split_position);
$("#product_form_submit_btn").attr('name', 'submit'+btn_name); $("#product_form_submit_btn").attr('name', 'submit'+btn_name);
if ($(this).attr("id") != $(".productTabs a.selected").attr('id')) if ($(this).attr("id") != $(".productTabs a.selected").attr('id'))
{ {
$(".tab-page").removeClass('selected'); $(".tab-page").removeClass('selected');
@@ -71,31 +71,18 @@
else else
return false; return false;
} }
$("#product-tab-content-wait").show(); $("#product-tab-content-wait").show();
if ($("#product-tab-content-"+id).hasClass('not-loaded') || $(this).hasClass('selected')) if ($("#product-tab-content-"+id).hasClass('not-loaded'))
{ displayTabProductById(this, id, true);
myurl = $(this).attr("href")+"&ajax=1";
$.ajax({
url : myurl,
async : true,
success :function(data)
{
$("#product-tab-content-"+id).html(data);
$("#product-tab-content-"+id).removeClass('not-loaded');
$("#product-tab-content-"+id).show();
$("#link-"+id).addClass('selected');
}
});
}
else else
{ {
$("#product-tab-content-"+id).show(); $("#product-tab-content-"+id).show();
$("#link-"+id).addClass('selected'); $("#link-"+id).addClass('selected');
} }
$("#product-tab-content-wait").hide(); $("#product-tab-content-wait").hide();
var languages = new Array(); var languages = new Array();
if (btn_name == "Combinations") if (btn_name == "Combinations")
{ {
@@ -37,6 +37,14 @@
updateMvtStatus($(this).val()); updateMvtStatus($(this).val());
}); });
updateMvtStatus($(this).val()); updateMvtStatus($(this).val());
$('.product-tab-content').each(function(){
var id = $(this).attr('id').substr(20);
if ($("#product-tab-content-"+id).hasClass('not-loaded'))
displayTabProductById('#link-'+id, id, false);
});
}); });
function updateMvtStatus(id_mvt_reason) function updateMvtStatus(id_mvt_reason)
{ {
@@ -621,8 +629,8 @@ var accessories = new Array();
</table> </table>
<br /> <br />
</div> </div>
{*
<script type="text/javascript"> <script type="text/javascript">
toggleVirtualProduct(getE('is_virtual_good')); toggleVirtualProduct(getE('is_virtual_good'));
</script> </script>*}
+20
View File
@@ -204,6 +204,26 @@ function editProductAttribute(ids, token)
} }
/* END Combination */ /* END Combination */
function displayTabProductById(el, id, selected)
{
myurl = $(el).attr("href")+"&ajax=1";
$.ajax({
url : myurl,
async : true,
success :function(data)
{
$("#product-tab-content-"+id).html(data);
$("#product-tab-content-"+id).removeClass('not-loaded');
if (selected)
{
$("#link-"+id).addClass('selected');
$("#product-tab-content-"+id).show();
}
}
});
}
function addPackItem() function addPackItem()
{ {
if ($('#curPackItemId').val() == '' || $('#curPackItemName').val() == '') if ($('#curPackItemId').val() == '' || $('#curPackItemName').val() == '')