Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

link_to doesn't behave when using image_tag and :confirm or :remote

#4156

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?

Reported by Robs · March 12th, 2010 @ 05:28 AM

State: duplicate
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: none

Activity

  1. Marc Schütz
    Marc Schütz
    • Tag changed from :confirm, :remote, image_tag, link_to to :confirm, :remote, image_tag, link_to, ujs

    March 12th, 2010 @ 10:23 AM

  2. José Valim
    José Valim
    • State changed from new to duplicate
    • Assigned user set to José Valim
    • Milestone cleared.

    March 12th, 2010 @ 06:37 PM

  3. info (at tomrothe)
    info (at tomrothe)

    the issue is still not solved, since #4133 browser compatibility changes for prototype-ujs was marked invalid. please reopen this ticket.

    April 14th, 2010 @ 12:36 PM

  4. Jeremy Kemper