registers ticking, but objects not showing
This commit is contained in:
@ -7,18 +7,31 @@ class ListView < ElementView
|
||||
@elements = []
|
||||
end
|
||||
|
||||
# can be overriden to return a string that will be passed to div to create the root
|
||||
# element for the list. See "div" in ElementView for possible strings
|
||||
def root
|
||||
"div"
|
||||
end
|
||||
|
||||
def draw on
|
||||
# create a root node acording to the "root" function (default div)
|
||||
# draw all chilren and keep the elements as @elements
|
||||
# return (as per base class) the single root of the collection
|
||||
def draw
|
||||
@element = div(self.root)
|
||||
@elements = @children.collect do | c |
|
||||
elem = c.draw(@element)
|
||||
elem.append_to(@element)
|
||||
elem
|
||||
add_element c.draw
|
||||
end
|
||||
@element
|
||||
end
|
||||
|
||||
# replace the child at index with the given one (second arg)
|
||||
# The child must be an ElementView , which will be rendered and
|
||||
# the old node will be replaces in the live dom
|
||||
def replace_at index , with
|
||||
old = @elements[index]
|
||||
@chilren[index] = with
|
||||
rendered = with.draw
|
||||
@elements[index] = rendered
|
||||
old.replace_with rendered
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user