<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web 3.0, 6 Bladed Razors, 7 Minute Abs &#187; ExtJS</title>
	<atom:link href="http://www.zachleat.com/web/tag/extjs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zachleat.com/web</link>
	<description></description>
	<lastBuildDate>Mon, 06 Feb 2012 17:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Rethinking JavaScript Grids and DataTables</title>
		<link>http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/</link>
		<comments>http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 20:29:26 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[Interface Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Conservative Design]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=122</guid>
		<description><![CDATA[In the world of front end engineering, one must consider the end-user of the interface first, and above all other things. The priorities should not start with development ease, nor external library preference. The priorities should start with the needs of the consumer of your end product. Evolution of your engineering skill is also a [...]]]></description>
			<content:encoded><![CDATA[<p>In the world of front end engineering, one must consider the end-user of the interface first, and above all other things.  The priorities should not start with development ease, nor external library preference.  The priorities should start with the needs of the consumer of your end product.</p>
<p>Evolution of your engineering skill is also a vital trait in this world, which means that as a developer increases his knowledge of good practices and proper methods, sometimes he must shirk his previous assertions about the world as he previously knew it.  And today I&#8217;m shirking a staple of the front end as all web users know it: The Grid (DataTable) Component.</p>
<p>Of course, I&#8217;ve written a few articles in the past about the <a href="http://developer.yahoo.com/yui/datatable/">YUI DataTable</a>, during my long love affair with Yahoo&#8217;s User Interface library.  Another popular one is jQuery&#8217;s <a href="http://tablesorter.com/docs/">TableSorter</a>.  Then there&#8217;s the <a href="http://dojotoolkit.org/book/dojo-book-0-9/docx-documentation-under-development/grid">Dojo Grid</a>, a component <a href="http://www.sitepen.com/blog/2007/09/16/the-dojo-grid/">inherited from TurboAjax</a>.  ExtJS has a variety of nice examples as well for their <a href="http://extjs.com/deploy/dev/examples/#sample-1">Ext 2.0 Grid</a>.</p>
<p>And after using these Grids and DataTables, I certainly respect the programming that went into developing these components.  But let&#8217;s take a step back for a second.  Why do the users need the bells and whistles in these components?  Are they worth the extra load time and complexity they add to the interface?</p>
<p>All we&#8217;re doing here is putting a nice coat of paint on a &lt;table&gt; tag.  Sure, it might have some nice ancillary features like Ajax Data Loading, but those don&#8217;t really matter &#8211; they are things that can be easily performed with some good Ajax and DOM insert utility functions.  In fact, most of the core features included in these components could be described as feature creep, and not beneficial to the end user at all.  Feature creep contributes to code bloat, which means the user is downloading bytes to their web browser that they don&#8217;t need, which can hamper performance.  Libraries usually have online examples of their components, and the include sizes are seen below.  (Gzip compression not considered)</p>
<table>
<thead>
<tr>
<th>Name</th>
<th>JavaScript Size</th>
<th>Minimized</th>
<th>Link</th>
</tr>
</thead>
<tbody>
<tr>
<td>YUI DataTable</td>
<td>216.6 KB</td>
<td>Minimized</td>
<td><a href="http://developer.yahoo.com/yui/examples/datatable/dt_basic_clean.html">Example</a></td>
</tr>
<tr>
<td>Dojo Grid</td>
<td>338.4 KB</td>
<td>Unminimized</td>
<td><a href="http://dojotoolkit.org/book/dojo-book-0-9/docx-documentation-under-development/grid/simple-grid">Example</a></td>
</tr>
<tr>
<td>Ext Grid</td>
<td>545.5 KB</td>
<td>Minimized</td>
<td><a href="http://extjs.com/deploy/dev/examples/grid/array-grid.html">Example</a></td>
</tr>
<tr>
<td>jQuery TableSorter</td>
<td>66 KB</td>
<td>Minimized</td>
<td><a href="http://www.tablesorter.com/">Example</a></td>
</tr>
</tbody>
</table>
<p>The JavaScript include sizes listed above are directly proportional to the feature set that the components provide, and should give you an idea of the overhead involved with using them.  Do we need 545.5 KB of features coming down the pipe to give our users an extra bell, or an extra whistle?  Let&#8217;s analyze the features to rationalize their usage, and remove items from the feature set.</p>
<ul>
<li>Sorting</li>
<li>Modifying column order and display</li>
<li>Resizing columns</li>
<li>Editing of row data directly on the grid itself</li>
<li>Scrolling</li>
<li>Pagination</li>
</ul>
<p><strong>Sorting</strong></p>
<p>Data should be used in the context of its usefulness.  You have a list of messages in your e-mail inbox.  What&#8217;s the most useful context for this list?  In order of date received.  The default sort order provided by the application, to facilitate proper use of the application.  Is comparing the rows in the grid by any other method as useful?  Does the user need to see the list of messages ordered alphabetically by subject?  In these cases where the user is in need of a specific message, <em>searching and filtering</em> is more useful than sorting.  The default sort is useful, but allowing the user to resort on the client, in most cases, is not as useful as other methods of finding a row.</p>
<p><strong>Modifying column order and display</strong></p>
<p>The same argument can be made for any of the other methods of customization provided to the end user.  Does the user need to reorder or hide columns?  The context provided by the application should be sufficient to use the applications data in the way it was intended.  Don&#8217;t overcomplicate your user interface with needless features or a deluge of useless data.  Provide succinct, appropriate data, and the user needn&#8217;t reorder or change the interface.</p>
<p><strong>Resizing columns</strong></p>
<p>The default HTML &lt;table&gt; tag expands to fit the data inside of its cells.  Even when you set the width of the table explicitly, the cells adjust themselves accordingly to fit the data.  This should be the behavior of your table.  You needn&#8217;t monkey around with widths, the browser is smart enough to do it for you.  You can even customize a cell to wrap its text to multiple lines with CSS, if need be.</p>
<p><strong>Editing of row data directly on the grid itself</strong></p>
<p>If you&#8217;re providing an Excel spreadsheet interface for the end user to customize your data, you haven&#8217;t designed your interface correctly.  Rethink how the user needs to interact with the data you&#8217;ve provided, and give them a better, simpler way to edit the data.</p>
<p><strong>Scrolling</strong></p>
<p>Everyone knows that internal scrollbars on a page are evil.  I don&#8217;t even like scrollbars on textareas, to be honest.  Previously, I had worked and reworked the YUI DataTable to handle horizontal scrolling.  Looking back on this, it was a mistake.  There are better ways to handle lots of data in a table, without the heavy mouse interaction and scanning that scrolling require.  Which brings me to my next point.</p>
<p><strong>Pagination</strong></p>
<p>This is the one exception to the feature set cutting board.  This is the one feature that&#8217;s is a requirement, when the data set has too many records to fit on a single page.</p>
<p>Keep these in mind, and look at the feature set provided by a few sites using tabular data centric interfaces that know a thing or two about interface design:</p>

<a href='http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/gmail/' title='Google Mail'><img width="150" height="150" src="http://www.zachleat.com/web/wp-content/uploads/2008/04/gmail-150x150.png" class="attachment-thumbnail" alt="Google Mail" title="Google Mail" /></a>
<a href='http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/wordpress-admin/' title='Wordpress 2.5 Admin Interface'><img width="150" height="150" src="http://www.zachleat.com/web/wp-content/uploads/2008/04/wordpress-admin-150x150.png" class="attachment-thumbnail" alt="Wordpress 2.5 Admin Interface" title="Wordpress 2.5 Admin Interface" /></a>
<a href='http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/google-reader/' title='Google Reader List View'><img width="150" height="150" src="http://www.zachleat.com/web/wp-content/uploads/2008/04/google-reader-150x150.png" class="attachment-thumbnail" alt="Google Reader List View" title="Google Reader List View" /></a>

<p><strong>So, what should we include?</strong></p>
<p>A simple CSS class to style your table is sufficient, with links to paginate the table (properly) and/or a hover for row selection if needed.  You&#8217;re looking at 10-20 lines of jQuery code, maximum, and a few CSS declarations.  In lieu of sorting, of course, you&#8217;ll need to program in a mechanism for searching and filtering as well.  But really, the difficulty with programming this component is knowing what to leave out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/rethinking-javascript-grids-and-datatables/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Write More Efficient Javascript in YUI with CSS Selectors</title>
		<link>http://www.zachleat.com/web/write-more-efficient-javascript-in-yui-with-css-selectors/</link>
		<comments>http://www.zachleat.com/web/write-more-efficient-javascript-in-yui-with-css-selectors/#comments</comments>
		<pubDate>Mon, 03 Sep 2007 22:36:05 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[CSS Selectors]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/09/03/write-more-efficient-javascript-in-yui-with-css-selectors/</guid>
		<description><![CDATA[This is an updated version of a previous article entitled Using DOM Query Libraries in YUI for the new version of YAHOO.util.Dom included with YUI 2.3.0 as well as including support for passing context nodes into Dom functions. Here we are again. I just love those CSS Selectors. If you haven&#8217;t read Part One of [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is an updated version of a previous article entitled <a href="http://www.zachleat.com/web/2007/07/30/using-dom-query-libraries-in-yui/">Using DOM Query Libraries in YUI</a> for the new version of YAHOO.util.Dom included with YUI 2.3.0 as well as including support for passing context nodes into Dom functions.</em></p>
<p>Here we are again.  I just love those CSS Selectors.  If you haven&#8217;t read Part One of the series linked above, I would encourage it to get a little background on why we&#8217;re attempting this approach.</p>
<h1>Download the appropriate files:</h1>
<h1>Get the easy <strong>ALL-IN-ONE file</strong>: <a href="/Lib/Y2/Y2.js">Y2.js</a> (31 KB original source) OR <a href="/Lib/Y2/Y2-p.js">Y2-p.js</a> (11 KB minimized)</h1>
<h2>Get the files separately (if you want to use a custom selector library, or have already included DomQuery or jQuery): <a href="/Lib/Y2/Y2-solo.js">Y2-solo.js</a> (9 KB original source) OR <a href="/Lib/Y2/Y2-solo-p.js">Y2-solo-p.js</a> (4 KB minimized)</h2>
<p>Also, first you&#8217;ll need to get Jack&#8217;s nice DomQuery class.</p>
<p>Download: <a href="/Lib/Y2/DomQuery.js">Jack Slocum&#8217;s DomQuery Standalone File (24 KB)</a> 1.0 Alpha 3 &#8211; Rev 4<br />
Download: <a href="/Lib/Y2/DomQuery-packer.js">Jack Slocum&#8217;s DomQuery Standalone File Packed (7 KB)</a> 1.0 Alpha 3 &#8211; Rev 4</p>
<p>You can use the jDomQuery standalone, or any jQuery version, (instead of DomQuery) linked in the previous article, but there is an unresolved bug with the getRegion method since jQuery doesn&#8217;t return actual Array&#8217;s.  But if you&#8217;re not using that method, have at it.</p>
<h1>What can I do with it?</h1>
<p>I have not included ALL functions in this class, only the ones that take nodes in as arguments.  If you use these functions, you are encouraged to use the unmodified versions contained in YAHOO.util.Dom.  Functions not included here: getClientHeight, getClientWidth, getDocumentHeight, getDocumentScrollLeft, getDocumentScrollTop, getDocumentWidth, getViewportHeight, getViewportWidth.</p>
<p>Let&#8217;s see some documentation on this mother (if you&#8217;re wondering what the original functions do, see the <a href="http://developer.yahoo.com/yui/docs/YAHOO.util.Dom.html">original documentation</a>).</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// this is the test context node we're going to pass in</span>
<span style="color: #003366; font-weight: bold;">var</span> context <span style="color: #339933;">=</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'context'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>addClass</h1>
<p>Adds a CSS class to first matching node.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns void</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'div div:last'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'myClass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div div:last'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #3366CC;">'myClassContext'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>addClassAll</h1>
<p>Adds a CSS class to all matching nodes.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns void</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClassAll</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'div div:last'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'myClass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClassAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div div:last'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #3366CC;">'myClassContext'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>hasClass</h1>
<p>Tests the first result node returned to see if it has a CSS class.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Booleans.</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div div:last'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'myClass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div div:last'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #3366CC;">'myClassContext'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>hasClassAll</h1>
<p>Tests all matching nodes to see if they have a CSS class.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of Booleans.</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClassAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div div:last'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'myClass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClassAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div div:last'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #3366CC;">'myClassContext'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>removeClass</h1>
<p>Removes a CSS class from first matched node.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Boolean (misdocumented on the YAHOO.util.Dom page)</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'third'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span><span style="color: #3366CC;">'third'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>removeClassAll</h1>
<p>Removes a CSS class from all matched nodes.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of Booleans (misdocumented on the YAHOO.util.Dom page)</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClassAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'third'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClassAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span><span style="color: #3366CC;">'third'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>replaceClass</h1>
<p>Replaces a CSS class on first matched node with a new CSS class, or adds it if the old CSS class doesn&#8217;t exist.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Boolean (misdocumented on the YAHOO.util.Dom page)</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">replaceClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'fourth'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'third'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">replaceClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span><span style="color: #3366CC;">'fourth'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'third'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>replaceClassAll</h1>
<p>Replaces a CSS class on all matched nodes with a new CSS class, or adds it if the old CSS class doesn&#8217;t exist.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of Booleans (misdocumented on the YAHOO.util.Dom page)</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">replaceClassAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'fourth'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'third'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">replaceClassAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span><span style="color: #3366CC;">'fourth'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'third'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>get</h1>
<p>Get first matched node.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div b'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div b'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getAll</h1>
<p>Get all matched nodes.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div b'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div b'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>batch</h1>
<p>Executes a function against first matched node.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns single return value from the function</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">batch</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second b'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> el<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">batch</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div b'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> el<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>batchAll</h1>
<p>Executes a function against all matched nodes.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of return values from the function</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">batchAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second b'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> el<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">batchAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div b'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> el<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>generateId</h1>
<p>Generates and assigns a unique ID attribute if not present on first matched element.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns String (new ID attribute)</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">generateId</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.first'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">generateId</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>generateIdAll</h1>
<p>Generates and assigns a unique ID attribute if not present on matched elements.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of String (new ID attributes)</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">generateIdAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.first'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">generateIdAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getChildren</h1>
<p>Gets all HTMLElement children of the first matched node (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getChildren</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getChildrenBy</h1>
<p>Returns all HTMLElement children of the first matched node that pass a Boolean function test. (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getChildrenBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'theMiddleB'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getChildrenBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'theMiddleB'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getAncestorBy</h1>
<p>Returns the first HTMLElement ancestor of the first matched node that passes a Boolean function test. (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getAncestorBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'context'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getAncestorBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'context'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getAncestorByClassName</h1>
<p>Returns the first HTMLElement ancestor of the first matched node that has a CSS Class. (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getAncestorByClassName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'contextClass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getAncestorByClassName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #3366CC;">'contextClass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getAncestorByClassName</h1>
<p>Returns the first HTMLElement ancestor of the first matched node that is a certain tag (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getAncestorByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getAncestorByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getFirstChild</h1>
<p>Returns the first HTMLElement child of the first matched node (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getFirstChild</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getFirstChild</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getFirstChildBy</h1>
<p>Returns the first HTMLElement child that passes a boolean function test from the first matched node (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getFirstChildBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'theMiddleB'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getFirstChildBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'theMiddleB'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getLastChild</h1>
<p>Returns the last HTMLElement child of the first matched node (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getLastChild</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getLastChild</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getLastChildBy</h1>
<p>Returns the last HTMLElement child that passes a boolean function test from the first matched node (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getLastChildBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'theMiddleB'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getLastChildBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'theMiddleB'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getNextSibling</h1>
<p>Returns the next HTMLElement sibling of the first matched node (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getNextSibling</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getNextSibling</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getNextSiblingBy</h1>
<p>Returns the next HTMLElement sibling that passes a boolean function test from the first matched node (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getNextSiblingBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'third'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getNextSiblingBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span><span style="color: #3366CC;">'third'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getPreviousSibling</h1>
<p>Returns the previous HTMLElement sibling of the first matched node (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getPreviousSibling</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getPreviousSibling</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getPreviousSiblingBy</h1>
<p>Returns the previous HTMLElement sibling that passes a boolean function test from the first matched node (does not include text nodes or whitespace)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getPreviousSiblingBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'third'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getPreviousSiblingBy</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span><span style="color: #3366CC;">'third'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getRegion</h1>
<p>Gets the <a href="http://developer.yahoo.com/yui/docs/YAHOO.util.Region.html">Region</a> containing the first matched element.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns &lt;a href=&quot;http://developer.yahoo.com/yui/docs/YAHOO.util.Region.html&quot;&gt;YAHOO.util.Region&lt;/a&gt;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getRegion</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getRegion</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getRegionAll</h1>
<p>Gets all <a href="http://developer.yahoo.com/yui/docs/YAHOO.util.Region.html">Regions</a> containing all matched elements.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of &lt;a href=&quot;http://developer.yahoo.com/yui/docs/YAHOO.util.Region.html&quot;&gt;YAHOO.util.Region&lt;/a&gt;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getRegionAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.myClass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getRegionAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.myClass'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>setStyle</h1>
<p>Sets the style for the first matched node</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns void</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'border'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'1px'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #3366CC;">'border'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'10px'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>setStyleAll</h1>
<p>Sets style for all matched nodes</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns void</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setStyleAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'border'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'1px'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setStyleAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #3366CC;">'border'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'10px'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getStyle</h1>
<p>Gets a specific style property from the first matched node</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns String of specific style property</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'border'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #3366CC;">'border'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getStyleAll</h1>
<p>Gets a specific style property from all matched nodes</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of Strings of specific style property</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getStyleAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'border'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getStyleAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #3366CC;">'border'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>setX, setY, setXY</h1>
<p>Sets the horizontal placement (X), vertical placement (Y), or both (XY) of the first matched element</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns void</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setX</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setX</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #CC0000;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setY</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setY</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #CC0000;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setXY</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">120</span><span style="color: #339933;">,</span><span style="color: #CC0000;">120</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setXY</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">120</span><span style="color: #339933;">,</span><span style="color: #CC0000;">120</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>setXAll, setYAll, setXYAll</h1>
<p>Sets the horizontal placement (X), vertical placement (Y), or both (XY) of all matched elements</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns void</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setXAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setXAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #CC0000;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setYAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setYAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #CC0000;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setXYAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">120</span><span style="color: #339933;">,</span><span style="color: #CC0000;">120</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setXYAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">120</span><span style="color: #339933;">,</span><span style="color: #CC0000;">120</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getX, getY, getXY</h1>
<p>Gets the horizontal placement (X), vertical placement (Y), or both (XY) of the first matched element</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Integer</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getX</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getX</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getY</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getY</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getXY</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getXY</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>getXAll, getYAll, getXYAll</h1>
<p>Gets the horizontal placement (X), vertical placement (Y), or both (XY) of all matched elements</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Array of Integers</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getXAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getXAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getYAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getYAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getXYAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">getXYAll</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>inDocument</h1>
<p>Find out whether the first matched element is in the current document</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns Boolean</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">inDocument</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">inDocument</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>insertAfter</h1>
<p>Take the first matched node of the first selector and insert after the first matched node of the second selector</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Note that this function handles context nodes on the first or second selectors, both, or none.</span>
<span style="color: #006600; font-style: italic;">// returns the moved HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'div.fourth'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">insertAfter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>insertBefore</h1>
<p>Take the first matched node of the first selector and insert before the first matched node of the second selector</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Note that this function handles context nodes on the first or second selectors, both, or none.</span>
<span style="color: #006600; font-style: italic;">// returns the moved HTMLElement</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.third'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span><span style="color: #3366CC;">'div.fourth'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h1>isAncestor</h1>
<p>Find out whether the first matched node of the first selector is an ancestor of the first matched node of the second selector.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Note that this function handles context nodes on the first or second selectors, both, or none.</span>
<span style="color: #006600; font-style: italic;">// return Boolean</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">isAncestor</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'b#theFirstB'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">isAncestor</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span><span style="color: #3366CC;">'b#theFirstB'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">isAncestor</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'b#theFirstB'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Y2.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">isAncestor</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div.second'</span><span style="color: #339933;">,</span> context<span style="color: #339933;">,</span><span style="color: #3366CC;">'b#theFirstB'</span><span style="color: #339933;">,</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>(Documentation is a bitch!)</p>
<h1>Additional Information</h1>
<ul>
<li><a href="http://www.zachleat.com/Projects/Y2/test.html">Run the test document.</a> (Might convert this to YUI Test framework if there is enough interest in this extension)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/write-more-efficient-javascript-in-yui-with-css-selectors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using DOM Query Libraries in YUI</title>
		<link>http://www.zachleat.com/web/using-dom-query-libraries-in-yui/</link>
		<comments>http://www.zachleat.com/web/using-dom-query-libraries-in-yui/#comments</comments>
		<pubDate>Mon, 30 Jul 2007 07:37:03 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[CSS Selectors]]></category>
		<category><![CDATA[DED|Chain]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Packer]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/07/30/using-dom-query-libraries-in-yui/</guid>
		<description><![CDATA[Recently, I posted the top 8 things I thought the YUI Library needed to be a top tier JavaScript library again. One of those things included a CSS Selector DOM Querying class. Use one of these babies for awhile, and you&#8217;ll never be able to code without it again. They&#8217;re amazingly useful and will shorten [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I posted the top 8 things I thought the YUI Library needed to be a top tier JavaScript library again.  One of those things included a CSS Selector DOM Querying class.  Use one of these babies for awhile, and you&#8217;ll never be able to code without it again.  They&#8217;re amazingly useful and will shorten your code quite beautifully.</p>
<p>So, let&#8217;s plug one of them into YUI!  Let&#8217;s get some of that power under the hood.  And let&#8217;s make it work identically to how we write our code for YUI currently, instead of changing the coding style (a la Dustin Diaz&#8217;s great extension to YUI called <a href="http://dedchain.dustindiaz.com/">DED|Chain</a>).</p>
<p>How are we going to do this?  Let&#8217;s dive into the shallow end of the pool.</p>
<p>The include order of our javascript files is going to be important.  So, first we&#8217;ll do the YUI library core file (either yahoo-dom-event.js or utilities.js depending on your need for animation).  Next, we need to include a CSS Selector DOM Querying class.  For this proof of concept, I&#8217;ve provided examples for my two favorites, the jQuery engine and Jack Slocum&#8217;s DomQuery.  These files are released under the MIT license, so make sure that complies with your project.  It&#8217;s pretty liberal, so you shouldn&#8217;t have any problems.  If you find these querying libraries useful, please donate to these projects!</p>
<p>For code simplicity, I&#8217;ve added a one liner to Jack&#8217;s DomQuery to make it work as a standalone file.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">typeof</span> Ext <span style="color: #339933;">==</span> <span style="color: #3366CC;">'undefined'</span> <span style="color: #009900;">&#41;</span> <span style="color: #003366; font-weight: bold;">var</span> Ext <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you want to read more about DomQuery, you can go to <a href="http://www.jackslocum.com/blog/2007/01/11/domquery-css-selector-basic-xpath-implementation-with-benchmarks/">Jack&#8217;s site all about syntax and benchmarks</a>.</p>
<p>Download: <a href="/Projects/Y2/DomQuery.js">Jack Slocum&#8217;s DomQuery Standalone File (24 KB)</a> 1.0 Alpha 3 &#8211; Rev 4<br />
Download: <a href="/Projects/Y2/DomQuery-packer.js">Jack Slocum&#8217;s DomQuery Standalone File Packed (7 KB)</a> 1.0 Alpha 3 &#8211; Rev 4</p>
<p>If you want to use jQuery&#8217;s selector engine, I&#8217;ve stripped out the functions unnecessary to the selector engine in the 1.1.3.1 release and packaged it up as jDomQuery.  There are differences between these two package&#8217;s syntax, so make sure you keep that in mind, especially when looking at the pseudos, like :gt() and :lt() for example.</p>
<p>Download: <a href="/Projects/Y2/jdomquery-1.1.3.1.js">jDomQuery Standalone File (23 KB)</a> 1.1.3.1<br />
Download: <a href="/Projects/Y2/jdomquery-1.1.3.1-packer.js">jDomQuery Standalone File Packed (10 KB)</a> 1.1.3.1</p>
<p>If you want to read about jQuery syntax, <a href="http://docs.jquery.com/Selectors">go over to their documentation</a>.  My current preference is the jQuery syntax, given that it <a href="http://www.zachleat.com/web/2007/07/10/javascript-frameworks-and-jsf/">works with poorly implemented JSF ID attributes</a>.  But that&#8217;s a different argument.</p>
<p>If you want to use the full jQuery library, that should work too, but if you want to do that, you might just want to switch to using jQuery at that point (dare I say it).</p>
<p>Next, we&#8217;ll extend the YAHOO.util.Dom class into a new Y2 namespace.  This will map all of the functions from YAHOO.util.Dom into a new CSS Selector extension.</p>
<h1>Download: <a href="/Projects/Y2/Dom.js">Y2.util.Dom (2 KB)</a></h1>
<p>(pack at your own leisure, you can do it online at <a href="http://dean.edwards.name/packer/">Dean Edward&#8217;s Packer</a>)</p>
<h1>Putting It All Together</h1>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
	&lt;body&gt;
		&lt;div&gt;
			&lt;div class=&quot;first&quot;&gt;
				&lt;span&gt;&lt;/span&gt;
			&lt;/div&gt;
			&lt;div class=&quot;second&quot;&gt;
				&lt;b&gt;&lt;/b&gt;
			&lt;/div&gt;
		&lt;/div&gt;
		&lt;script type=&quot;text/javascript&quot; src=&quot;/Lib/yui/build/yahoo-dom-event/yahoo-dom-event.js&quot;&gt;&lt;/script&gt;
		&lt;script type=&quot;text/javascript&quot; src=&quot;jdomquery-1.1.3.1-packer.js&quot;&gt;&lt;/script&gt;
		&lt;!-- &lt;script type=&quot;text/javascript&quot; src=&quot;DomQuery-packer.js&quot;&gt; --&gt;
		&lt;script type=&quot;text/javascript&quot; src=&quot;Dom.js&quot;&gt;&lt;/script&gt;
		&lt;script type=&quot;text/javascript&quot;&gt;
		Y2.util.Dom.addClass( 'div div:last', 'myClass' )
		Y2.util.Dom.hasClass( 'div div:last', 'myClass' ); // returns true
		var b = Y2.util.Dom.get( 'div div:last b' );
		Y2.util.Dom.addClass( b, 'myOtherClass' );
		&lt;/script&gt;
	&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>One important thing to note is that when using the CSS Selector syntax, when only one node is selected, functions will return a scalar instead of an array.  So if you&#8217;re expecting to select multiple nodes in your selector query and only one node results, make sure your code handling the result is prepared for such an instance.</p>
<p>Have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/using-dom-query-libraries-in-yui/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>JavaScript Frameworks and JSF</title>
		<link>http://www.zachleat.com/web/javascript-frameworks-and-jsf/</link>
		<comments>http://www.zachleat.com/web/javascript-frameworks-and-jsf/#comments</comments>
		<pubDate>Wed, 11 Jul 2007 02:24:05 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Facelets]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[Mootools]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/07/10/javascript-frameworks-and-jsf/</guid>
		<description><![CDATA[You&#8217;re programming a new web application using JSF, maybe with Facelets, maybe without. Which client-side JavaScript framework is going to work with it&#8217;s unstandardized method of assigning ID attributes to it&#8217;s elements? Here is an example of a JSF file: &#60;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %&#62; &#60;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %&#62; &#60;html&#62; &#60;body&#62; &#60;f:view&#62; &#60;h:form id="myForm"&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;re programming a new web application using JSF, maybe with Facelets, maybe without.  Which client-side JavaScript framework is going to work with it&#8217;s unstandardized method of assigning ID attributes to it&#8217;s elements?  Here is an example of a JSF file:<br />
<code><br />
&lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %&gt;<br />
&lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %&gt;<br />
&lt;html&gt;<br />
 &lt;body&gt;<br />
   &lt;f:view&gt;<br />
     &lt;h:form id="myForm"&gt;<br />
      &lt;h:inputText id="myText"/&gt;<br />
     &lt;/h:form&gt;<br />
   &lt;/f:view&gt;<br />
 &lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
<p>or maybe the same thing using Facelets:<br />
<code><br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"<br />
      xmlns:h="http://java.sun.com/jsf/html"<br />
      xmlns:f="http://java.sun.com/jsf/core"&gt;<br />
 &lt;body&gt;<br />
   &lt;f:view&gt;<br />
     &lt;form jsfc="h:form" id="myForm"&gt;<br />
      &lt;input type="text" jsfc="h:inputText" id="myText"/&gt;<br />
     &lt;/form&gt;<br />
   &lt;/f:view&gt;<br />
 &lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
<p>These will both output the following result:<br />
<code><br />
&lt;html xmlns="http://www.w3.org/1999/xhtml"<br />
      xmlns:ui="http://java.sun.com/jsf/facelets"&gt;<br />
 &lt;body&gt;<br />
     &lt;form id="myForm"&gt;<br />
      &lt;input type="text" id="myForm:myText"/&gt;<br />
     &lt;/form&gt;<br />
 &lt;/body&gt;<br />
&lt;/html&gt;<br />
</code></p>
<p>Notice how the resulting text field has an ID attribute with the parent id prepended on.  Now the real question is, how do we select this result node using the various JavaScript frameworks that are available to us?</p>
<h1>Works, but we don&#8217;t care: Raw JavaScript or any GetById Function</h1>
<p>Obviously using <code>document.getElementById( 'myForm:myText' );</code> will function correctly.  As will any framework that has a similar &#8220;GetById&#8221; function (YAHOO.util.Dom.get, or $ in Prototype, etc)  What is more interesting to us is the behavior using the various CSS selector packages included with each JavaScript library.</p>
<h1>Does not work: <a href="http://extjs.com/deploy/ext/docs/output/Ext.DomQuery.html">DomQuery</a> in Ext 1.1 Beta 2</h1>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Ext.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>These two tests will throw the error <code>Ext.DomQuery.pseudos[name] is not a function</code>, which obviously means that myText is not a pseudo class like :first or :last.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Throws the error: <code>Error parsing selector, parsing failed at "\:myText"</code></p>
<h1>Works: <a href="http://docs.jquery.com/DOM/Traversing/Selectors">jQuery</a> 1.1.3</h1>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As of version 1.1.3 (the latest of this writing), they have added support for the colon in ID selection when escaped with a double backslash.  Versions older than 1.1.3 will not function properly.  This is not yet in the documentation but can be viewed in the <a href="http://jquery.com/blog/2007/07/01/jquery-113-800-faster-still-20kb/">Escape selectors section of a blog post</a>.</p>
<h1>Does not Work: <a href="http://www.prototypejs.org/api/utility/dollar-dollar">Prototype</a> 1.5.1.1</h1>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Returns the form instead of the input element and treats myText as a pseudo class.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Interprets as XPATH selectors (\\ means anywhere in the document), using myText as a pseudo selector now, so it returns ALL nodes in the document.</p>
<h1>Does not Work: <a href="http://dojotoolkit.org/node/336">Dojo query</a> 0.9.0 Beta</h1>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">dojo.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dojo.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dojo.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>It&#8217;s becoming mind numbingly obvious that if the framework doesn&#8217;t specifically say that you can escape selectors, it&#8217;s not going to let you do so.  In the first two tests, Dojo performs the same as Prototype.  In the double backslash test however, Dojo returns no result nodes.</p>
<h1>Does not Work: <a href="http://docs.mootools.net/Element/Element-Selectors.js">Mootools</a> 1.11</h1>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\:</span>myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#myForm<span style="color: #000099; font-weight: bold;">\\</span>:myText'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>All throw the error <code>The expression is not a legal expression." code: "51</code>.</p>
<p>There you have it folks.  jQuery is the JavaScript library of choice for the discerning JSF applications developer.  Kudos to you if you&#8217;re already using it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/javascript-frameworks-and-jsf/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>DOMDom, easy DOM Element Creation</title>
		<link>http://www.zachleat.com/web/domdom-easy-dom-element-creation/</link>
		<comments>http://www.zachleat.com/web/domdom-easy-dom-element-creation/#comments</comments>
		<pubDate>Sun, 08 Jul 2007 04:59:31 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[CSS Selectors]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/07/07/domdom-easy-dom-element-creation/</guid>
		<description><![CDATA[Generally when approaching a complex problem involving web programming in JavaScript, the first question I ask myself is &#8216;What would Jesus do?&#8217; As much as I am entertained by a mental picture of Mr. Jesus himself sitting on his Jesux Distro appending children (and parents) into his DOM, I am instead distracted by an intense [...]]]></description>
			<content:encoded><![CDATA[<p>Generally when approaching a complex problem involving web programming in JavaScript, the first question I ask myself is &#8216;What would Jesus do?&#8217;  As much as I am entertained by a mental picture of Mr. Jesus himself sitting on his <a href="http://www.geocities.com/ResearchTriangle/Node/4081/">Jesux Distro</a> appending children (and parents) into his DOM, I am instead distracted by an intense &#8220;passionate&#8221; hatred for Mel Gibson swelling in my chest.  It&#8217;s actually quite distracting to the problem I am having, but I calm myself by punching my 4 foot tall inflatable Mad Max and wonder how much time I waste doing this.  I figure it happens about twice an hour.  (Digression)</p>
<p>The DOM.  Arch-nemesis of web developers attempting to support the ultimately tiny (I think it&#8217;s down to about 5 or 8% now?) sliver of browser market share that Internet Explorer currently entails.  Let&#8217;s make it easier on ourselves and make a little package to do it for us.  Run a function, pass in an argument with a description of the DOM node(s) we wish to create, and have the package auto-correct any bugs we would have encountered during manual creation, and maybe even have it inserted or appended for us.</p>
<p>But wait, why are we doing this when there are literally 80 billion other DOM element creation classes already out there?  It&#8217;s all about syntax.  The existing packages are incredibly verbose, focusing too much on a complex object structure to describe the nodes, in some cases even having separate objects for attributes inside a single node.  Why not use the syntax we&#8217;ve already come to love in the various DOM query libraries that are available?  Why not use DOMDom? Let&#8217;s see a few examples:</p>
<p>Single Node String</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'div'</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div&gt;&lt;/div&gt;</pre></div></div>

<p>Single Node String with ID and Classes</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'div#id1.class1.class2'</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;id1&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;class1 class2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Single Node String for a Form Element</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'input[name=&quot;myTextBox&quot;,type=&quot;text&quot;,maxlength=&quot;5&quot;]'</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;input</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;myTextBox&quot;</span> <span style="color: #000066;">maxlength</span>=<span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Single Node String with Style Syntax</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'div{height=80px,color=#f90,border=1px solid #000}'</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;border: 1px solid #000; height: 80px; color: #f90&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Complex Single Node String with ID, multiple classes, Style, and Namespaced Attribute)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'div#id1.class1.class2[style=&quot;width:60px;color:#f90&quot;,@class=&quot;class4&quot;,@att=&quot;true&quot;,@namespace:att=&quot;false&quot;]'</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;id1&quot;</span> <span style="color: #000066;">att</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">namespace:att</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;class1 class2 class4&quot;</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;width: 60px; color: #f90;&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Multiple Node String: Linear (Parents with one Child)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'div span div'</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Multiple Node String: Non-Linear (Parent with more than one Child)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">'div'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> <span style="color: #3366CC;">'span'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'span'</span> <span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;span<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/span<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h1>How Does It Work?</h1>
<p>By default, it&#8217;s set up to do HTML Fragments (innerHTML) because they are much speedier than the manual DOM element creation (createElement).  But if you desire, you can toggle a boolean in the code and it will switch back to DOM element creation.  When in DOM element creation mode, it will account for the following browser bugs:</p>
<ul>
<li>(IE6) Standardized for attribute representation (pointer to htmlFor)</li>
<li>(IE6) Standardized case for accesskey, usemap, maxlength, and frameborder attributes.</li>
<li>(IE6) Standardized checked attribute for radio and checkboxes.</li>
<li>(IE6) Special consideration for dynamic handling of name and type attributes (on form elements).</li>
<li>(Firefox) <a href="http://developer.mozilla.org/en/docs/Whitespace_in_the_DOM">Works with whitespace that is treated as a node.</a></li>
</ul>
<h1>Syntax</h1>
<p>You should already be able to tell how to create a node from the examples above.  Here are some more things you might not have guessed:</p>
<p>Creating a node with an id</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'div#myId'</span></pre></div></div>

<p>Creating a node with CSS classes</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'div.class1.class2'</span></pre></div></div>

<p>Creating two nodes at the same level</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#91;</span> <span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'div'</span> <span style="color: #009900;">&#93;</span></pre></div></div>

<p>Creating a node with two children</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">'div'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> <span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'div'</span> <span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can mix the {} and [] syntax wherever you like, but if you want a node to have non-linear children, you have to use the {} object notation.</p>
<p>Creating a text node (start the node declaration with a #, you can change this to another non-conflicting character in the code if you like)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'#Any Text Here'</span></pre></div></div>

<p>Creating a node with attributes (the @ is optional)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'div[class=&quot;class3&quot;,style=&quot;width:60px;color:#f90&quot;,@att=&quot;true&quot;,@namespace:att=&quot;false&quot;]'</span></pre></div></div>

<p>Creating a node with a Style Shortcut (mixing with a style attribute is handled properly)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'div{color=#f90,border=1px solid #000}[style=&quot;height:80px;background:#fff&quot;]'</span></pre></div></div>

<p>A few notes on attributes.  Quotes are required on attributes (single or double but be consistent), but are not required in the style shortcut declaration.  Quotes are not allowed to be nested inside of attributes (a single quote cannot be inside of a double quote and vice versa).</p>
<p>And of course, all of the above can be mixed together</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #3366CC;">'div#myId.class1.class2{color=#f90}[customAttr=&quot;true&quot;,@customAttr2=&quot;false&quot;] div#child1 div#child2'</span></pre></div></div>

<h1>Usage</h1>
<p><strong>Appending</strong> at the end of a parent&#8217;s children:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">DOMDom.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> yourParentNode <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Replacing</strong> the children of a parent:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">DOMDom.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> yourParentNode <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Unshifting </strong>(inserting at the beginning of a parent&#8217;s children):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">DOMDom.<span style="color: #660066;">unshift</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> yourParentNode <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>Inserting</strong> before a certain integer index of a parent&#8217;s children:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">DOMDom.<span style="color: #660066;">insert</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'div'</span><span style="color: #339933;">,</span> yourParentNode<span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// must have at least 3 children, the index is 0 based, if index is null with unshift by default</span></pre></div></div>

<h1>Templates</h1>
<p>Use &lt;$var&gt; to indicate a variable, in this example &lt;$test&gt;</p>
<p><code><br />
// "Compile" the template<br />
var str = DOMDom.compile( { 'div.test span': '#Test &lt;$test&gt;' } );</p>
<p>// Use your template in some context, notice the test variable being set.<br />
for( var j = 0; j < 1000; j++ )<br />
{<br />
	// knows we're using a compiled template since we're passing in variables as a third argument.<br />
	DOMDom.append( str, d, { test: j } );<br />
}<br />
</code></p>
<h3>Benchmarks</p>
<h4>
(If you have Firebug open, make sure it's not on the HTML tab, this will slow down the benchmark significantly)</p>
<p>Most of my work here has been inspired by the DomQuery and DomHelper classes written by JavaScript rock star Jack Slocum (the guy's initials are J.S. for God's sake), so I modeled my benchmark after <a href="http://www.jackslocum.com/blog/examples/domhelper.php">his benchmark hosted on his website to test the DomHelper class</a>.  I'm running the same nodes he's testing on his website, so the results should be comparable.  You can <a href="http://www.zachleat.com/Projects/DOMDom/benchmark.html">test my benchmark for DOMDom here</a>.  Here are some results, reporting the average of 3 results with the format of an uncompiled element first and the compiled template in square brackets.<br />
</h4>
<h2>DOMDom Results</h2>
<p>Internet Explorer 6: 666 ms [328 ms]<br />
Firefox 2.0.0.4: 1880 ms [666 ms]<br />
Safari 3.0.2 [Windows]: 546 ms [151 ms]<br />
Opera 9.21: 343 ms [140 ms]</p>
<h2>Comparative numbers from Jack Slocum's DomHelper</h2>
<p>Internet Explorer 6: 2458 ms [677 ms]<br />
Firefox 2.0.0.4: 672 ms [458 ms]<br />
Safari 3.0.2 [Windows]: 291 ms [119 ms]<br />
Opera 9.21: 370 ms [166 ms]</p>
<p>The thing to take away from this is the question of why Satan is haunting my benchmarks?  Two 666 averages?  Anyway, DOMDom is quite a bit faster in the most popular browser, Internet Explorer, although I haven't tested it on IE7 yet.  In Firefox, the opposite is true, with DomHelper taking the lead.  Opera is comparable and Safari is faster in DomHelper as well.  You can run your own tests using the links above.</p>
<h1>Dependencies</h1>
<p>This library was built to work with Yahoo User Interface (YUI), but could be trivially ported to another library by changing the function dependencies listed in the ADAPTER variable in the code.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> ADAPTER <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	setStyle<span style="color: #339933;">:</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">setStyle</span><span style="color: #339933;">,</span>
	addClass<span style="color: #339933;">:</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #339933;">,</span>
	isString<span style="color: #339933;">:</span> YAHOO.<span style="color: #660066;">lang</span>.<span style="color: #660066;">isString</span><span style="color: #339933;">,</span>
	isArray<span style="color: #339933;">:</span> YAHOO.<span style="color: #660066;">lang</span>.<span style="color: #660066;">isArray</span><span style="color: #339933;">,</span>
	isNumber<span style="color: #339933;">:</span> YAHOO.<span style="color: #660066;">lang</span>.<span style="color: #660066;">isNumber</span><span style="color: #339933;">,</span>
	isObject<span style="color: #339933;">:</span> YAHOO.<span style="color: #660066;">lang</span>.<span style="color: #660066;">isObject</span><span style="color: #339933;">,</span>
	get<span style="color: #339933;">:</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">get</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// to port, change these references</span></pre></div></div>

<p>If you're still reading this encyclopedia, here are some links:</p>
<ul>
<li><span style="font-size: 200%"><a href="http://www.zachleat.com/Projects/DOMDom/DOMDom.js">DOWNLOAD DOMDom</a></span></li>
<li><a href="http://www.zachleat.com/Projects/DOMDom/DOMDom-min-jsmin.js">DOWNLOAD DOMDom Minimized with JSMIN (10KB)</a></li>
<li><a href="http://www.zachleat.com/Projects/DOMDom/DOMDom-min-packer.js">DOWNLOAD DOMDom Minimized with Packer (6KB)</a></li>
<li><a href="http://www.zachleat.com/Projects/DOMDom/benchmark.html">See the benchmark</a></li>
<li><a href="http://www.zachleat.com/Projects/DOMDom/tests.html">See the test file with a bunch of examples of syntax</a></li>
</ul>
<p><a href="http://www.encyclopedia.com/doc/1O27-dom1.html"><em>-dom suffix denoting condition or state, as in freedom, wisdom, or DOMDom</em></a></p>
<p><strong>Update</strong>: changed the variable syntax to allow variables inside of nodes (not just text).</h3>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/domdom-easy-dom-element-creation/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Wake up to YouTube on my Internet Alarm Clock</title>
		<link>http://www.zachleat.com/web/wake-up-to-youtube-on-my-internet-alarm-clock/</link>
		<comments>http://www.zachleat.com/web/wake-up-to-youtube-on-my-internet-alarm-clock/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 01:40:07 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[Interface Design]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Alarmd]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/06/18/wake-up-to-youtube-on-my-internet-alarm-clock/</guid>
		<description><![CDATA[Update: Try the new ALARMd 2 Beta, with Google Calendar integration and offline Youtube caching. Did you take your contacts out last night and you can&#8217;t see the time on your alarm clock from all the way across the room? I&#8217;m here to calm your fears. Enter ALARMD, the Internet Alarm Clock. Wake up to [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>Update</strong>: Try the new <a href="http://www.zachleat.com/web/2008/04/06/alarmd-2-beta-with-google-calendar-integration/">ALARMd 2 Beta</a>, with Google Calendar integration and offline Youtube caching.</em></p>
<p>Did you take your contacts out last night and you can&#8217;t see the time on your alarm clock from all the way across the room?  </p>
<p>I&#8217;m here to calm your fears.  Enter <a href="http://www.zachleat.com/Projects/alarmd/">ALARMD, the Internet Alarm Clock</a>.  Wake up to any Youtube video (that allows embedding), a last.fm user stream or tag, or any mp3 hosted online.  There are a few defaults in there, but you can add and modify your own.</p>
<p><a href="http://www.flickr.com/photos/zachleat/531165035/" title="Photo Sharing"><img src="http://farm2.static.flickr.com/1067/531165035_d2ba407333.jpg" width="500" height="375" alt="Now that's an alarm clock" /></a></p>
<p>Features:</p>
<ul>
<li>Supports multiple alarms (ALT+R to add an alarm or use the Add Alarm button).</li>
<li>Options for 24 Hour (Military) time and Seconds display</li>
<li>Supports MP3 (hosted online), YouTube videos (that allow embedding), and last.fm user or tag streams.</li>
<li>Key Mash Mode to kill the alarm (hit five random keys in one second)</li>
<li>Time Font Size customization (automatically size to the width of the window using the Max option)</li>
<li>Typical alarm clock colors: Red, Green, or Blue</li>
<li>Alarm Toggle based on the Day of the Week</li>
<li>Test button to make sure your speaker volume is set correctly.</li>
<li>Sleep Mode button to get rid of the extra GUI while you don&#8217;t need it.</li>
<li>Save all of your settings, URL&#8217;s, and alarms locally in a cookie (you <strong>don&#8217;t</strong> need yet another account to use this)</li>
</ul>
<p>Things to think about:</p>
<ul>
<li>Power Settings &#8211; disable your screen saver, or any sort of automatic suspend or sleep setting.  In my testing, having your monitor go into power save mode is acceptable, and the alarms will still sound (but you might want to test this yourself and leave a comment with your result).</li>
<li>You might not want to use with a CRT, for fear of burn in.</li>
<li>Personally, I like to use this in Opera, just because their default full screen mode (F11) doesn&#8217;t have toolbars or a status bar.  But you can use the <a href="https://addons.mozilla.org/en-US/firefox/addon/4650">Fuller Screen Firefox plug-in</a> to soup up your Firefox for similar functionality.</li>
<li>Word of warning, the window <strong>must</strong> have focus to autoplay YouTube videos.</li>
<li>Make sure your local time on your computer is correct, especially if you are traveling between time zones.  It doesn&#8217;t do any server side validation on the time (yet?).</li>
</ul>
<p>Possible Future Improvements:</p>
<ul>
<li>Countdown mode, displays amount of time until next alarm in place of the clock (good for timed presentations, where you want to see how much time is left before you have to quit).</li>
<li>Google Gears integration for offline mode (if your internet goes out during the night)</li>
<li>Support customizing source URL&#8217;s on a per alarm basis.</li>
<li>Support days of the week toggle on a per alarm basis.</li>
<li>Support user specified color customization.</li>
<li>A crescendo alarm MP3 that increases in volume for a more peaceful wake up experience.</li>
<li>An alarm MP3 with especially violent noises for heavy sleepers.</li>
<li>An alarm MP3 of my mom&#8217;s voice to get that nice feeling of childhood back.</li>
</ul>
<p>This internet application was built using the Yahoo UI Libraries (YUI) and Jack Slocum&#8217;s Ext DomQuery class.  It is written entirely without using any server side programming languages, and therefore can be saved to your local machine.  Not that anyone might want to use the Internet Alarm Clock, but if you do, I declare it officially released under the BSD license.  Just don&#8217;t forget to cite the source when you redistribute.</p>
<p><strong>Update</strong>: added a couple more things to think about.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/wake-up-to-youtube-on-my-internet-alarm-clock/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Problems with YUI DataTable</title>
		<link>http://www.zachleat.com/web/problems-with-yui-datatable/</link>
		<comments>http://www.zachleat.com/web/problems-with-yui-datatable/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 22:52:41 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Interface Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/04/04/problems-with-yui-datatable/</guid>
		<description><![CDATA[If you have read anything I&#8217;ve written before or know me at all, you know that my go-to JavaScript library is the one and only YUI. So obviously, when I was looking around for a Grid (or as YUI jargon goes, a DataTable), naturally I&#8217;m going to turn to YUI compatible components. First, I looked [...]]]></description>
			<content:encoded><![CDATA[<p>If you have read anything I&#8217;ve written before or know me at all, you know that my go-to JavaScript library is the one and only YUI.  So obviously, when I was looking around for a Grid (or as YUI jargon goes, a DataTable), naturally I&#8217;m going to turn to YUI compatible components.  First, I looked at Jack Slocum&#8217;s EXT, which has a nice looking Grid component that had a lot of features I wouldn&#8217;t need, but I didn&#8217;t really want to take a 0.5 MB hit for the limited feature set I was requiring.  Adding the YUI DataTable would only tack on approximately 70-75 KB of additional download.  So first, let me establish what I&#8217;m going for:</p>
<p><strong>Minimum Feature Set</strong>:</p>
<ul>
<li>Client-Side Sorting: I don&#8217;t want it to do an XMLHttpRequest to sort the data, I want it to be done all clientside.</li>
<li>Simple inline editing: Edit a field in the table right there on the table.  I hadn&#8217;t established what types of data I would need to edit yet.</li>
<li>Data Sources: load from a native JavaScript array or a XMLHttpRequest returning XML or JSON.</li>
<li>Data Type Sort Algorithms: at the very minimum different sorting algorithms for numeric columns and string columns.</li>
<li>Hierarchical Columns: group column headers together under a parent header.</li>
<li>Easily customizable: must be able to customize the look and feel of the grid easily using CSS and not by editing Javascript.</li>
<li>Header Freeze: If I have overflow on my table vertically causing a scroll bar, I want the table headers to remain shown at the top of the table while I scroll from top to bottom.</li>
<li>Custom Cell Rendering: I have the data I&#8217;m loading, but I want to change how it looks when it is rendered to the table.  Common for date formatting.</li>
</ul>
<p><strong>Luxury Feature Set</strong>:</p>
<ul>
<li>Resizeable Columns: change the width of a column by dragging on the column header&#8217;s right border.</li>
<li>Movable Columns: dragging a column will cause it to be moved on the table (TIBCO General Interface supports this).</li>
<li>Custom Sort Algorithm: write my own algorithm to specify how data is sorted, or provide a way to do multi-column sorting (sort within one column, ties are sorted by another column, and so on).</li>
<li>Dynamic Paging (don&#8217;t make me click numbered links, load the data automatically when I scroll) both on the client (dynamically insert only what I&#8217;m looking at and remove what I&#8217;ve scrolled past) and using the server (load more data through an XMLHttpRequest)</li>
<li>Column Freeze: if the table is going to scroll horizontally, allow the developer to freeze a column or multiple columns so that they are shown when scrolling from left to right.</li>
</ul>
<p><strong>Evaluation of Options</strong>: How does the YUI DataTable stack up?</p>
<p>Basic Items: Client-Side Sorting, Simple inline editing, Data Sources, Data Type Sort Algorithms (<em>stock types not yet implemented out of the box</em>), Hierarchical Columns, Header Freeze (<em>buggy</em>), Custom Cell Rendering, and is easily customizable with CSS.</p>
<p>Luxury Items: Resizeable Columns, Movable Columns (<em>not supported</em>), Custom Sort Algorithms are supported (you can right your own Data Type Sort Algorithms with this feature), Dynamic Paging (manually, not dynamic), Column Freeze (<em>not supported</em>)</p>
<p>Problems:</p>
<ul>
<li>Any sort of fixed width table is going to be problematic.  Putting a fixed width on the table causes the table headers to be misaligned with the associated table data.  It&#8217;s a mess.  The only viable option here is to let the table do it&#8217;s own width calculations.  You can&#8217;t even set the column widths manually using the {width} variable as suggested when using a fixed width table.</li>
<li>Data Type Sort Algorithms supposedly work from the column type, but this feature is documented in the code as being a TODO.  All columns are sorted by a string datatype, meaning that if your column is numeric and you had the following rows: { 3, 7, 40 }, the sort result would be { 3, 40, 7 }.</li>
<li>Header Freeze was problematic.  Implementing the {scrollable=true} feature as recommended by the documentation causes the table headers to be misaligned with the data in a fixed width table.</li>
<li>Paging uses the old school numbers method.  This wasn&#8217;t a deal breaker, since I classified this feature as a luxury item.</li>
</ul>
<p>Granted, the DataTable in it&#8217;s current form is a beta component, but that 0.5 MB ExtJS hit is looking pretty nice right now.</p>
<p><strong>Minor Update</strong>: to do a fixed width table that will overflow horizontally, this is the method you can use:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #cc00cc;">#dataTableId</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #808080; font-style: italic;">/* change this to whatever id you're using to hold the dataTable */</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">520px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* put in your own fixed width */</span>
	overflow-x<span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	overflow-y<span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-headtext</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.yui-dt-headcontainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">static</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* without this declaration, the headers weren't horizontally scrolling with the data in IE6 */</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/problems-with-yui-datatable/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Namespaces in Ext DomQuery</title>
		<link>http://www.zachleat.com/web/namespaces-in-ext-domquery/</link>
		<comments>http://www.zachleat.com/web/namespaces-in-ext-domquery/#comments</comments>
		<pubDate>Tue, 06 Mar 2007 21:37:18 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[XHTML]]></category>
		<category><![CDATA[XML Namespaces]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/03/06/namespaces-in-ext-domquery/</guid>
		<description><![CDATA[Do you want to use custom attributes in your XHTML? Do you use the YUI Library and Jack Slocum&#8217;s wonderful DomQuery selector engine? If you want to select attribute nodes with a namespace in your XHTML, DomQuery does not support namespaces as an option to do so. But by adding a small snippet of code [...]]]></description>
			<content:encoded><![CDATA[<p>Do you want to use <a href="http://unspace.ca/discover/attributes/">custom attributes</a> in your XHTML?  Do you use the YUI Library and Jack Slocum&#8217;s wonderful <a href="http://www.jackslocum.com/blog/2007/01/11/domquery-css-selector-basic-xpath-implementation-with-benchmarks/">DomQuery selector engine</a>?</p>
<p>If you want to select attribute nodes with a namespace in your XHTML, DomQuery does not support namespaces as an option to do so.  But by adding a small snippet of code to DomQuery, we can make it do so.</p>
<p>As a standalone snippet executed after DomQuery is loaded.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">DomQuery</span>.<span style="color: #660066;">matchers</span>.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#123;</span>
	re<span style="color: #339933;">:</span> <span style="color: #009966; font-style: italic;">/^(?:([\[\{])(?:@)?([\w-]+(?:\:[\w-]+))\s?(?:(=|.=)\s?['&quot;]?(.*?)[&quot;']?)?[\]\}])/</span><span style="color: #339933;">,</span>
	select<span style="color: #339933;">:</span> <span style="color: #3366CC;">'n = byAttribute(n, &quot;{2}&quot;, &quot;{4}&quot;, &quot;{3}&quot;, &quot;{1}&quot;);'</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>OR</strong> by adding an array entry into the DomQuery code matchers array (paste <em>after</em> line 479 of the <a href="http://www.yui-ext.com/deploy/yui-ext.0.40-alpha/source/DomQuery.js">17 January 2007 2:26:32 PM version</a>)</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
	re<span style="color: #339933;">:</span> <span style="color: #009966; font-style: italic;">/^(?:([\[\{])(?:@)?([\w-]+(?:\:[\w-]+))\s?(?:(=|.=)\s?['&quot;]?(.*?)[&quot;']?)?[\]\}])/</span><span style="color: #339933;">,</span>
	select<span style="color: #339933;">:</span> <span style="color: #3366CC;">'n = byAttribute(n, &quot;{2}&quot;, &quot;{4}&quot;, &quot;{3}&quot;, &quot;{1}&quot;);'</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I did not modify the existing matcher for attribute selection because I didn&#8217;t want to modify the speed of the existing code for non-namespaced attributes.  So by appending another entry to the end of the array, it&#8217;ll be used as a last resort if the other entries aren&#8217;t matched.</p>
<p>This approach relies on the assumption that when selecting an attribute with getAttribute, the browser interprets any namespace automatically: getAttribute(&#8216;myNamespace:myAttributeName&#8217;), as documented by the <a href="http://blogger.xs4all.nl/peterned/archive/2005/12/11/70033.aspx">peterned weblog</a>.  This was tested in Firefox 2 and IE 6.</p>
<p><strong>Usage:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#test-data span[myNameSpace:myAttribute=myValue]'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>on the following DOM</p>

<div class="wp_syntax"><div class="code"><pre class="xhtml" style="font-family:monospace;">&lt;div id=&quot;test-data&quot;&gt;
&lt;span myNameSpace:myAttribute=&quot;myValue&quot;&gt;&lt;/span&gt;
&lt;/div&gt;</pre></div></div>

<p>Other notes regarding DomQuery:</p>
<p>To select a node with a non-empty attribute value:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">Ext.<span style="color: #660066;">query</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'#test-data span[myNameSpace:myAttribute]'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/namespaces-in-ext-domquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

