jquery Quicksand链接到预先过滤的页面

时间:2012-05-08 01:24:48

标签: javascript jquery filter quicksand

我正在使用jquery流沙,我想知道如何以列表预先排序返回该页面。我在javascript中不是很了解,所以任何帮助都会非常感激。

修改

找到了类似过滤器http://savethefix.wordpress.com/2011/12/06/filterable-portfolio-with-jquery-with-external-link-support/

的解决方案

但是无法看到如何将其与流沙相结合

1 个答案:

答案 0 :(得分:2)

如果有人有兴趣就弄明白了。

$(document).ready(function() {


// get the action filter option item on page load
var $filterType = $('#filterOptions li.active a').attr('class');

// get and assign the ourHolder element to the
// $holder varible for use later
var $holder = $('ul.ourHolder');

// clone all items within the pre-assigned $holder element
var $data = $holder.clone();

var $button = $('#filterOptions li');

var $all = $('ul.ourHolder li').data('type') === 'all';


if (window.location.hash) {
// reset the active class on all the buttons
$button.removeClass('active');

// assign the class of the clicked filter option
// element to our $filterType variable
var $filtered = window.location.hash.replace('#', '');

$('a[class=' + $filtered + ']').parent().addClass('active');

var $filteredData = $data.find('li[data-type~=' + $filtered + ']').show();

// call quicksand and assign transition parameters
$holder.quicksand($filteredData, {
    duration: 800,
    easing: 'easeInOutQuad'
});
}
// attempt to call Quicksand when a filter option
// item is clicked
// Main Filter
$('#filterOptions li a').on('click', function(e) {
// reset the active class on all the buttons
$button.removeClass('active');

// assign the class of the clicked filter option
// element to our $filterType variable
var $filterType = $(this).attr('class');
$(this).parent().addClass('active');

var $filterData = $data.find('li[data-type~=' + $filterType + ']').show();

// call quicksand and assign transition parameters
$holder.quicksand($filterData, {
    duration: 800,
    easing: 'easeInOutQuad'
});
});

//Main Containers
$('ul.ourHolder').on('click', 'li.all', function(e) {
// reset the active class on all the buttons
$button.removeClass('active');

// assign the class of the clicked filter option
// element to our $filterType variable
var $ba = $('#filterOptions li a');
var $filteringType = $(this).attr('id');
var $navFilter = $ba.attr('class');

var $filteringData = $data.find('li[data-type=' + $filteringType + ']').show();

// call quicksand and assign transition parameters
$holder.quicksand($filteringData, {
    duration: 800,
    easing: 'easeInOutQuad'
});
});
});