jQuery jquery地址你是怎么用的?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1955978/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 12:27:47  来源:igfitidea点击:

jquery address how do you use it?

jqueryajaxdeep-linkingjquery-address

提问by ajsie

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

我试图了解如何使用 jQuery 地址插件来处理与 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.valuedo? It says "Provides the current deep linking value." What does it even mean? And what does it do with it?

我的意思是,有什么作用$.address.value?它说“提供当前的深层链接值”。它甚至意味着什么?它与它有什么关系?

采纳答案by Alex Sexton

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/

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

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.

它的 $.param 实现正在被放入 jQuery 1.4 并且它的 deparam 实现是目前唯一读取这种新格式的东西。此外,文档很棒。

回答by Oras Laszlo

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.

简短的吐槽:使用 AJAX 的最大警告是 URL 不会改变,因此后退按钮不起作用 + 链接不会被抓取。解决方法是使用 URL 中的页面部分锚点,# 符号。根据 hashsign 后的数据,您可以使用 AJAX、加载可抓取的页面部分等。

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

唯一的问题是大多数浏览器没有 URL 更改事件,基于此可以加载 AJAX 内容,因此插件所做的实际上是不时监视 URL,如果更改,则触发基于 tha 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');  
    });  

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

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

回答by woodykiddy

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.

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

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

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

回答by Kelvin Chow

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

我还发现如何在这个网站上使用 Jquery 地址和机会,该网站使用它来满足他们的视差网站。

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

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

Hope this help in someway.

希望这在某种程度上有所帮助。