简体   繁体   中英

jQuery Address, changing a parameter? (deep linking)

I'm using jQuery Address to perform deep linking in an ajax site.

I have multiple arguments like this: /SomeController/SomeAction#/586?e=5808&tab=#First

Q1: How do I change just the "tab" parameter?
When I do it like this...

$("#tabs").bind("tabsselect", function(event, ui) {
    $.address.parameter("tab", ui.tab.hash);
}

..the result is: /SomeController/SomeAction#/586?e=5808&tab=#First#Third
instead of the desired: /SomeController/SomeAction#/586?e=5808&tab=#Third

In the event above the other parameters in the url hash should be considered unknown and must remain as they are.

Q2: How do I remove a parameter from the url hash?
Like above but if I want to remove the tab parameter completely.

Thank you!

The link you provided has a tabs example

http://www.asual.com/jquery/address/samples/tabs/#Overview

You can snoop the code with firebug. It looks clean

I know this is a very old question but thought id still answer.

You must first set the parameter to null to remove it then assign the new value:

$.address.parameter('tab', null) 
$.address.parameter('tab', ui.tab.hash)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM