Everything works, but resetting all the checkboxes, I do not understand what could be the problem?

When you click on the link - uncheck all the checkboxes, the filter settings should be reset ... Check marks are removed, and the filter settings are not reset!?

Just by clicking on the checkbox, everything works like a clock ... help me to understand what is the matter?

jQuery(document).ready(function () { $('input[type="checkbox"]').on('change', function () { var id = this.getAttribute('id'); var name = this.getAttribute('name'); var value = this.getAttribute('value'); if (id == undefined) return; if (this.checked) { categoryFilter('other' + name, value); //сортируСм ΠΊΠ°Ρ‚Π°Π»ΠΎΠ³ $.cookie('check' + name, value); //сохраняСм Π·Π½Π°Ρ‡Π΅Π½ΠΈΠ΅ Π² ΠΊΡƒΠΊΡƒ } else { categoryFilter('other' + name, ''); $.cookie('check' + name, ''); } }); //Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌ состояниС чСкбоксов var isCheck = false; for (i = 1; i < 10; i++) { isCheck = $.cookie("check" + i); if (isCheck) { $('#ch' + i).attr('checked', 'checked'); } else { $('#ch' + i).removeAttr('checked'); } } //снимаСм всС ΠΎΡ‚ΠΌΠ΅Ρ‚ΠΊΠΈ c чСкбоксов $("#select_none").click(function () { for (i = 1; i < 10; i++) { $('#ch' + i).removeAttr('checked'); categoryFilter('other' + i, ''); $.cookie('check' + i, ''); } }); }); 
  • one
    you have cookies stored in cookies, and you do not overwrite cookies when you reset the filter - Gedweb
  • $ .cookie ('check' + i, ''); - and what's that? - Dimastik86

2 answers 2

Maybe in the categoryFilter problem? Or here:

 $("#select_none").click(function () { //... return false; }); 

    Probably need or

     $.cookie('check' + name, null); 

    or

     isCheck = $.cookie("check" + i) != ''; 

    It seems to me that isCheck = $.cookie("check" + i) will be true even if the value is ''