Module: Vapir::Option

Extended by:
ElementHelper
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

Instance Method Details

#selectObject

selects this option, firing the onchange event on the containing select list if we are aware of it (see #selected=)



327
328
329
# File 'lib/vapir-common/elements/elements.rb', line 327

def select
  self.selected=true
end

#selected=(state) ⇒ Object



320
321
322
# File 'lib/vapir-common/elements/elements.rb', line 320

def selected=(state)
  set_selected(state)
end

#set_selected(state, method_options = {}) ⇒ Object

sets this Option’s selected state to the given (true or false). will fire the onchange event on the select list if our state changes.



308
309
310
311
312
313
314
315
316
317
318
# File 'lib/vapir-common/elements/elements.rb', line 308

def set_selected(state, method_options={})
  method_options={:highlight => true, :wait => config.wait}.merge(method_options)
  with_highlight(method_options) do
    state_was=element_object.selected
    element_object.selected=state # TODO: if state is false and this isn't an option of a multiple select list, should this error? 
    if state_was != state
      (@extra[:select_list] || parent_select_list).fire_event(:onchange, method_options)
    end
    wait if method_options[:wait]
  end
end