0
我遇到了涉及javascript的rails問題。基本上,我有以下代碼:(Rails,Javascript)RJS「無法找到變量」錯誤,但不提供詳細信息
<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%>)   <%=point.name%>
</li>
<%= draggable_element(domid, :ghosting => true, :revert => true, :scroll => "window")%>
<%end%>
</ul>
但是,我不斷收到RJS錯誤,告訴我「無法找到變量:點」。錯誤與DOMID有關,因爲當我將單詞「point」改爲「alksdjflksdjfls」(a.k.a.垃圾)時,它會警告我關於垃圾名稱。說到Javascript,我承認生鏽,但這個錯誤似乎沒有提供足夠的信息。有人可以告訴我我的代碼有什麼問題嗎?
僅供參考,誤差來到我的控制器,當我說:
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進行調試。思考?
最好。