Rails3Switch菜单在更改数据时重新加载页面



用户可以编辑他的帐户,并有一个菜单来选择他的社区:

<%= form_for @user, :html => { :multipart => true } do |f| %>
    <%= f.collection_select :community_id, Community.find(:all,
    :include => :memberships,
    :conditions => ['memberships.user_id = ? and memberships.role > ?', @user.id, '0' ]),
    :id,
    :name,
    :style => "width: 200px;" %>
<% end %>

我想把这个菜单放在节目页面上,让他可以直接切换。

对于rails 2,我使用了observe_field或:onchange=>'this.form.onsubmit()',但我不知道java…

<%= form_for @user, :remote => true do |f| %>
<%= f.collection_select :community_id,
Community.where('memberships.user_id = ? and memberships.role > ?', @user.id, '0').includes(:memberships), :id, :name,{},
:onchange => "this.form.submit();" %>   
<% end %>

将this.form.onsubmit()更改为this.form.submit(

相关内容

  • 没有找到相关文章

最新更新