Не работает фильтр на JS. Как исправить?
Доброго времени суток. Не работает фильтр товаров. Не могу понять почему. Библиотеки все подключены.
Есть фильтр такого рода: <!-- Калькулятор --> <div class="col-md-4"> <div> <div class="list-group-item type"> <div class="checkbox"> <label><input type="checkbox" checked class="type1" value="">квартиры <span>(25)</span></label> </div> <div class="checkbox"> <label><input type="checkbox" checked class="type2" value="">апартаменты <span>(35)</span></label> </div> <div class="checkbox"> <label><input type="checkbox" checked class="loft" value="">лофт <span>(6)</span></label> </div> </div> <div class="list-group-item otdelka"> <div class="checkbox" style=" "> <label><input type="checkbox" checked class="no" value="">без отделки <span>(40)</span></label> </div> <div class="checkbox" style=""> <label><input type="checkbox" checked class="yes" value="">с отделкой <span>(14)</span></label> </div> </div> <div class="list-group-item untype" style="height: 90px;"> <div class="checkbox"> <label><input type="checkbox" class="untype2" value="">только с пентхаусами <span>(32)</span></label> </div> <div class="checkbox"> <label><input type="checkbox" class="untype3" value="">только с террасами <span>(28)</span></label> </div> <br> </div> <div class="list-group-item tab-content"> <div> <b style=" position: relative;top: 2px; ">Цена</b> <div class="btn-group priceC" data-toggle="buttons"> <label class="btn btn-default active" data-toggle="tab" data-target="#obj_price" > <input type="radio" name="options" id="option1" class="obj" autocomplete="off" checked> за объект </label> <label class="btn btn-default cost1" data-toggle="tab" data-target="#m2" > <input type="radio" name="options" id="option2" class="m2" autocomplete="off"> за м<sup>2</sup> </label> </div> <!-- --> </div> <div class="slider-c pricel tab-pane active" id="obj_price"> <input type="text" id="w1" class="form-control" name="rating_3" value="4000000,304000000" data-krajee-slider="slider_5e4d9f50"> </div> <div class="slider-c pricelm tab-pane" id="m2"> <input type="text" id="w2" class="form-control" name="rating_9" value="130000,2200000" data-krajee-slider="slider_4866f492"> </div> </div> <div class="list-group-item"> <b>Площадь</b> <div class="slider-c metrl"> <!-- <b class="badge">10 м<sup>2</sup></b> --> <input type="text" id="w3" class="form-control" name="rating_4" value="15,1500" data-krajee-slider="slider_17f3b2a5"> </div> </div> <div class="list-group-item sdacha-cal" onclick=""> <b class="slup">Сдача объекта<i></i></b> <div class="sdsl"> <div class="checkbox"> <label><input type="checkbox" checked class="all" value="">все <!-- <span>()</span> --><div class="vrt"></div></label> </div> <div class="checkbox sdcl"> <label><input type="checkbox" class="sdachaСдан" value="Сдан" checked="">cдан <div class="vrt"></div> <span>(20)</span></label> </div> <div class="checkbox sdcl"> <label><input type="checkbox" class="sdacha2017" value="2017" checked>2017 <div class="vrt"></div> <span>(14)</span></label> </div> <div class="checkbox sdcl"> <label><input type="checkbox" class="sdacha2018" value="2018" checked>2018 <div class="vrt"></div> <span>(14)</span></label> </div> <div class="checkbox sdcl"> <label><input type="checkbox" class="sdacha2019" value="2019" checked>2019 <div class="vrt"></div> <span>(6)</span></label> </div> </div> </div> </div> </div> </div> Есть JavaScript, который это всё обрабатывает, но не пойму по какой причине он не работает. При нажатии чекбокса "квартиры", остаётся один элемент (первый по счёту) ВТБ Арена Парк и всё на этом, больше ничего не происходит. Снимай, не снимай чекбокс, больше реакции никакой нет. $(".sdacha-cal .all").click(function (event) { if (roll) { bool = $(this).prop("checked"); if (bool === true) { $(".sdacha-cal").find(".sdcl").each(function () { if ($(this).find('input:checked').length == 0) $(this).find('label').click(); }) } else { $(".sdacha-cal").find(".sdcl").each(function () { if ($(this).find('input:checked').length > 0) $(this).find('label').click(); }) } } /* if(roll){ $(".sdacha-cal").children(".sdcl").each(function( index ) { if( (val=$(this).children().children('input').prop( "checked" ))!=bool){ $(this).children().children('input').click() } }); } */ }); function suppose(json) { console.log('hhh'); window.not_run = 1; innull() var destination = $(".main").offset().top; $('body').animate({scrollTop: destination}, 600); if (json['otdelka'] != 'max') { $(".otdelka ." + json['otdelka']).click() } else { $(".otdelka .yes, .otdelka .no, .otdelka .loft").click() } if (json['raion'] != 'max') $(".raion" + json['raion']).click() else $(".raion-cal .all").click() if (json['time'] != 'max') $(".sdacha" + json['time']).click() else $(".sdacha-cal .all").click() console.log(json) json['type'].forEach(function (v, i, atr) { $(".type" + v).click() }); if (isset(json['untype'])) { console.log("isset untype") json['untype'].forEach(function (v, i, atr) { $(".untype" + v).click() }); } if (json['price'] != 'max') $("#w3").slider().slider('setValue', json['price']); if (json['price_m'] != 'max') $("#w2").slider().slider('setValue', json['price_m']) if (json['area'] != 'max') $("#w1").slider().slider('setValue', json['area']) window.not_run = 0; run() } function run() { if (!window.not_run) { Places = []; myCollection.removeAll() $(".list-group-item.oi").hide() window.i = 0 var onl = $(".otdelka .no").prop("checked"); var oyl = $(".otdelka .yes").prop("checked"); var ot = oyl && onl; var stype = ($('.type .loft').prop("checked") ? 4 : 0) + ($('.type .type2').prop("checked") ? 2 : 0) + ($('.type .type1').prop("checked") ? 1 : 0); var loc = $('.raion-cal .btn-group .btn-default.active').data('target'); var lp1 = $("#w1").val(); var lp2 = $("#w2").val(); var lm = $("#w3").val(); var prType = $('.priceC .btn.active').data('target') == '#obj_price'; $(".list-group-item.oi").each(function (index) { Bo = ot ? ot : oyl == $(this).data("otdelka"); Bt = stype & $(this).data('supertype'); rr = $(this).data("raion"); Br = ($(".raion" + rr).prop("checked")) ll = $(this).data("location"); Bl = ($(".location" + ll).prop("checked")) if (loc == 'location') { Br = 1; } else { Bl = 1; } if (prType) { alp = lp1.split(","); pfr = $(this).data("pricef"); ptr = $(this).data("pricet"); } else { alp = lp2.split(","); pfr = $(this).data("pricemf"); ptr = $(this).data("pricemt"); } Помогите пожалуйста разобраться, в чём проблема. :cray: |
Не видно вызова функции suppose.
|
Часовой пояс GMT +3, время: 08:36. |