Module: Vapir::Radio

Extended by:
ElementHelper
Includes:
RadioCheckBoxCommon
Defined in:
lib/vapir-common/elements/elements.rb

Instance Method Summary collapse

Methods included from ElementHelper

add_specifier, container_collection_method, container_single_method, included

Methods included from ElementClassAndModuleMethods

#add_container_method_extra_args, #all_dom_attr_aliases, #all_dom_attrs, #class_array_append, #class_array_get, #class_hash_get, #class_hash_merge, #container_collection_methods, #container_method_extra_args, #container_single_methods, #default_how, #dom_attr, #dom_attr_locate_alias, #dom_function, #dom_setter, #element_collection, #factory, #inspect_these, #inspect_this_if, #parent_element_module, #set_or_get_class_var, #specifiers

Methods included from RadioCheckBoxCommon

#clear

Instance Method Details

#set(state = true, options = {}) ⇒ Object

Checks this radio, or clears (defaults to setting if no argument is given) Raises ObjectDisabledException exception if element is disabled.

Fires the onchange event if value changes. Fires the onclick event the state is true.



443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
# File 'lib/vapir-common/elements/elements.rb', line 443

def set(state=true, options={})
  options=handle_options(options, :highlight => true, :wait => true)
  with_highlight(options) do
    assert_enabled
    if checked!=state
      element_object.checked=state
      handling_existence_failure { fire_event(:onchange, options) } # we may stop existing due to change in state 
    end
    if state
      handling_existence_failure { fire_event(:onclick, options) } # fire this even if the state doesn't change; javascript can respond to clicking an already-checked radio. 
    end
    wait if options[:wait]
  end
  return self
end