我知道这是一个受欢迎的问题,但我正在努力与Isotope网站上的教程,以开发我当前的同位素使用BBQ hash history。集成同位素与烧烤哈希历史
我基本上试图将BBQ哈希历史记录添加到当前的设置中,以便我可以直接链接到过滤的内容。
这是我迄今为止的jQuery代码,它完美的工作。
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;
});
});
而且我已经从改变了我的过滤器导航:
<li><a href="#" data-filter=".<?php echo esc_attr($page_class) ?>"><?php the_title(); ?></a></li>
到
<li><a href="#filter=.<?php echo esc_attr($page_class) ?>"><?php the_title(); ?></a></li>
我使用Wordpress因此$ PAGE_CLASS变量等等 - 但不要花太多时间在那。
感谢和任何帮助将不胜感激。 [R
UPDATE
这是我迄今为止...
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');
});
谢谢,卢克。我已经更新了上面的代码,我觉得它应该停止,但我仍然错过了一些东西。我得到这些错误: Uncaught TypeError:无法调用未定义的方法'片段':446 未捕获的TypeError:对象函数(e,t){返回新的v.fn.init(e,t,n)}没有方法'deparam' –
你可以提供一个jsFiddle或测试环境,以便我可以看到发生了什么? – lukeshumard
您是否看到过我设置的jsFiddle? http://jsfiddle.net/HWwa4/ –