Rails 3更改数据时切换菜单重新加载页面

发布于 2024-11-13 04:17:30 字数 521 浏览 2 评论 0原文

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

<%= 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…

The user can edit his account and has a menu to choose his community :

<%= 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 %>

I would like to put this menu on the show page and give him the possibility to switch directly.

With rails 2, I used observe_field or :onchange => 'this.form.onsubmit()' and I don't know java…

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘羡 2024-11-20 04:17:30
<%= 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()

<%= 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 %>

Changed 'this.form.onsubmit() to 'this.form.submit()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文