mirror of
https://github.com/github/rails.git
synced 2026-01-30 16:58:15 -05:00
Tidy up link to remote options. Closes #9505. [nik.wakelin]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7468 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -45,6 +45,13 @@ module ActionView
|
||||
# :url => { :action => "destroy", :id => post.id }
|
||||
# link_to_remote(image_tag("refresh"), :update => "emails",
|
||||
# :url => { :action => "list_emails" })
|
||||
#
|
||||
# You can override the generated HTML options by specifying a hash in
|
||||
# <tt>options[:html]</tt>.
|
||||
#
|
||||
# link_to_remote "Delete this post", :update => "posts",
|
||||
# :url => post_url(@post), :method => :delete,
|
||||
# :html => { :class => "destructive" }
|
||||
#
|
||||
# You can also specify a hash for <tt>options[:update]</tt> to allow for
|
||||
# easy redirection of output to an other DOM element if a server-side
|
||||
@@ -129,8 +136,8 @@ module ActionView
|
||||
# default this is the current form, but
|
||||
# it could just as well be the ID of a
|
||||
# table row or any other DOM element.
|
||||
def link_to_remote(name, options = {}, html_options = {})
|
||||
link_to_function(name, remote_function(options), html_options)
|
||||
def link_to_remote(name, options = {}, html_options = nil)
|
||||
link_to_function(name, remote_function(options), html_options || options.delete(:html))
|
||||
end
|
||||
|
||||
# Periodically calls the specified url (<tt>options[:url]</tt>) every
|
||||
|
||||
@@ -88,6 +88,11 @@ class PrototypeHelperTest < Test::Unit::TestCase
|
||||
link_to_remote("Remote outauthor", :failure => "alert(request.reponseText)", :url => { :action => "whatnot", :a => '10', :b => '20' })
|
||||
end
|
||||
|
||||
def test_link_to_remote_html_options
|
||||
assert_dom_equal %(<a class=\"fine\" href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outauthor</a>),
|
||||
link_to_remote("Remote outauthor", { :url => { :action => "whatnot" }, :html => { :class => "fine" } })
|
||||
end
|
||||
|
||||
def test_periodically_call_remote
|
||||
assert_dom_equal %(<script type="text/javascript">\n//<![CDATA[\nnew PeriodicalExecuter(function() {new Ajax.Updater('schremser_bier', 'http://www.example.com/mehr_bier', {asynchronous:true, evalScripts:true})}, 10)\n//]]>\n</script>),
|
||||
periodically_call_remote(:update => "schremser_bier", :url => { :action => "mehr_bier" })
|
||||
|
||||
Reference in New Issue
Block a user