提交 89d8afa2 编写于 作者: D David Heinemeier Hansson

Added that JavaScriptHelper#link_to_function will honor existing :onclick...

Added that JavaScriptHelper#link_to_function will honor existing :onclick definitions when adding the function call [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3365 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 341d34cd
......@@ -53,7 +53,7 @@ def link_to_function(name, function, html_options = {})
"a", name,
html_options.merge({
:href => html_options[:href] || "#",
:onclick => "#{function};#{html_options[:onclick] ? " #{html_options[:onclick]};" : ""} return false;"
:onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function}; return false;"
})
)
end
......
......@@ -27,7 +27,7 @@ def test_link_to_function
end
def test_link_to_function_with_existing_onclick
assert_dom_equal %(<a href="#" onclick="alert('Hello world!'); confirm('Sanity!'); return false;">Greeting</a>),
assert_dom_equal %(<a href="#" onclick="confirm('Sanity!'); alert('Hello world!'); return false;">Greeting</a>),
link_to_function("Greeting", "alert('Hello world!')", :onclick => "confirm('Sanity!')")
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册