【发布时间】:2015-01-26 11:14:34
【问题描述】:
我遇到了 Rails 的问题。我想要一个在单击时呈现部分视图的选择表单。我希望部分视图在不刷新整个文档(Ajax)的情况下有效,但似乎remote: true 对我不起作用......
我目前拥有的并刷新整个文档:
= form_tag url_for(action: :index), method: 'get' do
//Storing some informations in html fields for further use
- shops_array = @shops.collect.with_index { |shop, i| [shop.title, shop.id, {'address' => [shop.address, shop.zipcode, shop.city].join(" ")}, {'id' => 'shop'+String(i)}] }
= select_tag :shop_id, options_for_select(shops_array, @shop_id), prompt: "Your shop :", data: {submit_on_change: true}
我尝试过的:
= form_tag url_for(action: :index), remote: true, method: 'get' do
//Storing some informations in html fields for further use
- shops_array = @shops.collect.with_index { |shop, i| [shop.title, shop.id, {'address' => [shop.address, shop.zipcode, shop.city].join(" ")}, {'id' => 'shop'+String(i)}] }
= select_tag :shop_id, options_for_select(shops_array, @shop_id), prompt: "Your shop :", data: {submit_on_change: true}
如何将remote: true 选项与url_for 一起应用?如果不可能,我可以使用一些帮助来寻找解决方法。
【问题讨论】:
标签: ruby-on-rails ruby ajax forms