Class: ObjectView::Combobox

Inherits:
Element
  • Object
show all
Defined in:
lib/object_view/input.rb

Instance Attribute Summary

Attributes inherited from Element

#acceptable_children, #children, #single_line, #tag

Instance Method Summary collapse

Methods inherited from Element

#<<, #add, #add_with_tag, #attr, #attributes, #css_class=, #find_element_with_tag, #id=, #is_acceptable_child?, #on_click=, #render, #render_attributes, #render_children, #style, #style=

Constructor Details

#initializeCombobox

Returns a new instance of Combobox.



132
133
134
135
# File 'lib/object_view/input.rb', line 132

def initialize
  super
  @tag = 'select'
end

Instance Method Details

#nameObject



146
147
148
# File 'lib/object_view/input.rb', line 146

def name
  self.attributes['name']
end

#name=(text) ⇒ Object



142
143
144
# File 'lib/object_view/input.rb', line 142

def name= text
  self.attr('name', text)
end

#option(name, value) ⇒ Object



137
138
139
140
# File 'lib/object_view/input.rb', line 137

def option(name, value)
  option = self.add Option.new(name, value)
  return option
end

#select(select_option) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
# File 'lib/object_view/input.rb', line 150

def select(select_option)
  self.children.each do |option|
    if (selection_option == option)
      option.attr('selected', 'selected')
    else
      if (option.attributes['selected'] != nil)
        option.attributes.delete('selected')
      end
    end
  end
end