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=)



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

def select
  self.selected=true
end

#selected=(state) ⇒ Object



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

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). if this Option is aware of its select list (this will generally be the case if you got this Option from a SelectList container), will fire the onchange event on the select list if our state changes.



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

def set_selected(state, method_options={})
  method_options={:highlight => true, :wait => true}.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 @extra[:select_list] && state_was != state
      @extra[:select_list].fire_event(:onchange, method_options)
    end
    wait if method_options[:wait]
  end
end