Created
October 18, 2010 10:06
-
-
Save champierre/631996 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionView | |
module Helpers | |
module FormTagHelper | |
def image_submit_tag(source, options = {}) | |
options.stringify_keys! | |
if confirm = options.delete("confirm") | |
options["onclick"] ||= '' | |
options["onclick"] += "return #{confirm_javascript_function(confirm)};" | |
end | |
if disable = options.delete("disable") | |
onclick = "#{options.delete('onclick')}" if options['onclick'] | |
options["onclick"] = "this.setAttribute('originalValue', this.value);this.disabled = true;#{onclick};" | |
options["onclick"] << "result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());" | |
options["onclick"] << "if (result == false) { this.disabled = false; }return result;" | |
end | |
tag :input, { "type" => "image", "src" => path_to_image(source) }.update(options.stringify_keys) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment