Class: Scarpe::WASMCheck

Inherits:
WASMWidget
  • Object
show all
Defined in:
lib/scarpe/wasm/check.rb

Instance Attribute Summary collapse

Attributes inherited from WASMWidget

#children, #parent, #shoes_linkable_id

Instance Method Summary collapse

Methods inherited from WASMWidget

#bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #set_parent, #to_html

Constructor Details

#initialize(properties) ⇒ WASMCheck

Returns a new instance of WASMCheck.



7
8
9
10
11
12
13
# File 'lib/scarpe/wasm/check.rb', line 7

def initialize(properties)
  super

  bind("click") do
    send_self_event(event_name: "click", target: shoes_linkable_id)
  end
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/scarpe/wasm/check.rb', line 5

def text
  @text
end

Instance Method Details

#elementObject



23
24
25
26
27
# File 'lib/scarpe/wasm/check.rb', line 23

def element
  HTML.render do |h|
    h.input(type: :checkbox, id: html_id, onclick: handler_js_code("click"), value: "hmm #{text}", checked: @checked)
  end
end

#properties_changed(changes) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/scarpe/wasm/check.rb', line 15

def properties_changed(changes)
  checked = changes.delete("checked")

  html_element.toggle_input_button(checked)

  super
end