isotope filter to link from another page

nikita gupta picture nikita gupta · May 12, 2012 · Viewed 9.8k times · Source

i'm working on jquery isotope and the filter works just fine using the method given below on the same page portfolio.html:

<li class="current"><a href="#" data-filter="*">all</a></li>
<li><a href="#" data-filter=".design">design</a></li>
<li><a href="#" data-filter=".coding">coding</a></li>
<li><a href="#" data-filter=".logo">logo</a></li>

What i'm trying to achieve is to link to a specific category so that my users can come from other pages to the filtered category.

i tried the following linking method but it didn't work:

<a href="portfolio.html#filter=logo" data-filter=".logo">logo</a>

can anyone help me out? is there any method to pre-filter the categories?

Answer

Bill picture Bill · Jul 9, 2012

After you configure isotope you need to read the querystring variable and then click the filter button that matches.

jsFiddle Example: http://jsfiddle.net/Y6vWn/

var filterFromQuerystring = getParameterByName('filter');
$('a[data-filter=".' + filterFromQuerystring  + '"]').click();