Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added submit_to_remote helper

  • Loading branch information...
commit 7d34975214e80d54786f92cf1daee7ec7847a07c 1 parent 39ec7ce
Bob Remeika foobarfighter authored stefanpenner committed
10 actionpack/lib/action_view/helpers/ajax_helper.rb
View
@@ -48,6 +48,16 @@ def button_to_remote(name, options = {}, html_options = {})
tag(:input, attributes)
end
+ def submit_to_remote(name, value, options = {})
+ html_options = options.delete(:html) || {}
+ html_options.merge!(:name => name, :value => value, :type => "submit")
+
+ attributes = extract_remote_attributes!(options)
+ attributes.merge!(html_options)
+
+ tag(:input, attributes)
+ end
+
def periodically_call_remote(options = {})
attributes = extract_observer_attributes!(options)
attributes["data-js-type"] = "periodical_executer"
12 actionpack/test/javascript/ajax_test.rb
View
@@ -332,7 +332,7 @@ def author_article_path(author, article)
class ButtonToRemoteTest < AjaxTestCase
def button(options, html = {})
- button_to_remote("Remote outpost", options, html)
+ button_to_remote("RemoteOutpost", options, html)
end
def url_for(*)
@@ -355,6 +355,16 @@ class LegacyButtonToRemoteTest < ButtonToRemoteTest
end
end
+class SubmitToRemoteTest < AjaxTestCase
+ test "basic" do
+ expected = %(<input class="fine" type="submit" name="foo" value="bar" data-url="/url/hash" data-js-type="remote" data-update-success=".klass" />)
+ options = { :url => {:action => "whatnot"}, :update => ".klass", :html => { :class => "fine" } }
+
+ assert_dom_equal expected,
+ submit_to_remote("foo", "bar", options)
+ end
+end
+
class ScriptDecoratorTest < AjaxTestCase
def decorator()
script_decorator("data-js-type" => "foo_type", "data-foo" => "bar", "data-baz" => "bang")
Please sign in to comment.
Something went wrong with that request. Please try again.