0

I have a rails form that fires ajax by remote true as follows.

= form_tag(root_path, method: "get", remote: true) do ...

Works fine and all but how can I achieve the browser url to be updated with the search params ? What I want to achieve is that after successful response, the browser should be updated with the correct url as in normal rails html request.

Eg. localhost:3000/my_controller?status=canceled&search=mysearchkey&commit=Search

CodeSmith
  • 2,133
  • 1
  • 20
  • 43
user2004082
  • 141
  • 2
  • 8

1 Answers1

0

In success response write this little js code

window.history.pushState("", "", '/my_controller?&status=canceledsearch=mysearchkey&commit=Search');

Updating address bar with new URL without hash or reloading the page

I hope it will help you out

Community
  • 1
  • 1
Salman Tahir
  • 81
  • 1
  • 5