5

我正在 Rails 2.3.8 上开发项目,当用户在下拉菜单中选择特定选项时,我需要刷新整个网页。我怎样才能在铁轨上做到这一点?

这是我的下拉菜单

  <%= collection_select("country", "id", @countries , :id, :name, {:prompt => true}, :id => 'xx') %>
  <%= observe_field('xx', :url => { :controller => 'calendar', :action => 'update_country' },:update => 'app_header',:with => "'con=' + escape(value)")%>

这很好地加载了国家,所以我如何重新加载整个页面?请问有人可以解释一下吗?

4

2 回答 2

3

只需在您的集合中添加一个 html 选项 select , onchange => "Javascript code to reload the page"

<%= collection_select("country", "id", @countries , :id, :name, {:prompt => true}, :id => 'xx', :onchange => "location.href = '#{root_url}'") %>
于 2011-10-14T05:12:43.543 回答
0

或者您可以只刷新当前页面:

<%= collection_select("country", "id", @countries , :id, :name, {:prompt => true}, :id => 'xx', :onchange => "location.href = window.location.href") %>
于 2018-08-29T11:52:21.903 回答