Gmail like URL scheme
- by Varun
I am working on a ticket system, having the following requirement:
The home page is divided into two sections:
Sec-1. Some filter options are shown here.(like closed-tickets, open-tickets, all-tickets, tickets-assigned-to-me etc.). You can select one or more of these filters.
sec-2. List of tickets satisfying above filters will be displayed here.
Now this is what I want: As I change the filters
-- the change should be reflected in the URL, so that one is able to bookmark it.
-- an ajax request will go and list of tickets satisfying the selected filters will be updated in sec-2.
I want the same code to be used to load the tickets in both ways-
(a) by selecting that set of filters and
(b) by using the bookmark to reload the page.
I have little idea on how to do it:
The URL will contain the selected filters.(appended after #)
changing filters on the page will modify the hash part of URL and call a function (say ajaxHandler()) to parse the URL to get the filters and then make an ajax request to get the list of tickets to be displayed in section2.
and
I will call the same function ajaxHandler() in window.onload.
I feel this is what Yahoo maps does.
What's the best way to implement such URL scheme?
Am I headed in the right direction?