0

I am building application where most of all the request are ajax or remote form ( new,create,show,edit etc.). i am just updating a common div on each request.

now i need a back button, onclick the div must be updated with previous contents (somewhat similar to gmail's back link)

can anyone tell me how it can be achieved in rails 3.?

anil.n
  • 509
  • 2
  • 5
  • 17

1 Answers1

0

The idea is to bookmark/historize the urls.

Let's say you have an ajax submit button form with the submitButton id :

$("#submitButton").bind("click",function(){

   // do you AJAX stuff here (form validation, form sending, etc.)
   $.getScript(this.href);
   history.pushState(null, "", this.href);
});

$(window).bind("popstate",function(){
   $.getScript(location.href);
});

With this code, you are enabling the back button history.

Please refer to that SO post for more information.

Community
  • 1
  • 1
Zakaria
  • 14,892
  • 22
  • 84
  • 125