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



274
275
276
# File 'lib/vapir-common/elements/elements.rb', line 274

def select
  self.selected=true
end

#selected=(state) ⇒ Object



267
268
269
# File 'lib/vapir-common/elements/elements.rb', line 267

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.



255
256
257
258
259
260
261
262
263
264
265
# File 'lib/vapir-common/elements/elements.rb', line 255

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