Feed Sign in with OpenID OpenID

Simon Willison’s Weblog

Dojo 1.3 now available. Looks like an excellent release. dojo.create is particularly nice—I’d be interested to know why something similar has never shipped with jQuery (presumably there’s a reason) as it feels a lot more elegant than gluing together an HTML-style string. Also interesting: you can swap between Dojo’s Acme selector engine and John Resig’s sizzle.

Tagged , , , , , , ,

5 comments

  1. Hey Simon you can create dom elements in that manner in jQuery like so:

    $('<div>').addClass('loading').append($('<a>').att r('href','#'));

    Clint Ecker - 1st April 2009 00:50 - #

  2. Oops, missed the "with attributes" bit—was that what you were referring to?

    Clint Ecker - 1st April 2009 00:51 - #

  3. I find the angle bracket notation pretty unintuitive. It looks like there's innerHTML manipulation going on. In fact, jQuery uses a regex to detect single elements and converts it to a createElement call under the hood, but you have to dig pretty far in to the code to spot that. Probably just a colour-of-the-bike-shed issue.

    Simon Willison - 1st April 2009 12:18 - #

  4. I've always used Michael Geary's Easy DOM Creation plugin.

    http://mg.to/2006/02/27/easy-dom-creation-for-jque ry-and-prototype

    The cool part for me is the nesting, and the ability to assign a variable to any element in the tree you're creating for use later.

    Paul McLanahan - 1st April 2009 15:40 - #

  5. I agree with Paul. Creating nested DOM elements is much easier the jQuery way and I think it is more intuitive than having .create() function IMO.

    jQuery Tutorials - 23rd April 2009 13:23 - #

Comments are closed.
A django site