diff options
author | Bob Remeika <bob.remeika@gmail.com> | 2009-11-04 02:14:30 -0800 |
---|---|---|
committer | Stefan Penner <stefan.penner@gmail.com> | 2010-01-27 12:44:29 -0600 |
commit | d9765c3af5acbd8b709482dfbea3e8fffdc36556 (patch) | |
tree | 8fcf57be6ef81e526efacdbf34f8fd330a47ca7f /actionpack/lib/action_view | |
parent | 4536191d557b03c8155ba8793411d76958a810a2 (diff) | |
download | rails-d9765c3af5acbd8b709482dfbea3e8fffdc36556.tar.gz rails-d9765c3af5acbd8b709482dfbea3e8fffdc36556.tar.bz2 rails-d9765c3af5acbd8b709482dfbea3e8fffdc36556.zip |
Changed data-name to data-observed on observe_field
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/ajax_helper.rb | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/actionpack/lib/action_view/helpers/ajax_helper.rb b/actionpack/lib/action_view/helpers/ajax_helper.rb index 93a79766dc..807c943d2c 100644 --- a/actionpack/lib/action_view/helpers/ajax_helper.rb +++ b/actionpack/lib/action_view/helpers/ajax_helper.rb @@ -55,20 +55,12 @@ module ActionView end def observe_field(name, options = {}) - attributes = extract_remote_attributes!(options) - callback = options.delete(:function) - frequency = options.delete(:frequency) + options[:observed] = name - attributes["data-name"] = name + attributes = extract_remote_attributes!(options) + attributes.merge!(extract_observer_attributes!(options)) attributes["data-js-type"] = "field_observer" - if callback - attributes["data-observer-code"] = create_js_function(callback, "element", "value") - end - if frequency && frequency != 0 - attributes["data-frequency"] = frequency.to_i - end - script_decorator(attributes) end @@ -146,6 +138,22 @@ module ActionView purge_unused_attributes!(attributes) end + def extract_observer_attributes!(options) + attributes = {} + attributes["data-observed"] = options.delete(:observed) + + callback = options.delete(:function) + frequency = options.delete(:frequency) + if callback + attributes["data-observer-code"] = create_js_function(callback, "element", "value") + end + if frequency && frequency != 0 + attributes["data-frequency"] = frequency.to_i + end + + attributes + end + def purge_unused_attributes!(attributes) attributes.delete_if {|key, value| value.nil? } attributes |