Permalink
Browse files

Added the beginnings of the observe_field helper

  • Loading branch information...
1 parent b599c4c commit 23275d1b793c21ea9481383402a881c177e8111c @foobarfighter foobarfighter committed with stefanpenner Sep 23, 2009
Showing with 8 additions and 11 deletions.
  1. +8 −11 actionpack/lib/action_view/helpers/ajax_helper.rb
@@ -74,21 +74,18 @@ def observe_field(name, options = {})
script_decorator(attributes)
end
- def observe_form(name, options = {})
- options[:observed] = name
- attributes = extract_observer_attributes!(options)
- attributes["data-js-type"] = "form_observer"
+ def observe_field(name, options = {}, html_options = {})
+ url = options.delete(:url)
+ url = url_for(url) if url.is_a?(Hash)
- script_decorator(attributes)
- end
+ if frequency = options.delete(:frequency)
+ html_options[:"data-frequency"] = frequency
+ end
- def script_decorator(options)
- attributes = %w(type="application/json")
- attributes += options.map{|k, v| k + '="' + v.to_s + '"'}
- "<script " + attributes.join(" ") + "></script>"
+ html_options.merge!(:"data-observe" => true, :"data-url" => url)
+ tag(:input, html_options)
end
- # TODO: All evaled goes here per wycats
module Rails2Compatibility
def set_callbacks(options, html)
[:complete, :failure, :success, :interactive, :loaded, :loading].each do |type|

0 comments on commit 23275d1

Please sign in to comment.