Note that there are some explanatory texts on larger screens.

plurals
  1. POConflict between Isotope filtering and Fancybox
    primarykey
    data
    text
    <p>I have a Fancybox gallery that is filtered using jQuery Isotope. My problem is that even when filtered, Fancybox still cycles through all of the images. I know this issue has a few discussions here and have tried all of the solutions on those pages without success. </p> <p>I’m wondering if anyone can spot a conflict, probably in my filter script. I’m using Isotope v1.5.25.</p> <p>HTML</p> <pre><code>&lt;div class="row"&gt; &lt;div class="span12"&gt; &lt;!-- Filter --&gt; &lt;nav id="options" class="work-nav"&gt; &lt;ul id="filters" class="option-set" data-option-key="filter"&gt; &lt;li class="type-work"&gt;Type of Work&lt;/li&gt; &lt;li&gt;&lt;a href="#" data-filter="*" class="selected"&gt;All Projects&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" data-filter=".branding"&gt;Branding&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" data-filter=".brochure"&gt;Brochure&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; &lt;!-- End Filter --&gt; &lt;/div&gt; &lt;div class="span12"&gt; &lt;div class="row"&gt; &lt;section id="projects"&gt; &lt;ul id="thumbs"&gt; &lt;li class="item-thumbs span3 branding"&gt; &lt;a class="hover-wrap fancybox1" data-fancybox-group="gallery" title="Image Title" href="bigImage.jpg "&gt; &lt;span class="overlay-img"&gt;&lt;/span&gt; &lt;span class="overlay-img-thumb font-icon-search"&gt;&lt;/span&gt; &lt;/a&gt; &lt;img src="thumb.jpg" alt=""&gt; </code></pre> <p>ISOTOPE SCRIPT</p> <pre><code>DK.filter = function (){ if($('#projects').length &gt; 0){ var $container = $('#projects'); $container.imagesLoaded(function() { $container.isotope({ // options animationEngine: 'best-available', itemSelector : '.item-thumbs', layoutMode : 'fitRows' }); }); // open filtered items only $('#filters a').click(function(){ var selector = $(this).attr('data-filter'); $('#projects').isotope({ filter: selector }, function(){ if(selector == "*"){ $(".fancybox1").attr("data-fancybox-group", "gallery"); } else{ $(selector).find(".fancybox1").attr("data-fancybox-group", selector); } }); return false; }); // filter items when filter link is clicked var $optionSets = $('#options .option-set'), $optionLinks = $optionSets.find('a'); $optionLinks.click(function(){ var $this = $(this); // don't proceed if already selected if ( $this.hasClass('selected') ) { return false; } var $optionSet = $this.parents('.option-set'); $optionSet.find('.selected').removeClass('selected'); $this.addClass('selected'); // make option object dynamically, i.e. { filter: '.my-filter-class' } var options = {}, key = $optionSet.attr('data-option-key'), value = $this.attr('data-option-value'); // parse 'false' as false boolean value = value === 'false' ? false : value; options[ key ] = value; if ( key === 'layoutMode' &amp;&amp; typeof changeLayoutMode === 'function' ) { // changes in layout modes need extra logic changeLayoutMode( $this, options ) } else { // otherwise, apply new options $container.isotope( options ); } return false; }); } } </code></pre> <p>UPDATE: I've managed to get the filtering to work correctly and have updated the script above. The issue was using the <code>data-option-value</code> attribute instead of the <code>data-filter</code> one and referencing <code>$('#isotopegallery').isotope({ filter: selector }, function(){</code> instead of <code>$('#projects').isotope({ filter: selector }, function(){</code>.</p> <p>The problem now is when I click on the first filtered item, in this case 'branding' nothing happens. Then thumbnails only filter once I click on the page a second time.</p> <p>Can anyone please shed some light on this????</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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