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:28 -0600 |
commit | a792ee5665fff4bd3751e97e1d949b60e73e333d (patch) | |
tree | 3d5e7f474546660f8697bf5251dc574606dda59f /actionpack/lib/action_view | |
parent | f3caa63bcbbfff093efcdfa3547fb2eb96479f0a (diff) | |
download | rails-a792ee5665fff4bd3751e97e1d949b60e73e333d.tar.gz rails-a792ee5665fff4bd3751e97e1d949b60e73e333d.tar.bz2 rails-a792ee5665fff4bd3751e97e1d949b60e73e333d.zip |
Added the beginnings of the observe_field helper
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/ajax_helper.rb | 14 |
1 files changed, 13 insertions, 1 deletions
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| |