Hi everyone, I am trying to implement the in_place_editor method and am trying to pass in each item.id as the elementID argument. So I''m trying to do something like this, <% in_place_editor(''title_<%=item.id%>'', :rows => "1",.....) %> But that doesn''t work. Here is my code, http://rafb.net/paste/results/K5yFSG20.html My goal here is to be able to make this in_place_editor work for each of the items in the list. Any ideas?? Thanks in advance! -- Posted via http://www.ruby-forum.com/.
On 12/4/05, Jordan Isip <jordanisip-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Hi everyone, I am trying to implement the in_place_editor method and am > trying to pass in each item.id as the elementID argument. So I''m trying > to do something like this, <% in_place_editor(''title_<%=item.id%>'', > :rows => "1",.....) %> But that doesn''t work.<% in_place_editor("title_#{item.id}", :rows => "1",.....) %>
Hi Jeremy, thanks for the reply. I did what you posted and I am getting an error message saying ''item'' is undefined. However, it works for item.id earlier in the code? Any ideas? Sorry I am a noob at rails. Here is my updated code with error message pasted in below: http://rafb.net/paste/results/T4b8ew63.html Thanks! jeremyevans0 wrote:> On 12/4/05, Jordan Isip <jordanisip-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: >> Hi everyone, I am trying to implement the in_place_editor method and am >> trying to pass in each item.id as the elementID argument. So I''m trying >> to do something like this, <% in_place_editor(''title_<%=item.id%>'', >> :rows => "1",.....) %> But that doesn''t work. > > <% in_place_editor("title_#{item.id}", :rows => "1",.....) %>-- Posted via http://www.ruby-forum.com/.
On 12/4/05, Jordan Isip <jordanisip-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> Hi Jeremy, thanks for the reply. I did what you posted and I am getting > an error message saying ''item'' is undefined. However, it works for > item.id earlier in the code? Any ideas? Sorry I am a noob at rails. > Here is my updated code with error message pasted in below: > > http://rafb.net/paste/results/T4b8ew63.htmlitem is defined as a local block variable earlier on in the code, that''s why it works there. item is undefined when you use it later. You may be able to get what you want by moving the sortable_element and in_place_editor inside the block. In any case, I''d pick up a good book on Ruby before you go much further. There''s a free online one at http://www.rubycentral.com/book/. It will explain variable scope among other important issues.
Ah you are right, it worked! Thanks for the help and the link! jeremyevans0 wrote:> On 12/4/05, Jordan Isip <jordanisip-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: >> Hi Jeremy, thanks for the reply. I did what you posted and I am getting >> an error message saying ''item'' is undefined. However, it works for >> item.id earlier in the code? Any ideas? Sorry I am a noob at rails. >> Here is my updated code with error message pasted in below: >> >> http://rafb.net/paste/results/T4b8ew63.html > > item is defined as a local block variable earlier on in the code, > that''s why it works there. item is undefined when you use it later. > You may be able to get what you want by moving the sortable_element > and in_place_editor inside the block. > > In any case, I''d pick up a good book on Ruby before you go much > further. There''s a free online one at > http://www.rubycentral.com/book/. It will explain variable scope > among other important issues.-- Posted via http://www.ruby-forum.com/.