Помощь Скрипт который убирает нулевые комбинации - ошибка

vaness

Постоялец
Регистрация
26 Окт 2008
Сообщения
33
Реакции
14
Есть скрипт для prodct.tpl который должен убирать комбинации товаров с 0 количеством.
Он работает криво, отображает не все цвета, доступные для нужного размера.
Помогите найти ошибку

Сам скрипт:
{literal}
<script type="text/javascript">
$(function(){

var groupIds=new Array();
$('select[id^="group_"]').each(function(){
groupIds.push(this.id);
});

if(groupIds.length == 0) return;

var newCombos={};

$.each(combinations,function(key,combination){
if(combination.quantity>0){
if(newCombos[combination['idsAttributes']['0']]==undefined){
newCombos[combination['idsAttributes']['0']]=[];
newCombos[combination['idsAttributes']['0']].push(combination['idsAttributes'][1]);
}else{
newCombos[combination['idsAttributes']['0']].push(combination['idsAttributes'][1]);
}
}
});

$('select[id^="group_"]').change(function(){console.log(123);checkCombination()});

checkCombination();

function checkCombination()
{
$('select[id^="group_"] option').prop('disabled',false);
$('a.color_pick').each(function(){
$(this).closest('li').hide();
});
$.each(groupIds,function(key,groupId){
var this_select=$('select[id='+groupId+']');
for(i in newCombos[this_select.val()]){
$('#color_'+newCombos[this_select.val()]).closest('li').show();
$('#color_to_pick_list li:visible').eq(0).find('a').trigger('click');
}
});
}

});
</script>
{/literal}
 
Назад
Сверху