0

I have a landing page with two tabs when i click on tabB I use js and update div

$.get("/users", function(data) {}); 

$('.userTable').html("<%= escape_javascript render(:file => 'users/index.html.erb') %> ");

How I can change the url in address bar also?? Every tab has function like create, edit which is also I do using ajax. How I can change url in address bar for create and update?? I check some railscast but none of them is talking about crud. Thanks a ton in advance for help.

user588324
  • 310
  • 1
  • 6
  • 19

1 Answers1

1

You can use the history manipulation api:

//Change address to http://www.test.com/page.php:
history.pushState('', '', 'http://www.test.com/page.php');

See How do I do awesome refreshless page changes like GitHub do? or https://github.com/blog/760-the-tree-slider

Community
  • 1
  • 1
Ilyssis
  • 4,849
  • 7
  • 24
  • 30
  • Do all browser versions support the pushState() method, or only the lasst versions of each browsers? – Reporter Aug 06 '13 at 14:17
  • http://stackoverflow.com/questions/3722815/does-internet-explorer-support-pushstate-and-replacestate – Ilyssis Aug 06 '13 at 14:18
  • How this is going to work? from where i will get the url to pass here `history.pushState('', '', 'from where??');` – user588324 Aug 06 '13 at 15:29
  • Not 'from where' but to where. Just enter the code above into your javascript code, and you will see the url in the address bar changes. – Ilyssis Aug 06 '13 at 15:42