Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I could make it work but it was not as straightforward as I thought in a firts instance. I think you need to bear on mind a couple of things:</p> <ol> <li><p>If you want to use a restrictive AND condition, then I suggest don´t use the <strong>"data-filter-value"</strong> option. Instead, put your <strong>filter variables as classes</strong>. Then, you will need to fire the isotope function by yourself in the onclick event. This is because otherwise you will fire the "default" isotope function when the user clicks the button and you won´t be able to achieve the restrictive AND mentioned.</p></li> <li><p>In the same direction, you will need to use <strong>new variable names (so new classes) for each combination of nested filter options you are going to work with</strong>. Otherwise, I don´t see other way (at the moment) to get a restrictive AND condition.</p></li> </ol> <p><strong>This concept about restrictive and nonrestrictive AND clauses is like the difference between an outer and an inner join</strong>. It's the concept you should use if you want to handle two filters, one subfilter of the other one. <br> One example would be something like a list of ebooks which could be filtered by brand, an other subfilter based on the different range prices they belong to.</p> <p>I show you below a code example where I implement this idea, it can give you a hint of what i mean:</p> <p>HTML:</p> <pre><code>&lt;!--Filters section --&gt; &lt;div id="filters"&gt; &lt;ul id="optionSet1" class="option-set" data-option-key="filter"&gt; &lt;li&gt;&lt;a id="filter10" href="#filter" class="selected"&gt;Everything&lt;/a&gt;&lt;/li&gt; &lt;c:forEach var="brand" items="${brands}" varStatus="status" &gt; &lt;li&gt;&lt;a id="filter1${status.count}" href="#filter" class='${brand}'&gt;${brand}&lt;/a&gt;&lt;/li&gt; &lt;/c:forEach&gt; &lt;/ul&gt; &lt;ul id="optionSet2" class="option-set" data-option-key="filter"&gt; &lt;li&gt;&lt;a id="filter20" href="#filter" class="selected"&gt;Any Price&lt;/a&gt; &lt;/li&gt; &lt;c:forEach var="brandPrice" items="${brandPrices}" varStatus="status" &gt; &lt;li&gt;&lt;a id="filter2${status.count}" href="#filter" class='${brandPrice}'&gt;${brandPrice}&lt;/a&gt;&lt;/li&gt; &lt;/c:forEach&gt; &lt;/ul&gt; &lt;/div&gt; &lt;!--Elements to filter --&gt; &lt;div id="portfolio-wrapper" class="row"&gt; &lt;c:forEach var="publication" items="${publications}" varStatus="status" &gt; &lt;div class='span4 portfolio-item ${publication.filterOption1} ${publication.filterOption2} ${publication.filterOption3}...'&gt; &lt;!-- filterOption3 would be the combination of filterOption1 and filterOption2, you can make this building a string as the addition of filterOption1 and filterOption2 strings--&gt; &lt;!--Content to display--&gt; &lt;/c:forEach&gt; &lt;/div&gt; </code></pre> <p>javascript:</p> <pre><code>$(function(){ $("a[id^='filter1']").on('click', function() { // alert($(this).attr('class')); // alert($('#optionSet2 .selected').attr('class')); var myclass = $('#optionSet2 .selected').attr('class'); myclass = myclass.replace(' selected',''); myclass = myclass.replace('selected',''); var myclass2 = $(this).attr('class'); myclass2 = myclass2.replace(' selected',''); myclass2 = myclass2.replace('selected',''); if($(myclass=='' &amp;&amp; myclass2==''){ $('#portfolio-wrapper').isotope({ filter: '*'}); }else if(myclass==''){ $('#portfolio-wrapper').isotope({ filter: '.'+ myclass2+'' }); }else if(myclass2==''){ $('#portfolio-wrapper').isotope({ filter: '.'+myclass+'' }); }else{ $('#portfolio-wrapper').isotope({ filter: '.'+myclass2+myclass+''}); } }); $("a[id^='filter2']").on('click', function() { // alert($(this).attr('class')); // alert($('#optionSet1 .selected').attr('class')); var myclass = $('#optionSet1 .selected').attr('class'); myclass = myclass.replace(' selected',''); myclass = myclass.replace('selected',''); var myclass2 = $(this).attr('class'); myclass2 = myclass2.replace(' selected',''); myclass2 = myclass2.replace('selected',''); if(myclass=='' &amp;&amp; myclass2==''){ $('#portfolio-wrapper').isotope({ filter: '*'}); }else if(myclass==''){ $('#portfolio-wrapper').isotope({ filter: '.'+ myclass2+'' }); }else if(myclass2==''){ $('#portfolio-wrapper').isotope({ filter: '.'+myclass+'' }); }else{ $('#portfolio-wrapper').isotope({ filter: '.'+myclass+myclass2+''}); } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload