Class: ActionView::Helpers::Tags::CheckBox

Inherits:
Base
  • Object
show all
Includes:
JavaScriptHelper
Defined in:
lib/prime/rails/tags/check_box.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from JavaScriptHelper

#p_javascript_tag

Instance Method Details

#p_renderObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/prime/rails/tags/check_box.rb', line 6

def p_render
  options = @options.stringify_keys
  options["type"]     = "checkbox"
  options["value"]    = @checked_value
  options["checked"] = "checked" if input_checked?(object, options)

  if options["multiple"]
    add_default_name_and_id_for_value(@checked_value, options)
    options.delete("multiple")
  else
    add_default_name_and_id(options)
  end

  include_hidden = options.delete("include_hidden") { true }
  checkbox = tag("input", options)

  if include_hidden
    hidden = hidden_field_for_checkbox(options)
    output = hidden + checkbox
  else
    output = checkbox
  end
  
clientid = sanitize_to_id(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('CheckBox','#{widgetvar}',#{options_ui})"
script += '});'         
output += p_javascript_tag(script, "id" => clientid+"_s")           
  
end