mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
add missing :before and :after callbacks for link_to_remote
This commit is contained in:
committed by
Stefan Penner
parent
426a6b2e00
commit
133f6011d0
@@ -600,7 +600,7 @@ module ActionView
|
||||
|
||||
private
|
||||
def set_callbacks(options, html)
|
||||
[:uninitialized, :complete, :failure, :success, :interactive, :loaded, :loading].each do |type|
|
||||
[:before, :after, :uninitialized, :complete, :failure, :success, :interactive, :loaded, :loading].each do |type|
|
||||
html["data-on#{type}"] = options.delete(type.to_sym)
|
||||
end
|
||||
|
||||
|
||||
@@ -86,6 +86,11 @@ class AjaxHelperTest < AjaxHelperBaseTest
|
||||
link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :position => :bottom)
|
||||
end
|
||||
|
||||
test "link_to_remote with before/after callbacks" do
|
||||
assert_dom_equal %(<a href=\"#\" data-remote=\"true\" data-url=\"http://www.example.com/whatnot\" data-onbefore=\"before();\" data-onafter=\"after();\">Remote outauthor</a>),
|
||||
link_to_remote("Remote outauthor", :url => { :action => "whatnot" }, :before => "before();", :after => "after();")
|
||||
end
|
||||
|
||||
test "link_to_remote with method delete" do
|
||||
assert_dom_equal %(<a class=\"fine\" href=\"#\" data-remote=\"true\" data-url=\"http://www.example.com/whatnot\" data-method=\"delete\" rel=\"nofollow\">Remote outauthor</a>),
|
||||
link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :method => "delete"}, { :class => "fine" })
|
||||
|
||||
Reference in New Issue
Block a user