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:

  1. user types 'fish' text box
  2. user chooses book title list of autocomplete options - fish farming, fish frying, etc
  3. html loads on page (as ajax) - 'click here fish farming'
  4. user clicks on link , loads fish farming page
  5. 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

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -