This project is archived and is in readonly mode.
link_to doesn't behave when using image_tag and :confirm or :remote
Reported by Robs | March 12th, 2010 @ 05:28 AM | in 3.0.2
For example, this works fine:
<%= link_to 'Destroy', item, :confirm => 'Are you sure?', :method => :delete, :remote => true %>
However, this ignores the :confirm and :remote (:method appears to be respected):
<%= link_to image_tag('delete.png'), item, :confirm => 'Are you sure?', :method => :delete, :remote => true %>
I believe this has to do with $(document.body).observe("click", function(event) {...}) in rails.js. In the first line of code above, event.findElement() returns the link element. However in the second line of code, event.findElement() returns the image element.
If "a" is passed to event.findElement() it seems to traverse the dom correctly and find the link element:
//rails.js
// ...
$(document.body).observe("click", function(event) {
var message = event.findElement("a").readAttribute('data-confirm');
// ...
Does this work?
Comments and changes to this ticket
-
Marc Schütz March 12th, 2010 @ 10:23 AM
- Tag changed from :confirm, :remote, image_tag, link_to to :confirm, :remote, image_tag, link_to, ujs
Please have a look at #4133.
-
José Valim March 12th, 2010 @ 06:37 PM
- State changed from new to duplicate
- Assigned user set to José Valim
- Milestone cleared.
Marking as duplicated of #4133.
-
info (at tomrothe) April 14th, 2010 @ 12:36 PM
the issue is still not solved, since #4133 was marked invalid. please reopen this ticket.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Referenced by
- 4133 browser compatibility changes for prototype-ujs Updated patch to make link_to with images work, as sugges...