<?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>SwellJS - another big fish in the sea &#187; event delegation</title>
	<atom:link href="http://blog.justswell.org/tag/event-delegation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.justswell.org</link>
	<description>well-minded javascript library</description>
	<lastBuildDate>Fri, 20 Aug 2010 20:48:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Even more Drag&amp;Drop coolness between your desktop and your browser!</title>
		<link>http://blog.justswell.org/even-more-dragdrop-coolness-with-event-delegation/</link>
		<comments>http://blog.justswell.org/even-more-dragdrop-coolness-with-event-delegation/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 15:41:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DD]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Swell]]></category>
		<category><![CDATA[drag&drop]]></category>
		<category><![CDATA[event delegation]]></category>
		<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://blog.justswell.org/?p=305</guid>
		<description><![CDATA[We are making more &#38; more progress with the native DnD API, and being native means fully taking advantage of Event Bubbling. In essence this means that if you want to make for example a datatable with a lot of rows without attaching events to them (remember the flyweight pattern?) you&#8217;ll only need to set [...]]]></description>
			<content:encoded><![CDATA[<p>We are making more &amp; more progress with the native DnD API, and being native means fully taking advantage of <strong>Event Bubbling</strong>.</p>
<p>In essence this means that if you want to make for example a datatable with a lot of rows without attaching events to them (remember the flyweight pattern?) you&#8217;ll only need to set your draggable element at a higher level in the hierarchy to get the DnD behavior applied on all children nodes (marked with the draggable attribute), that&#8217;s powerful and of course, reduces a lot the memory footprint of your web application.</p>
<p>A lot of components could benefit of this approach, Treeview, Datatable, Listview and so on.</p>
<p><strong>Another part of the example shows another level of interaction between the browser and desktop, and we are sure this one will get a lot of attention and excitement!</strong></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="581" height="363" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=6500920&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=c9ff23&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="581" height="363" src="http://vimeo.com/moogaloop.swf?clip_id=6500920&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=c9ff23&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://playground.justswell.org/drag-and-drop-event-delegation.html"><img class="aligncenter size-full wp-image-309" title="Swell drag&amp;drop in action" src="http://blog.justswell.org/wp-content/uploads/2009/09/dragging.png" alt="Swell drag&amp;drop in action" width="400" height="128" /></a>And the code <img src='http://blog.justswell.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> proxyElement <span style="color: #339933;">=</span> html.<span style="color: #660066;">div</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> html.<span style="color: #660066;">span</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">'cls'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'dd-proxy-icon'</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> html.<span style="color: #660066;">span</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Moo'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> draggableRows <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Swell.<span style="color: #660066;">Lib</span>.<span style="color: #660066;">DD</span>.<span style="color: #660066;">Draggable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'bleh'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">'delegate'</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">'proxy'</span>  <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
    <span style="color: #3366CC;">'proxyOverride'</span>    <span style="color: #339933;">:</span> proxyElement<span style="color: #339933;">,</span>  
    <span style="color: #3366CC;">'dataCallback'</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>dt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> _currentEl <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getDragEl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">current</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> _stdOut <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> _n <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> _l <span style="color: #339933;">=</span> _currentEl.<span style="color: #660066;">childNodes</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> _n <span style="color: #339933;">&lt;</span> _l<span style="color: #339933;">;</span> _n<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>_currentEl.<span style="color: #660066;">childNodes</span><span style="color: #009900;">&#91;</span>_n<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">nodeType</span> <span style="color: #339933;">===</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> _text <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>_currentEl.<span style="color: #660066;">childNodes</span><span style="color: #009900;">&#91;</span>_n<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                _stdOut.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>Swell.<span style="color: #660066;">Core</span>.<span style="color: #660066;">trim</span><span style="color: #009900;">&#40;</span>_text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setData</span><span style="color: #009900;">&#40;</span>dt<span style="color: #339933;">,</span> <span style="color: #3366CC;">'text/plain'</span><span style="color: #339933;">,</span> _stdOut.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> dropTarget <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Swell.<span style="color: #660066;">Lib</span>.<span style="color: #660066;">DD</span>.<span style="color: #660066;">Droppable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'moo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
dropTarget.<span style="color: #660066;">ondrop</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #339933;">,</span> draggable<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!!</span>draggable<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        draggable.<span style="color: #660066;">getDragEl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'moo'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">current</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">tBodies</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.justswell.org/even-more-dragdrop-coolness-with-event-delegation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

