{:action => "add_point"-6ren">
gpt4 book ai didi

javascript - (Rails,Javascript) RJS "Can' t 查找变量“错误未提供详细信息

转载 作者:行者123 更新时间:2023-12-02 20:46:29 28 4
gpt4 key购买 nike

我遇到了涉及 javascript 的 Rails 问题。基本上,我有以下代码:

<ul id="all-points">
<%for point in Point.find(:all)%>
<%domid = "point[all][#{point.id}]"%>
<li class="available-point" id='<%=domid%>'>
<span>
<%= link_to_remote "ADD",:url => {:action => "add_point"},
:html => {:style => "background: wheat; color: gray; text-decoration: none; border: 1px solid gray;"},
:with => "'point=' + #{domid}"
%>
</span>
(<%=point.source%>) &nbsp <%=point.name%>
</li>
<%= draggable_element(domid, :ghosting => true, :revert => true, :scroll => "window")%>
<%end%>
</ul>

但是,我不断收到 RJS 错误,告诉我“找不到变量:点”。该错误与 DOMID 有关,因为当我将“point”一词更改为“alksdjflksdjfls”(又名垃圾)时,它会警告我有关垃圾名称的信息。诚然,我对 Javascript 很生疏,但这个错误似乎没有提供足够的信息。有人可以告诉我我的代码有什么问题吗?

仅供引用,当我说:

时,我的 Controller 出现错误:
def add_point
render :update do |page|
page.insert_html :bottom, "selected-points", "<li>test phrase</li>"
page.remove params[:point] #error occurs here
end
end

我也尝试过encodeURIComponent,但似乎没有什么关系。另外,我同时使用 Safari 和 Firefox 进行调试。想法?

最好。

最佳答案

哇。没关系。是一个试图过于严格地遵循一个例子的例子。字面主义失败了!将我的“:with”调整为“point = #{domid}”后,一切正常。

关于javascript - (Rails,Javascript) RJS "Can' t 查找变量“错误未提供详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1083414/

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