@category}) do %> -6ren">
gpt4 book ai didi

javascript - 未定义方法submit_to_remote

转载 作者:行者123 更新时间:2023-12-02 19:16:27 25 4
gpt4 key购买 nike

<%= submit_to_remote(:category, :url => params[:id].blank? ? {:action => 'create'} : {:action => "update", :id => @category}) do %>
<table>
<tr>
<th>Name</th>

</tr>

<tr>
<td><%= text_field(:category, :name, :size => 20) %></td>
<td><%= submit_tag(params[:id].blank? ? "New": "Edit") %></td>
</tr>
</table>
<% end %>

我想使用 Ajax 创建新记录。我得到错误未定义方法submit_to_remote我在布局中声明了原型(prototype)文件。 等待答案.......

最佳答案

首先,您的 submit_to_remote 似乎正在尝试定义 form - 因此请使用 form_forform_tag .

其次,Rails 3 中不再存在 submit_to_remote 。您需要 form_tag:remote => true 选项,这将使 UJS (不显眼的 JavaScript)介入并让 AJAX 发生。

参见some docs .

关于javascript - 未定义方法submit_to_remote,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13069256/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com