Activate your free membership today | Log-in

Wednesday, May 16th, 2007

IBDOM: “Wielding the Document Object Model with Ease and Standards-Compliance”

Category: JavaScript, JSON, Library

<p>Chris Holland has released IBDOM, a library that aims to make working with the DOM lots of fun ;)

The core of the library is about injecting HTML.

Example

HTML:
  1.  
  2. <div id="myCarInfo">
  3.                 <h1 title="data:lastUpdated">
  4.                         <span>data:make</span>
  5.                         <span>data:model</span>
  6.                         <span>data:year</span>
  7.                 </h1>
  8. </div>
  9.  

Given the HTML and the following JSON:

JAVASCRIPT:
  1.  
  2. var carInfoObject = {
  3.         make: "BMW",
  4.         model: "325i",
  5.         year: "2002",
  6.         lastUpdated: new Date(481516234200)
  7. }
  8.  

you can populate the DOM via:

JAVASCRIPT:
  1.  
  2. $e("myCarInfo").populate(carInfoObject);
  3.  

There are some interesting features such as:

  • DWR support gives you a nice abstraction and separation
  • conditional class setting based on object property's value:
    HTML:
    1.  
    2.                <td class="setclass:TEST_YEAR{if}((this.year==2002))
    3. SOME_OTHER_CLASS">data:year</td>
    4.  
  • Two repeating-template mechanisms when dealing with arrays of
    objects:

    1. HTML:
      1.  
      2. <tbody id="someCollection" class="use_template:repeat|
      3. vehicle_row use_template:empty_collection|nothingWasFound">
      4. </tbody>
      5.  

      where the class attribute refers to templates defined in a div
      class="templates"

    2. <tbody id="someCollection>... Templates can be inserted here instead of stashed-away ...

Related Content:

  • Document Object Model (DOM)
    Document Object Model (DOM), a programming interface specification being developed by the World Wide Web Consortium (W3C), lets a programmer create...
  • DOM
    Document Object Model (DOM), a programming interface specification being developed by the World Wide Web Consortium (W3C), lets a programmer create...
  • How do I print a form in VB.NET?
  • Mapping tool aims to ease data access issues
    Software firm Vanatec has launched an object-relational mapping tool that is compatible with Microsoft Visual Studio 2005 and SQL Server...
  • Introducing Axiom
    An XML Object model should be memory efficient and fast in processing XML. These two goals are very difficult to satisfy with the technologies that...

Posted by Dion Almaer at 7:25 am
7 Comments

+++++
5 rating from 3 votes

7 Comments »

Comments feed TrackBack URI

Looks cool! I can already think of 1000 uses for this. Thanks!

Comment by Joe Rosenblum — May 16, 2007

Cool. Testing

Comment by Zac Heismann — May 16, 2007

This is essential if you’re working with structured data and html. Good stuff!

Comment by exliontamer — May 17, 2007

The syntax is rather difficult to understand, compared to adobe spry or MindFrame (similar project I found in Ajaxian)

Comment by Robert — May 21, 2007

Robert: Spry and Mindframe do indeed look good, and larger in scope. IBDOM’s smaller scope and size (i’ve not yet released a minified version of it, that’s coming soon) should make it a nice complement to many existing frameworks.

Yesterday we put out an “interactive demo” that lets users edit JS objects in input fields, then click a button to inject the data in an HTML table. There’s also some updated documentation. I’m hoping this will make the basic syntax more digestible. The “ibdom_tests” page is likely a bit overwhelming to newcomers as it really tests just about everything IBDOM can do.

Exliontamer: Thanks :) Do let us know if you use it.

Comment by chris holland — May 23, 2007

It is very interesting to see how fast it can handle large data, since DOM is considered to be slow.

Comment by Rizqi Ahmad — May 28, 2007

Rizqi: If you’ve got load-test examples using IBDOM, feel free to publish them somewhere so i could link to it. I’ve yet to play with MindFrame.

I found a number of performance issues in IBDOM release 0.1 which i’ve addressed in a soon-to-be-released 0.2, with a detailed explanation in the changelog. It will be the first IBDOM version we’ll be using in production for our used cars search application ( http://www.carsdirect.com/used_cars/search ), which will replace the current usage of an older library i had written in a hurry.

Comment by chris holland — May 31, 2007

Leave a comment

You must be logged in to post a comment.