I have an Ajax site where I have browser navigation hooked up to ajax page loads in cases where navigation results in a change to the URL hash.
I was wondering what the best way to get navigation history is for ajax loads that don't result in a change to the hash.
So, say I have 'Level 1' links which, on clicking, result in a URL hash change. Something like the jquery history plugin picks that up and invoked my handler, and front/back navigation works fine for these 'Level 1' links.
But I have a set of 'Level 2' links that fetch data using the 'click' handler (which internally do some Ajax fetches) instead of going the URL hash + history plugin route. These currently don't result in a change to the URL/hash. I want these 'Level 2' links to be browser navigation enabled.
It seems like for this to work smoothly, I must change the URL so my guess is any solution here involves decorating the hash some more. One solution that might work but I'd never开发者_C百科 consider seriously is to encode the JS function name I wish to execute and the params into the URL hash somehow, and then have my history load handler invoke that function. Blech!
Anyone have clever ideas about how I can do this?
Hmmm... maybe the jQuery BBQ plugin is what you're looking for?
One thing I did for a project was use hash values like this:
IDProduct-8185--tab-tech--g-8184
Meaning there were 3 parameters: IDProduct = 8185, tab = "tech", and g = 8184. Then, I'd split
by "--" and loop over the resulting array. Probably not the most elegant solution, and works for very simple parameter values only. Better have a look at the BBQ plugin that Sean is suggesting first.
精彩评论