From 23275d1b793c21ea9481383402a881c177e8111c Mon Sep 17 00:00:00 2001 From: Bob Remeika Date: Wed, 23 Sep 2009 00:18:10 -0700 Subject: Added the beginnings of the observe_field helper --- actionpack/lib/action_view/helpers/ajax_helper.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'actionpack/lib/action_view/helpers') 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 + '"'} - "" + 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| -- cgit v1.2.3