diff options
Diffstat (limited to 'actionpack/lib/action_view/helpers/ajax_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/ajax_helper.rb | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/actionpack/lib/action_view/helpers/ajax_helper.rb b/actionpack/lib/action_view/helpers/ajax_helper.rb index 550f7fbbe2..ab4f5d53e9 100644 --- a/actionpack/lib/action_view/helpers/ajax_helper.rb +++ b/actionpack/lib/action_view/helpers/ajax_helper.rb @@ -154,34 +154,37 @@ module ActionView def create_js_function(statements, *arguments) "function(#{arguments.join(", ")}) {#{statements}}" end + end - # TODO: All evaled goes here per wycat - module Rails2Compatibility - def set_callbacks(options, html) - [:complete, :failure, :success, :interactive, :loaded, :loading].each do |type| - html["data-#{type}-code"] = options.delete(type.to_sym) - end + # TODO: All evaled goes here per wycat + module AjaxHelperCompat + include AjaxHelper - options.each do |option, value| - if option.is_a?(Integer) - html["data-#{option}-code"] = options.delete(option) - end - end + def set_callbacks(options, html) + [:complete, :failure, :success, :interactive, :loaded, :loading].each do |type| + html["data-#{type}-code"] = options.delete(type.to_sym) end - - def link_to_remote(name, url, options = nil) - if !options && url.is_a?(Hash) && url.key?(:url) - url, options = url.delete(:url), url + + options.each do |option, value| + if option.is_a?(Integer) + html["data-#{option}-code"] = options.delete(option) end - set_callbacks(options, options[:html] ||= {}) - - super end - - def button_to_remote(name, options = {}, html_options = {}) - set_callbacks(options, html_options) - super + end + + def link_to_remote(name, url, options = nil) + if !options && url.is_a?(Hash) && url.key?(:url) + url, options = url.delete(:url), url end + set_callbacks(options, options[:html] ||= {}) + + super + end + + def button_to_remote(name, options = {}, html_options = {}) + html_options.merge!(:testing => true) + set_callbacks(options, html_options) + super end end end |