Module: Vapir::CheckBox

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 check box, or clears (defaults to setting if no argument is given) Raises ObjectDisabledException exception if element is disabled.

takes options:

  • :highlight => true/false (defaults to true)

  • :wait => true/false (defaults to false)



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/vapir-common/elements/elements.rb', line 476

def set(state=true, options={})
  options=handle_options(options, :highlight => true, :wait => true)
  with_highlight(options) do
    assert_enabled
    if checked!=state
      if browser_class.name != 'Vapir::Firefox'  # compare by name to not trigger autoload or raise NameError if not loaded 
        # in firefox, firing the onclick event changes the state. in IE, it doesn't, so do that first 
        # todo/fix: this is browser-specific stuff, shouldn't it be in the browser-specific class? 
        element_object.checked=state
      end
      handling_existence_failure { fire_event(:onclick, options) } # sometimes previous actions can cause self to stop existing 
      handling_existence_failure { fire_event(:onchange, options) }
    end
    wait if options[:wait]
  end
  return self
end