开发者

JQuery Quicksand: Link directly to pre-filtered Quicksand from another page

开发者 https://www.devze.com 2023-03-28 18:02 出处:网络
For example: If I have a page called fruit.php with Quicksand and the filters are \'All\', \'Apple\', and \'Bananas\' and it is set to \'All\' by default, can I link to fruit.php开发者_StackOverflow中

For example: If I have a page called fruit.php with Quicksand and the filters are 'All', 'Apple', and 'Bananas' and it is set to 'All' by default, can I link to fruit.php开发者_StackOverflow中文版 from some other page and have quicksand pre-filtered to 'Apple' or 'Banana' instead?


If you set up your links like fruit.php#apple, you can write some javascript to parse the hashtag and filter the collection on the page load:

if(window.location.hash) {
    // run code here to filter the quicksand set
    var $filteredData = $data.find('li[data-type=' + window.location.hash + ']');
    $applications.quicksand($filteredData, {
        duration: 800
    });
}
0

精彩评论

暂无评论...
验证码 换一张
取 消