The Ultimation wrote:
> Hi, I'm trying to get my javascript to execute after clicking a link on
> my page using :format => "js" here's my link:
>
> <%= link_to image_tag("/images/icons/user_add.png"),
> add_contact_path(:profile_id => profile.id, :url => request.url, :format
> => "js"), :title => "Add person to your contacts"%>
>
> in my controller i have format.js
>
> here's my add_contact.js.erb:
>
> $("#contact_icon_<%=params[:profile_id]%>").html("Contact Added")
>
> Right now it just prints that code on the screen instead of executing
> it. I've done this before with a form where I submitted with AJAX but
> never with just a straight link before. Any thoughts? Thanks!
Generating JavaScript dynamically with ERb is almost never a good thing
in my experience. Make your JavaScript static by getting the profile_id
from the DOM or a URL parameter.
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.