diff --git a/lib/base/element_view.rb b/lib/base/element_view.rb index dfe3629..c6999cd 100644 --- a/lib/base/element_view.rb +++ b/lib/base/element_view.rb @@ -8,10 +8,11 @@ class ElementView raise "implement me to return an Element" end - def create_element name_class + def div name_class , text = nil name , clazz = name_class.split(".") name = "div" if name.empty? element = $document.create_element(name) + element.text = text if text return element unless clazz if( clazz.is_a? Array ) clazz.each { |c| add_class_or_id( element , cl )} @@ -36,4 +37,13 @@ class ElementView node.append_to wrapper end + def create_element class_or_id , text = nil + @element = div( class_or_id , text) + end + + def add class_or_id , tex = nil + element = div( class_or_id , tex) + element.append_to @element + element + end end diff --git a/lib/base/list_view.rb b/lib/base/list_view.rb index f7b10f7..6baedd9 100644 --- a/lib/base/list_view.rb +++ b/lib/base/list_view.rb @@ -13,7 +13,7 @@ class ListView < ElementView end def draw on - @container_element = create_element(self.root) + @container_element = div(self.root) @elements = @children.collect do | c | elem = c.draw(@container_element) elem.append_to(@container_element)