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

梦想与她 提交于 2019-12-11 12:28:57

问题


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 from some other page and have quicksand pre-filtered to 'Apple' or 'Banana' instead?


回答1:


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
    });
}


来源:https://stackoverflow.com/questions/7083261/jquery-quicksand-link-directly-to-pre-filtered-quicksand-from-another-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!