Class: Nitro::HasManyControl

Inherits:
RelationControl show all
Defined in:
lib/nitro/control/relation/has_many.rb

Overview

HasMany, ManyToMany and JoinsMany

Instance Attribute Summary

Attributes inherited from AttributeControl

#anno, #attribute, #value

Attributes included from ElementMixin

#_children, #_parent, #_text, #_view, #id

Instance Method Summary collapse

Methods inherited from RelationControl

#initialize, #rel, #symbol

Methods inherited from AttributeControl

#initialize

Methods included from XhtmlHelper

#date_select, #datetime_select, #hidden, #href_of, #js_popup, #link_to, #objects_to_options, #onclick_popup, #options, #popup, #submit, #time_select

Methods inherited from Element

compile_template_elements

Methods included from ElementMixin

#add_child, #close, #content, #initialize, #open, #render_children

Constructor Details

This class inherits a constructor from Nitro::RelationControl

Instance Method Details

#renderObject

pre :do_this, :on => :populate_object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/nitro/control/relation/has_many.rb', line 11

def render
  str = "#{emit_label}"
  str << emit_container_start
  str << emit_js
  if selected_items.empty?
    str << emit_selector(:removable => false)
  else
    removable = selected_items.size != 1 ? true : false
    selected_items.each do |item|
      str << emit_selector(:selected => item.pk)
    end
  end
  str << emit_container_end
end