This project is archived and is in readonly mode.

Patch that adds an exception
Reported by nasmorn | March 26th, 2009 @ 01:34 PM | in 3.x
<%= link_to 'bla', '#', {:onclick => "document.merge_form.submit()", :confirm => "Really?"}%>
will result in
<a onclick="return confirm('Really?');" href="#">bla</a>
with my onclick just eaten without any notice. If this isn't done for a specific reason I would propose 2 possible solutions. Allow only one of the two being set and throw an exception Wrap the onclick JS in the confirm
I totally understand that I will have to write the patch myself and just wanted to check if this is not for some reason intended behaviour, if it is I could add a comment on this to the link_to method.
Comments and changes to this ticket
-
Jeff April 5th, 2009 @ 10:07 PM
- Tag changed from action_view, javascript, link_to to action_view, javascript, link_to
I can't speak to what the intention is here, but if you look at the documentation for the link_to_function method, you'll one example of what you're trying to do
link_to_function(image_tag("delete"), "if (confirm('Really?')) do_delete()")
http://api.rubyonrails.org/class...
Maybe raising an exception or a warning would be a good idea, but I'm not sure that wrapping the onclick in the confirm is obvious.
-
nasmorn April 6th, 2009 @ 02:41 PM
- Tag changed from action_view, javascript, link_to to action_view, javascript, link_to, patch
- Title changed from :confirm overwrites :onclick to Patch that adds an exception
I hope this is acceptable, it does pretty much what the other exception does
-
-
Ryan Bigg October 6th, 2010 @ 02:10 AM
- State changed from new to incomplete
- Importance changed from to Low
Please add tests to this patch.
-
Ryan Bigg October 6th, 2010 @ 02:11 AM
- Tag changed from action_view, javascript, link_to, patch to action_view, needs_tests
-
Ben Mills October 6th, 2010 @ 02:58 AM
- Assigned user set to Ryan Bigg
In Rails master seems to do just what it should. Rails 3 utilizes the HTML5 attribute data-confirm to handle the confirmation.
<%= link_to 'bla', '#', {:onclick => "document.merge_form.submit()", :confirm => "Really?"}%>
Outputs:
<a href="#" data-confirm="Really?" onclick="document.merge_form.submit()">bla</a>
Since it seems unnecessary, my vote:
-1
-
-
-
-
Piotr Sarnacki December 17th, 2010 @ 10:36 AM
- State changed from incomplete to invalid
I'm closing that. As Ben noticed, 3.x is no longer adding stuff to onclick attribute.
-
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>