Forum: Ruby on Rails Edit link id is not passing while doing ajax edit link.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
46911700017303070d64f73b69bb04a8?d=identicon&s=25 Guest (Guest)
on 2007-03-07 07:10
hi all,

   now i am stuggling to pass the edit id to the ajax edit link. please
kindly help me to pass the id. here i have put my coding below.

company.rhtml file

 <% for company in @Edia_comp_addr %>
                                 <tr>

                                   <td><%= company.street_addr%></td>
                                   <td><%=company.city%></td>
                                   <td><%=company.state%></td>
                                   <td><%=company.pin%></td>
                                   <td
width=10%><%=company.branch%></td>
                                   <td width=10%>
                        <%= link_to_remote "EDIT",
         :update => 'detail',
   :with     => "'addr=' + escape($F('company.id'))  " ,
         :url    => { :action => 'edit_comp_addr' }
        %> </td>
                               </tr>
           <% end %>


company.rb

def edit_comp_addr

    @tmp=params[:addr]
    render :text => @tmp


  end


please help me asap
6165aecb1a97c3ee6df433e38b49ca37?d=identicon&s=25 Blake Miller (Guest)
on 2007-03-07 08:36
(Received via mailing list)
Guest,

:with=>"'addr=' + escape($F('company.id')) "

Keep in mind that this string you are passing is entirely JavaScript.
company.id is a ruby expression, and only confuses your poor JS
interpreter which knows nothing of ruby.

Try this:

:with=>"'company_id='+#{company.id}"

Then ruby will insert the value of company.id as a string, which gets
passed to JS, serialized with the form, becomes part of the AJAX
request, etc. The value of company.id should arrive at the action as
params[:company_id].

<rant>
Again we run into the same paradox: IE is the worst environment in
which to try to debug JS (seriously, you'd be better off debugging JS
at a rave, or underwater, or in a dark closet . . . its making me
queasy just thinking about it), and yet there are tons of quirky,
subtle IE-specific JS problems lurking out there. IE is bad!
</rant>

Cheers,
Blake Miller
46911700017303070d64f73b69bb04a8?d=identicon&s=25 Guest (Guest)
on 2007-03-07 09:06
hi,

   Thanks a lot. i got the answer.


Blake Miller wrote:
> Guest,
>
> :with=>"'addr=' + escape($F('company.id')) "
>
> Keep in mind that this string you are passing is entirely JavaScript.
> company.id is a ruby expression, and only confuses your poor JS
> interpreter which knows nothing of ruby.
>
> Try this:
>
> :with=>"'company_id='+#{company.id}"
>
> Then ruby will insert the value of company.id as a string, which gets
> passed to JS, serialized with the form, becomes part of the AJAX
> request, etc. The value of company.id should arrive at the action as
> params[:company_id].
>
> <rant>
> Again we run into the same paradox: IE is the worst environment in
> which to try to debug JS (seriously, you'd be better off debugging JS
> at a rave, or underwater, or in a dark closet . . . its making me
> queasy just thinking about it), and yet there are tons of quirky,
> subtle IE-specific JS problems lurking out there. IE is bad!
> </rant>
>
> Cheers,
> Blake Miller
This topic is locked and can not be replied to.