Forum: Rails Spinoffs (closed, excessive spam) new Element vs Builder.node

Posted by AlannY (Guest)
on 2008-06-13 14:58
(Received via mailing list)
Why there are Builder.node from scriptaculous if threre are exists new
Element?

Which one should I use to create a DOM elements and then append it to
some other element?
Posted by Frederick Polgardy (Guest)
on 2008-06-13 15:37
(Received via mailing list)
Builder.node() boils down to DOM operations, but it's a handy DSL for 
doing
nested element creation without creating all the intermediate objects 
and
gluing them together:

  document.observe('dom:loaded', function() {
    $('stuff').update(
      Builder.node('table', {id: 'mytable'}, [
        Builder.node('tr', [
          Builder.node('td', 'cell 1'),
          Builder.node('td', 'cell 2'),
          Builder.node('td', 'cell 3')
        ])
      ])
    );
  });

Or if you do Builder.dump() first:

  Builder.dump();
  document.observe('dom:loaded', function() {
    $('stuff').update(
      TABLE({id: 'mytable'}, [
        TR([
          TD('cell 1'),
          TD('cell 2'),
          TD('cell 3')
        ])
      ])
    );
  });

You're free to use whatever method you like best. :-)

-Fred

On Fri, Jun 13, 2008 at 7:57 AM, AlannY <m@alanny.ru> wrote:

>
> Why there are Builder.node from scriptaculous if threre are exists new
> Element?
>
> Which one should I use to create a DOM elements and then append it to
> some other element?


--
Science answers questions; philosophy questions answers.
Posted by AlannY (Guest)
on 2008-06-13 16:20
(Received via mailing list)
tnx
Posted by Richard Quadling (Guest)
on 2008-06-13 16:27
(Received via mailing list)
2008/6/13 AlannY <m@alanny.ru>:

>
> tnx
> >
>
Don't forget the template class. If you are building the same HTML 
structure
again and again, then a template works really well.



--
-----
Richard Quadling
Zend Certified Engineer : 
http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
Posted by Frederick Polgardy (Guest)
on 2008-06-13 16:43
(Received via mailing list)
Yes, and will be faster in many cases, due to the fact that it generates
HTML markup, and takes advantage of the blazing fast performance of 
setting
.innerHTML.

-Fred

On Fri, Jun 13, 2008 at 9:27 AM, Richard Quadling 
<rquadling@googlemail.com>
wrote:

> Don't forget the template class. If you are building the same HTML
> structure again and again, then a template works really well.
>

--
Science answers questions; philosophy questions answers.
This topic is locked and can not be replied to.