views:

70

answers:

1

I built this website using ajax (via jquery) instead of full page refresh. Right now, it does not support the browser's back/next buttons, nor deeplink bookmarking. I'd like to implement these functionalities, using for instance the jquery bbq plugin but i'm not sure i understand completely the concept.

The main point i'm missing is this: do i need to modify all my links?

For instance, take this url:

http://example.com/projects/title-of-project/visuals/video/

My application converts the url into these vars:

section = projects
item= title-of-project
content=visuals
id=video

The php script detects whether this is an ajax call (thus only returns the video html) or a non ajax call (thus returns the full page html, with the video code inside).

If i use hashes instead, the browser will not send the variables. right?

I'm a bit lost so don't hesitate to comment if you need more details.

+3  A: 

Basically, hash-permalinks work like this:

  1. User clicks on a link, which makes an AJAX call to some other URL.
  2. The click event tells the history-managing code (like the BBQ plugin) to update the hash, the part of the URL after the pound character (#).
  3. The history-managing code makes sure that when the user clicks the back or forward button, the browser hash changes to its last or next state.
  4. The history-managing code fires an event when it thinks the hash has changed.
  5. Your app responds to the event and determines what new URL to get contents from, using the browser hash.

For example, let's say a link on your site uses AJAX to load content from http://example.com/some/path. When the user clicks the link, the browser URL could be http://yoursite.com/#some/path. When another link is clicked, the hash could change to #some/other/path. When the user hits the back button, the hash should be returned to #some/path. Your app would then take the current hash and then use AJAX to load http://example.com/some/path accordingly.

So, the URLs that AJAX grabs content from don't have to change. Does that make sense? I may have misunderstood your question.

ashrewdmint
no, your explanation is really helpful to clarify things to me. So basically, i don't need to change the url? If i understood you correctly, it means i have to tell the script what should be stored in the hash on every click. i looked through the bbq plugin documentation but didn't quite understood how to do that.
pixeline
ashrewdmint