Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11537 (new defect)

Opened 8 months ago

[PATCH] link_to with :method => :delete ignores :target option in html_options

Reported by: thijslangeveld Assigned to: core
Priority: high Milestone: 2.x
Component: ActionPack Version: edge
Severity: normal Keywords: link_to delete target rest
Cc:

Description

This patch fixes the 'link_to' method when the ':method' option is set to ':delete' and a ':target' option is given in html_options.

When the link_to method is passed the ':method => :delete' option, it yields an anchor tag with an onclick event that creates and submits a form. All user defined options are included in this form, except the :target option.

link_to("Destroy", "http://www.thijslangeveld.nl", :method => :delete, :target => '_top')

should yield:

<a href='http://www.thijslangeveld.nl' onclick=\"var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.target = this.target;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit();return false;\" target=\"_top\">Destroy</a>

Instead, it lacks the 'f.target = this.target' part. This means that the request will always render in the current window while it should be rendered in the window that is designated by the target option, if present.

Attachments

link_tag_using_delete_javascript_and_target_plus_test.diff (3.1 kB) - added by thijslangeveld on 04/06/08 14:18:49.

Change History

04/06/08 14:18:49 changed by thijslangeveld

  • attachment link_tag_using_delete_javascript_and_target_plus_test.diff added.