开发者

How to refresh the web page when user select a particular value on dropdown list on rails?

开发者 https://www.devze.com 2023-04-13 02:32 出处:网络
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 ?

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") %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号