Prefilter Quicksand Page - jQuery [英] Prefilter Quicksand Page - jQuery

查看:117
本文介绍了Prefilter Quicksand Page - jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我访问 net / quicksand / demos / one-set-clone.html#apprel =nofollow> http://razorjack.net/quicksand/demos/one-set-clone.html#app 它只是显示应用程序。这是可能的吗?

一些人说,这将有助于:

  if(window.location.hash){
//在这里运行代码来过滤流沙设置
var $ filteredData = $ data.find('li [data-type ='+ window.location .hash +']');
$ applications.quicksand($ filteredData,{
duration:800
});
}

但我不知道在哪里使用它。



非常感谢这里的任何帮助 - 真正坚持下去。

解决方案

  $(document).ready(function(){
//在页面加载时,我们检查是否存在一个散列值
if(window。 location.hash){
//在这里运行代码来过滤流沙设置
var $ filteredData = $ data.find('li [data-type ='+ window.location.hash +']' );
$ applications.quicksand($ filteredData,{
duration:800
});
} else {
//页面没有散列值。
$ applications.quicksand('Your Normal Data Here',{
duration:800
});
}
});

这个代码只在页面准备好的时候运行。它检查是否存在散列值。如果是这样的话,它会将数据过滤到 li 数据类型等于散列值的元素。然后准备好流沙以相应地过滤数据。如果没有散列值,我们通常加载流沙。我不知道你对你的选择器做了什么,所以只要用你使用的任何数据过滤器替换'你的正常数据在这里'

应该注意的是,按照这个例子,他们期望你有如下的< li> 结构 - >



< li data-type =data1> //东西< / li>



其中 data1 散列值用于过滤目的。


Is there a way I can prefilter this page to solely show 'Applications'.

Like, if I visit http://razorjack.net/quicksand/demos/one-set-clone.html#app it would just show 'Applications'. Is this possible?

Googling around some people say this would help:

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

but I've no idea where to use it.

Many thanks for any help here - truly stuck.

解决方案

$(document).ready(function(){
   //on page load, we check to see if a hash value exists.
   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
       });
   }else{
       // the page does not have a hash value. deliver normal content.
       $applications.quicksand('Your Normal Data Here', {
           duration: 800
       });
   }
});

This code only runs once the page has been prepared. It checks to see if the hash value is present. if so, it filters the data to li elements that have a data type equal to the hash value. Then it prepares quicksand to filter the data accordingly. If there is no hash value present, we load quicksand normally. I don't know what you do for your selector, so just replace 'Your Normal Data Here' with whatever data filter you use.

It should be noted that as per the example, they are expecting you to have an <li> structure as follows ->

<li data-type="data1"> //stuff </li>

Where data1 would be what the expected hash value is for filtering purposes.

这篇关于Prefilter Quicksand Page - jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆