提交 23275d1b 编写于 作者: B Bob Remeika 提交者: Stefan Penner

Added the beginnings of the observe_field helper

上级 b599c4c7
......@@ -74,21 +74,18 @@ def observe_field(name, options = {})
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|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册