javascript - Integrating Isotope with BBQ hash history -
i know it's popular question i'm struggling little tutorial on isotope site develop current isotope use bbq hash history.
i trying add bbq hash history current set can link directly filtered content.
this jquery code far, works perfectly.
jquery(function () {     var $container = jquery('.wwd-content-container');     $container.imagesloaded(function () {         $container.isotope({             itemselector: '.each-wwd-content',             filter: '.corporate'         });     });     jquery('.wwd-filters a').click(function () {         jquery('a.active-filter').removeclass('active-filter');         jquery(this).addclass('active-filter');         var selector = $(this).attr('data-filter');         $container.isotope({             filter: selector         });         return false;     }); }); and have changed filter navigation from:
<li><a href="#" data-filter=".<?php echo esc_attr( $page_class ) ?>"><?php the_title(); ?></a></li> to
<li><a href="#filter=.<?php echo esc_attr( $page_class ) ?>"><?php the_title(); ?></a></li> i using wordpress hence $page_class variables etc — don't spend time on that.
thanks , appreciated. r
update
this have far...
jquery(function () {     var $container = jquery('.wwd-content-container');     $container.imagesloaded(function () {         $container.isotope({             itemselector: '.each-wwd-content',             filter: '.corporate'         });     });     jquery('.wwd-filters a').click(function () {         jquery('a.active-filter').removeclass('active-filter');         jquery(this).addclass('active-filter');         var selector = $(this).attr('data-filter');         $container.isotope({             filter: selector         });         return false;     });     jquery('.wwd-filters a').click(function(){           // href attr, remove leading #       var href = jquery(this).attr('href').replace( /^#/, '' ),           // convert href object           // i.e. 'filter=.inner-transition' -> { filter: '.inner-transition' }           option = $.deparam( href, true );       // set hash, triggers hashchange on window       $.bbq.pushstate( option );       return false;     });     jquery(window).bind( 'hashchange', function( event ){       // options object hash       var hashoptions = $.deparam.fragment();       // apply options hash       $container.isotope( hashoptions );     })       // trigger hashchange capture hash data on init       .trigger('hashchange'); }); 
it looks you've gotten rid of value variable selector, since tag no longer has attribute of data-filter. if set breakpoint value of selector, you'll see returns undefined instead of .corporate or of other values. means isotope doesn't filter anymore.
have on documentation this, linked below. http://isotope.metafizzy.co/docs/hash-history-jquery-bbq.html
your click event function should more or less documentation, particularly section titled 'jquery script'. function grabs selector href value, filters instance of isotope, , pushes through bbq hash history management.
i make sure have function bound hashchange well, written in documentation. it's important make sure hooking bbq's hashchange event make filtered content bookmarkable.
update
you've got 2 functions hooked on click. need second 1 fire isotope filter hashchange event.
have @ following code , compare earlier example: http://jsfiddle.net/hwwa4/1/
Comments
Post a Comment