diff options
author | Bob Remeika <bob.remeika@gmail.com> | 2009-09-23 00:18:10 -0700 |
---|---|---|
committer | Stefan Penner <stefan.penner@gmail.com> | 2010-01-27 12:44:29 -0600 |
commit | 23275d1b793c21ea9481383402a881c177e8111c (patch) | |
tree | 73d4058b7b3d282b50c248294fb299a01800aba6 /actionpack/lib/action_view/helpers/ajax_helper.rb | |
parent | b599c4c7ee9af9943a983fd1ca4e061975dd5629 (diff) | |
download | rails-23275d1b793c21ea9481383402a881c177e8111c.tar.gz rails-23275d1b793c21ea9481383402a881c177e8111c.tar.bz2 rails-23275d1b793c21ea9481383402a881c177e8111c.zip |
Added the beginnings of the observe_field helper
Diffstat (limited to 'actionpack/lib/action_view/helpers/ajax_helper.rb')
-rw-r--r-- | actionpack/lib/action_view/helpers/ajax_helper.rb | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/actionpack/lib/action_view/helpers/ajax_helper.rb b/actionpack/lib/action_view/helpers/ajax_helper.rb index 5de33868e9..5cb8e96ae6 100644 --- a/actionpack/lib/action_view/helpers/ajax_helper.rb +++ b/actionpack/lib/action_view/helpers/ajax_helper.rb @@ -74,21 +74,18 @@ module ActionView 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| |