gberz3
2009-Jul-05 03:45 UTC
RJS error ("Can''t find variable: point") not providing sufficient information.
Hi All, I''m having an issue with rails involving javascript. Basically, I have the following code: <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> However, I keep receiving RJS errors telling me "Can''t find variable: point". The error has something to do with DOMID as when I change the word "point" to "alksdjflksdjfls" (a.k.a. garbage), it warns me about the garbage name. I''m admittedly rusty when it comes to Javascript, but this error doesn''t seem to give enough info. Can someone please tell me what is wrong with my code? FYI, the error comes in my controller when I say: 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 I''ve tried encodeURIComponent as well, but nothing seems to matter. Also, I''m using both Safari and Firefox to debug. Thoughts? Best.
gberz3
2009-Jul-05 03:51 UTC
Re: RJS error ("Can''t find variable: point") not providing sufficient information.
Wow. Nevermind. Was a case of attempting to follow an example too closely. Literalism FAIL! After adjusting my ":with" to "point = # {domid}" everything worked. On Jul 4, 11:45 pm, gberz3 <gbe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi All, > > I''m having an issue with rails involving javascript. Basically, I > have the following code: > > <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> > > However, I keep receiving RJS errors telling me "Can''t find variable: > point". The error has something to do with DOMID as when I change the > word "point" to "alksdjflksdjfls" (a.k.a. garbage), it warns me about > the garbage name. I''m admittedly rusty when it comes to Javascript, > but this error doesn''t seem to give enough info. Can someone please > tell me what is wrong with my code? > > FYI, the error comes in my controller when I say: > > 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 > > I''ve tried encodeURIComponent as well, but nothing seems to matter. > Also, I''m using both Safari and Firefox to debug. Thoughts? > > Best.