javascript - jQuery autocomplete and back button behaviour? -
i'm using awesome jquery autocomplete plugin. i'm bit of newbie when comes understanding browser behaviour , ajax, have question.
this sequence of events:
- user types 'fish' text box
- user chooses book title list of autocomplete options - fish farming, fish frying, etc
- html loads on page (as ajax) - 'click here fish farming'
- user clicks on link , loads fish farming page
- user decides fish farming isn't them, clicks on 'back' button - , returns empty page!
how can change when user returns home page, see fish farming html - page looking at?
this autocomplete code:
// autocomplete listener. $("#q").catcomplete({ source: "/book_results", select: function(event,ui) { $('#book_results').html(load_img); if (ui.item.category=="books") { $.bbq.removestate(); var paramsobj = { 'b' : ui.item.id }; $.bbq.pushstate( paramsobj ); get_books(null, null, null, ui.item.id); } else { $.bbq.removestate(); var paramsobj = { 's' : ui.item.id }; $.bbq.pushstate( paramsobj ); get_books(null, ui.item.id, null); } } });
as can see, i'm using bbq plugin update url fragment when user chooses autocomplete, because seemed idea.
so have book_id
set in hash - how can ensure relevant html loads when user clicks back?
thanks!
as user makes choices append anchors uri or session state.
make new events , forward buttons , traverse lists accordingly.
Comments
Post a Comment