简体   繁体   中英

jQuery BBQ Push State with '?x=y' Query

I have been using http://benalman.com/projects/jquery-bbq-plugin/ push and react to URL's (AJAX loaded URLS)...

Currently I have Urls like:

article/category/specific -> http://mypage.com/#article/category/specific
article/single/id -> http://mypage.com/#article/single/id

And so on, that works really well...

Now I have the need to augment that further with some parameters like ?l=http://mypage.com/whereicamefrom

This is for very specific situations where I wish that the user can store/bookmark the current url, but needs to know where that url started. Specifically when the URL changes by other means that the user clicking linkes etc...

Like performing a search, because searching would make the following url:

search/query -> http://mypage.com/#search/query

//I Would like (): 
search/query -> http://mypage.com/#search/query?l=article/category/specific
search/query -> http://mypage.com/#search/query?l=article/single/id
//(Depending on where you came from)

If I just try to pushstate with 'search/query?l=article/single/id' however, ? gets transformed to '%3F'...

DOH!!!!!! Never mind... this didn't work due to another thing, i missed a "#" in the start of the hash I tried to push on page search... Ohh god... good thing that typing down your question can get your thoughts out of the circle your sitting in.

DOH!!!!!! Never mind... this didn't work due to another thing, i missed a "#" in the start of the hash I tried to push on page search... Ohh god... good thing that typing down your question can get your thoughts out of the circle your sitting in.

So I pushed: 'search/query?l=article/single/id" Where I should have pushed: '#search/query?l=article/single/id"

Then it works... (I feel a bit stupid now)

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