Class: YDIM::Html::View::AjaxValues

Inherits:
HtmlGrid::Component show all
Defined in:
lib/ydim/html/view/ajax_values.rb

Constant Summary collapse

HTTP_HEADERS =
{
	'Content-Type'	=>	'text/javascript; charset=UTF-8',
}

Instance Method Summary collapse

Methods inherited from HtmlGrid::Component

#escape, escaped, #format, links, #number_format, #precision

Instance Method Details

#to_html(context) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/ydim/html/view/ajax_values.rb', line 15

def to_html(context)
   if @model.is_a?(Array)
     "var ajaxResponse = {\n" << @model.collect { |key, val|
       "'#{escape(key)}': '#{escape(val)}'"
     }.join(",\n") << "\n};"
   else
     "var ajaxResponse = {\n'" << escape(@model.to_s) + "'\n};"
   end
end