link_to a method that outputs to a popup


I am trying to implement a popup window that will contain the output of
a method called by a link_to tag.

I am using Rails 3 with jQuery and have read that :popup => true no
longer works.

I have also read a post that said...

# --- Start of Post
Another option is to use the Rails 3 unobtrusive way of event
delegating those links:

- Add an attribute "data-popup" to your link_to if you want it to open
in a new window

With the jquery adapter, add to application.js inside the document
ready handler:

   $('a[data-popup]').live('click', function(e) {$(this).href);
#--- End of post

I do not know how to "Add an attribute" to my link_to tag. I have tried
:class => "data-popup" and
:name => "data-popup" (and $('a[name=data-popup]').live ...

and many other combinations. Using firebug, I've determined that the
jQuery function never gets called when I click the link.

The latest version of my link_to tag looks like:

<%= link_to h(link_str ||= "Click to add"),
edit_comment_path(cart_item), :method => :get, :name => "data-popup" %>

Has anyone done this?

If so, I am anxiously awaiting your reply...


I haven’t tried it yet but to add a ‘data-popup’ attribute try using

<%= link_to h(link_str ||= “Click to add”), edit_comment_path(cart_item), :method => :get, ‘data-popup’ => true %>