Is there a way to get link_to to generate a body-less anchor?
I have a CSS sprite which represents an “add” / “remove” button which I
use, so I don’t want any body text. For example, I want something
similar to this:
<a title=‘Add Attachment’ class=‘add_child’ onclick=‘add_asset_row’>
Using this does not work:
<%= link_to ‘#’, :url => {:action => ‘add_asset_row’}, :title => ‘Add
attachment’, :class => ‘add_child’, :remote => true %>
Any suggestions?
Is there a way to get link_to to generate a body-less anchor?
Not sure I understand as what you ask for below isn’t an anchor… ??
But maybe what you want is…
link_to_function ‘’, ‘add_asset_row()’, :class => ‘add_child’
Or if you really want a remote link just replace that ‘#’ with ‘’ and it
should give you an empty link…
Philip H. wrote in post #979207:
Not sure I understand as what you ask for below isn’t an anchor… ??
But maybe what you want is…
link_to_function ‘’, ‘add_asset_row()’, :class => ‘add_child’
Or if you really want a remote link just replace that ‘#’ with ‘’ and it
should give you an empty link…
Using ‘’ with link_to forces it to use the href as the body. But,
switching to link_to_function using ‘’ got rid of the body.
Thanks for the tip!
Now I need to figure out how to get it working with jQuery since I’m not
using Prototype…
Edward S. wrote in post #979228:
Now I need to figure out how to get it working with jQuery since I’m not
using Prototype…
Here’s how I got it to work using jQuery:
<%=link_to_function ‘’, “$(’#asset_rows’).append(’#{escape_javascript
render(:partial => ‘partials/asset_row’, :locals => {:asset =>
Asset.new})}’)”, :title => ‘Add Attachment’, :class => ‘add_child’ %>
Now on to the “remove” button…
if you name your partial
partials/rows/asset
then you can use
:object => Asset.new
instead of :locals => …
On Wed, Feb 2, 2011 at 11:22 AM, Edward S. [email protected]
wrote:
Now on to the remove button…
–
make haste slowly
festina lente \
mobile +1_415_632_6001
[email protected]
http://robotarmyma.de