I know it's a popular question but I'm struggling a little with the tutorial on the Isotope site to develop my current Isotope to use BBQ hash history.
I am essentially trying to add BBQ hash history to my current set up so I can link directly to the filtered content.
This is my jQuery code so far, which 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 I have changed my 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 am using Wordpress hence the $page_class variables etc — but don't spend too much time on that.
Thanks and any help would be most appreciated. R
UPDATE
This is what I have so 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(){
// get href attr, remove leading #
var href = jQuery(this).attr('href').replace( /^#/, '' ),
// convert href into 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 ){
// get options object from hash
var hashOptions = $.deparam.fragment();
// apply options from hash
$container.isotope( hashOptions );
})
// trigger hashchange to capture any hash data on init
.trigger('hashchange');
});