From a792ee5665fff4bd3751e97e1d949b60e73e333d 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 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (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 9cc2acc239..1246ec7107 100644 --- a/actionpack/lib/action_view/helpers/ajax_helper.rb +++ b/actionpack/lib/action_view/helpers/ajax_helper.rb @@ -33,7 +33,19 @@ module ActionView tag(:input, html_options) end - + + def observe_field(name, options = {}, html_options = {}) + url = options.delete(:url) + url = url_for(url) if url.is_a?(Hash) + + if frequency = options.delete(:frequency) + html_options[:"data-frequency"] = frequency + end + + html_options.merge!(:"data-observe" => true, :"data-url" => url) + tag(:input, html_options) + end + module Rails2Compatibility def set_callbacks(options, html) [:complete, :failure, :success, :interactive, :loaded, :loading].each do |type| -- cgit v1.2.3