jquery地址怎么用呢?

发布于 2024-08-16 03:55:27 字数 489 浏览 7 评论 0原文

我试图了解如何使用 jQuery 地址插件来处理 ajax 的深度链接。

但文档非常差,我找不到任何好的教程来解释正在发生的事情。

我认为带有良好示例的良好文档对于每个插件都很重要。

有人可以解释或提供一些有用的解释链接吗?

$.address.change(function(event) {  
    // do something depending on the event.value property, e.g.  
    // $('#content').load(event.value + '.xml');  
});  
$('a').click(function() {  
    $.address.value($(this).attr('href'));  
});  

我的意思是,$.address.value 是做什么的?它说“提供当前的深度链接值”。它究竟意味着什么?它有什么作用?

I'm trying to understand how to use the jQuery address plugin for handling deep linking with ajax.

But the documentation is very poor and I cant find any good tutorials explaining what is going on.

I think a good documentation with good examples is important with every plugin.

Could someone explain or give some useful links for explanation?

$.address.change(function(event) {  
    // do something depending on the event.value property, e.g.  
    // $('#content').load(event.value + '.xml');  
});  
$('a').click(function() {  
    $.address.value($(this).attr('href'));  
});  

I mean, what does $.address.value do? It says "Provides the current deep linking value." What does it even mean? And what does it do with it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

最后的乘客 2024-08-23 03:55:28

快速嘟哝:
使用 AJAX 的最大警告是 URL 不会改变,因此后退按钮不起作用+链接不会被抓取。解决方法是在 URL 中使用页面部分锚点,即 # 符号。根据 hashsign 之后的数据,您可以使用 AJAX,加载可爬行的页面部分等。

唯一的问题是大多数浏览器没有 URL 更改事件,基于此,可以加载 AJAX 内容,所以实际上插件是什么正在做的是,它会不时监视 URL,如果发生更改,则会根据 after-hash-sign-parameters 触发一个事件。
所以基本上你在这里所做的是

    $('a').click(function() {  
    **//change the after-hash-sign-params to the value of the clicked link**
        $.address.value($(this).attr('href'));

    });
    $.address.change(function(event) { 
 **//define an event handler based on the params...**
         if (event.value = 'sortbyname')
            sortstuffbyname()
else if (event.value ='sortbysomethingelse')
         sortstuffbysomethingelse();
        // do something depending on the event.value property, e.g.  
        // $('#content').load(event.value + '.xml');  
    });  

我从未尝试过其他插件,但工作原理可能是相同的。

A quick tut.:
The biggest caveat of using AJAX is that the URL is not changing hence back button is not working + links are not crawled. The workaround for this is to use the page section anchor in the URL, the # sign. Based on the data after the hashsign you can use AJAX, load crawlable pageparts, etc.

The only problem with this that most browsers do not have an URL change event, based on which, the AJAX content can be loaded, so practicly what the plugin is doing is that from time to time it monitors the URL and if it changed, triggers an event based on tha after-hash-sign-parameters.
So basically what you do here is

    $('a').click(function() {  
    **//change the after-hash-sign-params to the value of the clicked link**
        $.address.value($(this).attr('href'));

    });
    $.address.change(function(event) { 
 **//define an event handler based on the params...**
         if (event.value = 'sortbyname')
            sortstuffbyname()
else if (event.value ='sortbysomethingelse')
         sortstuffbysomethingelse();
        // do something depending on the event.value property, e.g.  
        // $('#content').load(event.value + '.xml');  
    });  

I never tried the other plugin but working principles are probably the same.

小兔几 2024-08-23 03:55:28

该插件似乎有适度的文档,但如果您正在寻找更深入的东西来做同样的事情,我会查看 jQuery BBQ:http://benalman.com/projects/jquery-bbq-plugin/

它的 $.param 实现被放入 jQuery 1.4 中,其 deparam 实现是目前唯一可以读取该新格式的东西。此外,文档也很棒。

The plugin seems to have moderate documentation, but if you're looking for something a little more in depth that does the same sort of thing, I would check out jQuery BBQ: http://benalman.com/projects/jquery-bbq-plugin/

It's $.param implementation is being put into jQuery 1.4 and its deparam implementation is currently the only thing that reads that new format. Also, the documentation is great.

心安伴我暖 2024-08-23 03:55:28

找到了这个在线教程,我认为它对我们了解如何使用 jQuery Address 很有帮助。那里也提供了代码示例。值得一看。

http://www.thetutorialblog.com/jquery/deep-linking-with- jquery/

Found this online tutorial which I think was helpful for us to understand how to use jQuery Address. Code examples provided there too. Worth taking a look.

http://www.thetutorialblog.com/jquery/deep-linking-with-jquery/

醉生梦死 2024-08-23 03:55:28

我还发现了如何使用 Jquery 地址,并偶然发现了这个网站,该网站使用它来兼容他们的视差网站。

网址:http://www.goodstuph.org/#/home

希望这会有所帮助。

I'm also finding out how to use Jquery address and chance upon this web site which uses it to compliemnt their parallax site.

Url: http://www.goodstuph.org/#/home

Hope this help in someway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文