Class: Wee::Brush::CheckboxTag

Inherits:
InputTag show all
Defined in:
lib/wee/html_brushes.rb

Constant Summary collapse

HTML_TYPE =
'checkbox'.freeze

Constants inherited from InputTag

InputTag::HTML_TAG

Instance Attribute Summary

Attributes inherited from Wee::Brush

#canvas, #document

Instance Method Summary collapse

Methods included from CallbackMixin

#call, #callback, #callback_method

Methods inherited from GenericSingleTagBrush

nesting?

Methods inherited from GenericTagBrush

#get_oid, html_attr, #oid, #onclick_callback, #onclick_javascript, #onclick_update_callback, #onclick_update_self_callback, #ondblclick_callback

Methods inherited from Wee::Brush

#close, nesting?, #setup

Constructor Details

#initializeCheckboxTag

Returns a new instance of CheckboxTag.



408
409
410
# File 'lib/wee/html_brushes.rb', line 408

def initialize
  super(HTML_TYPE)
end

Instance Method Details

#__callbackObject

do nothing



412
# File 'lib/wee/html_brushes.rb', line 412

def __callback; end

#withObject



414
415
416
417
418
419
420
421
422
423
424
# File 'lib/wee/html_brushes.rb', line 414

def with
  if @callback
    n = @canvas.register_callback(:input, proc {|input|
      @callback.call(input.send(input.kind_of?(Array) ? :include? : :==, '1'))
    })
    @document.single_tag('input', :type => 'hidden', :name => n, :value => '0')
    name(n)
    value('1')
  end
  super
end