diff options
author | Erik St. Martin <alakriti@gmail.com> | 2010-01-30 19:44:35 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-01-30 19:44:35 -0600 |
commit | 392817cf11e2e840eb564dd4f8713092cff167f8 (patch) | |
tree | 242a19782af6c4e67fd50f324c5781ecde93d4a4 /actionpack/lib/action_view/helpers/form_tag_helper.rb | |
parent | 7d9ed8eec1c899dac10d582ced07149fe5c58c4f (diff) | |
download | rails-392817cf11e2e840eb564dd4f8713092cff167f8.tar.gz rails-392817cf11e2e840eb564dd4f8713092cff167f8.tar.bz2 rails-392817cf11e2e840eb564dd4f8713092cff167f8.zip |
updating link_to and button_to to support :remote => true and other options such as :confirm in a unobtrusive manor
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_tag_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/form_tag_helper.rb | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 048bedc7ba..0e034d781a 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -57,7 +57,7 @@ module ActionView # ==== Examples # select_tag "people", options_from_collection_for_select(@people, "name", "id") # # <select id="people" name="people"><option value="1">David</option></select> - # + # # select_tag "people", "<option>David</option>" # # => <select id="people" name="people"><option>David</option></select> # @@ -128,7 +128,7 @@ module ActionView # Creates a label field # - # ==== Options + # ==== Options # * Creates standard HTML attributes for the tag. # # ==== Examples @@ -367,7 +367,7 @@ module ActionView if disable_with = options.delete("disable_with") disable_with = "this.value='#{disable_with}'" disable_with << ";#{options.delete('onclick')}" if options['onclick'] - + options["onclick"] = "if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }" options["onclick"] << "else { hiddenCommit = document.createElement('input');hiddenCommit.type = 'hidden';" options["onclick"] << "hiddenCommit.value = this.value;hiddenCommit.name = this.name;this.form.appendChild(hiddenCommit); }" @@ -377,8 +377,7 @@ module ActionView end if confirm = options.delete("confirm") - options["onclick"] ||= 'return true;' - options["onclick"] = "if (!#{confirm_javascript_function(confirm)}) return false; #{options['onclick']}" + add_confirm_to_attributes!(options, confirm) end tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys) @@ -411,8 +410,7 @@ module ActionView options.stringify_keys! if confirm = options.delete("confirm") - options["onclick"] ||= '' - options["onclick"] += "return #{confirm_javascript_function(confirm)};" + add_confirm_to_attributes!(options, confirm) end tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options.stringify_keys) |