If you scroll on down to a comment by Olsow, you’ll find what I think is a better way to do DOM creation:

http://mg.to/2006/02/27/easy-dom-creation-for-jquery-and-prototype#comment-176

 

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Linan Wang
Sent: Thursday, October 26, 2006 11:57 AM
To: jQuery Discussion.
Subject: Re: [jQuery] Has anybody done this?

 

Thanks to  Klaus and Dave.
It's improved and more interesting, at least I feel :)
http://204.13.69.149/~wang/
Pleae leave your comments and see if it can be better.

On 10/26/06, Dave Methvin <[EMAIL PROTECTED]> wrote:

> Here is my little plugin to create dom element:
>
> http://204.13.69.149/~wang/
>
> My questions are:
> 1, Has anybody done this before?
> 2, As it's my first crack on jQuery, anything wrong with the api call?
> 3, Is there any more elegant solutions?

As Klaus said, the name is a bit off but I do think this approach has some
promise. Right now I am using Mike Geary's DOM creation functions.
http://mg.to/2006/02/27/easy-dom-creation-for-jquery-and-prototype
I like them because (unlike string building and innerHTML) there are no
gotchas with the contents of the strings you put into the DOM functions.
However, the $.DIV syntax is not pretty. More important, doing things in the
"natural" way involves attaching event handlers before the element is added
to the document tree, which causes a small memory leak in IE6.

Since dom() changes the selected nodes, jQuery convention says it should use
pushStack to save the previous set of nodes. Building a DOM tree often
several levels, though, so a pushStack on every element could result in a
lot of pushed state that you don't care about.

Let's say I want to create a list like "<ul><li>one</li><li>two</li></ul>".
How would I do that with tag()? I can only pass in one tag, and it's always
appended as a child.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/




--
Best regards

Linan Wang

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to