How to refresh the web page when user select a particular value on dropdown list on rails?
I'm developing project on rails 2.3.8 and I need to refresh the whole web page when user select particular selection on drop-down menu. How can I do it on rails ?
This is my drop down menu
<%= collection_select("country", "id", @countries , :id, :name, {:prompt => true}, :id => 'xx') %>
<%= observe_field('xx', :url => { :controller => 'c开发者_C百科alendar', :action => 'update_country' },:update => 'app_header',:with => "'con=' + escape(value)")%>
This finely load the countries so how I can reload the whole page ? please can some one explain me about this?
Simply add a html option to your collection select , onchange => "Javascript code to reload the page"
<%= collection_select("country", "id", @countries , :id, :name, {:prompt => true}, :id => 'xx', :onchange => "location.href = '#{root_url}'") %>
Or you can just refresh the current page:
<%= collection_select("country", "id", @countries , :id, :name, {:prompt => true}, :id => 'xx', :onchange => "location.href = window.location.href") %>
精彩评论