Jump to content

filters are resetting in blocklayered module


hrachocode2

Recommended Posts

Hello folks

https://linzoptic.am/4-sunglasses#/Price-40500-3700000

If you follow this link,  and click one of filters, for example Bentley, than refresh page, you can see its resetting, but if you  do force-reload like cntrl+f5 or cntrl+shift+r he will show ya filter you selected once, I am confused why this can happen? here is the algorithm I wrote to generate click from filtered url after reload. but suspiciously it works only after force-reload, how to solve this kinda trouble?

 

I am using blocklayered module, which is corrupted by fact

    $('div.layered_filter  a').each(function(key, elem){

      var _text = $(this).text();
      var removeBracks = _text.replace(/[{()}]/g, '');
      var removeNums = removeBracks.replace(/[0-9]/g, '');
      var replaceSpaces = removeNums.replace(/\s+/g, '_');
      var removeLastChar = replaceSpaces.substring(0, replaceSpaces.length - 1);
      var removeAmbersand = removeLastChar.replace('&', ''); 
      var removeDoublUnderscores = removeAmbersand.replace('__', '_'); 
      var removeDot = removeDoublUnderscores.split('.').join("");
      var dashToUnderscore = removeDot.replace('-', '_'); 
      var readyStr = dashToUnderscore.toLowerCase();
      var checker = $(elem).parent().prev().children('span')[0];

      if( _decodedURL.includes(readyStr) ){   

        if(!$(checker).hasClass('checked')) {
            setTimeout(function() { // in first mileseconds it resetting URL, so I set timeout after a second generating click
			$('form#layered_form a')[key].click(); // here is the click generator to specifit filter finded 						from old url(trigger is not working)
              return false; // breaking loop 
            }, 1000);
          }
    });
  }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...