22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/prime/rails/tags/select.rb', line 22
def p_select_content_tag(option_tags, options, html_options)
html_options = html_options.stringify_keys
add_default_name_and_id(html_options)
options[:include_blank] ||= true unless options[:prompt] || select_not_required?(html_options)
select = content_tag("select", add_options(option_tags, options, value(object)), html_options)
if html_options["multiple"] && options.fetch(:include_hidden, true)
output = tag("input", :disabled => html_options["disabled"], :name => html_options["name"], :type => "hidden", :value => "") + select
else
output = select
end
clientid = sanitize_to_id(html_options["id"])
widgetvar = options.has_key?("widgetVar") ? options["widgetVar"] : "widget_"+clientid
options_ui = options
options_ui = options_ui.merge(:id => clientid )
options_ui = options_ui.to_json
script = '$(function() {'
script += "PrimeFaces.cw('Dropdown','#{widgetvar}',#{options_ui})"
script += '});'
output += p_javascript_tag(script, "id" => clientid+"_s")
end
|