This project is archived and is in readonly mode.

#4663 ✓resolved
Jérémie Horhant (Titinux)

Problem with prototype UJS and pictures as links

Reported by Jérémie Horhant (Titinux) | May 21st, 2010 @ 05:23 PM | in 3.0.5


I have a little problem with the click observer of the prototype UJS file. When you use an image as a link the confirmation popup does not show up.

link_to ..., {:confirm => 'Are you sure ?'), :method => :delete} do
  image_tag ...

which produce this html

<a href="..." data-confirm="Are you sure ?" data-method="delete" rel="nofollow"><img src="..." /></a>

The click observer (line 61 of railties/lib/rails/generators/rails/app/templates/public/javascripts/rails.js)

  $(document.body).observe("click", function(event) {
    var message = event.findElement().readAttribute('data-confirm');
    if (message && !confirm(message)) {
    return false;

In this case the event.findElement() does not return the link but the image and that why data-confirm can't be found.
I suggest to replace event.findElement() by event.findElement("a") and findElement will go up to find the a markup.

Sorry for my ignorance but how can I make a patch ? Fork rails/prototype-ujs, make the correction, commit and make a pull request ?

Thanks in advance.
Jérémie Horhant

Comments and changes to 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=""></a>