Rails 3 data errors with link_to
I've been searching for a while for a solution, but haven't been able to find out what is wrong with my code.

I'm trying to delete an item using an ajax call on an event page, but it doesn't seem to work.

    <%= link_to 'X', { :controller => 'items', :action => 'destroy', :id => item.id }, :method => :delete, :confirm => 'Are you sure you want to delete this item?', :remote => true %>

    <a rel="nofollow" data-method="delete" data-confirm="Are you sure you want to delete this item?" href="/items/83">X</a>

I believe everything looks right, however, the data attributes don't seem to work. No confirmation occurs when I click this and instead it calls the 'show' action for the controller, so the data-method is not working either.

The weirdest part is that I something else on the page that generates the confirmation messages.

    <%= link_to image_tag("trashcan.png"), @event, :confirm => 'Are you sure you want to delete this event?', :method => :delete %>
    
    <a rel="nofollow" data-method="delete" data-confirm="Are you sure you want to delete this event?" href="/events/3">

I've tried changing the 'X' in the first one to an image (in case an image_tag did the trick) - no luck. However, when I changed the link_to to a button_to it did delete, but not confirmation which I assume button does not support. So I'm not sure if I maybe has some javascript error somewhere else, which I assume to not be the case since it works in the other case or maybe I'm missing something somewhere.

Thanks for your help!
Rails 3 data errors with link_to
===

I've been searching for a while for a solution, but haven't been able to find out what is wrong with my code.

I'm trying to delete an item using an ajax call on an event page, but it doesn't seem to work.

    <%= link_to 'X', { :controller => 'items', :action => 'destroy', :id => item.id }, :method => :delete, :confirm => 'Are you sure you want to delete this item?', :remote => true %>

    <a rel="nofollow" data-method="delete" data-confirm="Are you sure you want to delete this item?" href="/items/83">X</a>

I believe everything looks right, however, the data attributes don't seem to work. No confirmation occurs when I click this and instead it calls the 'show' action for the controller, so the data-method is not working either.

The weirdest part is that I something else on the page that generates the confirmation messages.

    <%= link_to image_tag("trashcan.png"), @event, :confirm => 'Are you sure you want to delete this event?', :method => :delete %>
    
    <a rel="nofollow" data-method="delete" data-confirm="Are you sure you want to delete this event?" href="/events/3">

I've tried changing the 'X' in the first one to an image (in case an image_tag did the trick) - no luck. However, when I changed the link_to to a button_to it did delete, but not confirmation which I assume button does not support. So I'm not sure if I maybe has some javascript error somewhere else, which I assume to not be the case since it works in the other case or maybe I'm missing something somewhere.

Thanks for your help!