<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>SitePen Blog</title>
	<atom:link href="http://www.sitepen.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepen.com/blog</link>
	<description>SitePen Services and notes about Dojo, Persevere, CometD, JavaScript, and the Web</description>
	<lastBuildDate>Wed, 01 Feb 2012 20:36:15 +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>Dojo 1.7 Tutorial Update</title>
		<link>http://www.sitepen.com/blog/2012/02/01/dojo-1-7-tutorial-update/</link>
		<comments>http://www.sitepen.com/blog/2012/02/01/dojo-1-7-tutorial-update/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 20:36:15 +0000</pubDate>
		<dc:creator>Torrey Rice</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=3930</guid>
		<description><![CDATA[<p>Hot on the heels of the Dojo 1.7.1 release, we are excited to officially publish SitePen&#8217;s 1.7-specific updates to not one, not two but ALL 55 Dojo 1.6 tutorials. As you can guess, this was no small feat given that Dojo 1.7 is loaded with significant changes that encompass best practices on the road to [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>


Related posts:<ol><li><a href='http://www.sitepen.com/blog/2012/01/17/the-year-of-dojo-is-here/' rel='bookmark' title='Permanent Link: The Year of Dojo is Here!'>The Year of Dojo is Here!</a></li>
<li><a href='http://www.sitepen.com/blog/2007/04/28/dojo-09-update/' rel='bookmark' title='Permanent Link: Dojo 0.9 Update'>Dojo 0.9 Update</a></li>
<li><a href='http://www.sitepen.com/blog/2008/05/11/everyone-can-ask-the-experts/' rel='bookmark' title='Permanent Link: Everyone can &#8220;Ask the Experts&#8221;'>Everyone can &#8220;Ask the Experts&#8221;</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://dojotoolkit.org/documentation/"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/01/17tuts2.png" style="float:left; margin:0 1em 1em 0" /></a>Hot on the heels of the <a href="http://dojotoolkit.org/blog/dojo-1-7-1-is-released">Dojo 1.7.1 release</a>, we are excited to <a href="http://dojotoolkit.org/documentation/">officially publish SitePen&#8217;s 1.7-specific updates</a> to not one, not two but ALL 55 Dojo 1.6 tutorials.   As you can guess, this was no small feat given that Dojo 1.7 is loaded with significant changes that encompass best practices on the road to 2.0.   We’ve revamped the full Dojo 1.6 tutorial series to cover, not only how to do the things you already knew, but to prepare your team and your web app for what&#8217;s to come.</p>
<p>Oh and of course, the tutorials are rewritten to take full advantage of the new Dojo loader’s support for AMD, and they lay a groundwork for preparing your application to be lighter and more modular than ever!</p>
<p>So raise your glass and toast with us to the completion and <a href="http://dojotoolkit.org/documentation/">release of the Dojo 1.7 Tutorials</a> and to the best JavaScript toolkit available for scalable web apps!</p>
<h2 style="font-size:18px"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/01/update.png" style="vertical-align:middle; margin-bottom:3px;" /> Ready to upgrade to 1.7?</h2>
<p>We stand ready to bring your code current to the latest release or kick off your project right out of the gate with Dojo 1.7!  In addition to our dedication to Dojo documentation and tutorials we offer a comprehensive set of services to make your project a success!</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/01/workshop.png" style="vertical-align:middle; margin:0 0.5em 0.5em 0" /><strong>Dojo Workshops</strong> &#8211; Learn Dojo 1.7 from the experts.  We&#8217;ve posted a nationwide, <a href="http://www.sitepen.com/workshops/public.html">2012 workshop schedule</a> that will exceed the expectations of developers and engineering budgets alike!  If these dates and locations don’t work for you and your team, reach out to us about our <a href="http://www.sitepen.com/workshops/private.html">private Dojo workshops</a>.</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/01/support1.png" style="vertical-align:middle; margin:0 0.5em 0.5em 0" /><strong>Dojo Support</strong> &#8211; SitePen offers <a href="http://www.sitepen.com/support/index.html">5 different plans</a>, all of which are provided to you by Dojo experts who will provide your team with the knowledge and experience necessary to support your web development efforts.  Get pro-active and purchase a plan that will support your team with Dojo 1.0 through 1.7 and eliminate potential schedule-busting roadblocks on your path to success!  </p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/01/dev.png" style="vertical-align:middle; margin:0 0.5em 0.5em 0" /><strong>Development</strong> &#8211; Upgrading to Dojo 1.7 will improve your web application.   If you know this to be true but don&#8217;t have the resources to make it happen, <a href="http://www.sitepen.com/development/index.html">engage our development team</a> to work for you and let us do what we do best &#8211; Make you look good. <a href="http://www.sitepen.com/site/contact.html">Contact us for a custom quote</a> for your Dojo 1.7 upgrade.</p>


<p>Related posts:<ol><li><a href='http://www.sitepen.com/blog/2012/01/17/the-year-of-dojo-is-here/' rel='bookmark' title='Permanent Link: The Year of Dojo is Here!'>The Year of Dojo is Here!</a></li>
<li><a href='http://www.sitepen.com/blog/2007/04/28/dojo-09-update/' rel='bookmark' title='Permanent Link: Dojo 0.9 Update'>Dojo 0.9 Update</a></li>
<li><a href='http://www.sitepen.com/blog/2008/05/11/everyone-can-ask-the-experts/' rel='bookmark' title='Permanent Link: Everyone can &#8220;Ask the Experts&#8221;'>Everyone can &#8220;Ask the Experts&#8221;</a></li>
</ol></p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/02/01/dojo-1-7-tutorial-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Eleven Trends for 2012: The Year of Dojo</title>
		<link>http://www.sitepen.com/blog/2012/01/30/eleven-trends-for-2012-the-year-of-dojo/</link>
		<comments>http://www.sitepen.com/blog/2012/01/30/eleven-trends-for-2012-the-year-of-dojo/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 23:35:14 +0000</pubDate>
		<dc:creator>Angela Segovia</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Support]]></category>
		<category><![CDATA[Training]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=3923</guid>
		<description><![CDATA[<p>Most 2012 trend lists include 12 trends. (Get it?  12 in ’12.  Of course you do.).  Because we are not fond of adding unnecessary or filler content (read code), Dylan has come up with 11 trends for 2012. 1.  Mobile Mobile will gain even more momentum in 2012.  There’s no doubt we will see many [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>


Related posts:<ol><li><a href='http://www.sitepen.com/blog/2011/12/05/we%e2%80%99ve-unofficially-declared-2012-as-the-year-of-dojo/' rel='bookmark' title='Permanent Link: We’ve (unofficially) declared 2012 as the Year of Dojo!'>We’ve (unofficially) declared 2012 as the Year of Dojo!</a></li>
<li><a href='http://www.sitepen.com/blog/2012/01/17/the-year-of-dojo-is-here/' rel='bookmark' title='Permanent Link: The Year of Dojo is Here!'>The Year of Dojo is Here!</a></li>
<li><a href='http://www.sitepen.com/blog/2011/10/19/sitepen-at-blackberry-devcon-americas-2011/' rel='bookmark' title='Permanent Link: SitePen at BlackBerry DevCon Americas 2011'>SitePen at BlackBerry DevCon Americas 2011</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Most 2012 trend lists include 12 trends. (Get it?  12 in ’12.  Of course you do.).  Because we are not fond of adding unnecessary or filler content (read code), Dylan has come up with <a title="11 Trends for 2012" href="http://www.slideshare.net/sitepen/2012-the-year-of-dojo" target="_blank">11 trends for 2012</a>.</p>
<p>1.  <a title="Mobile" href="http://www.sitepen.com/development/index.html" target="_blank">Mobile</a></p>
<p>Mobile will gain even more momentum in 2012.  There’s no doubt we will see many new APIs, development tools and capabilities in place to both build and install most any app as a web app rather than using native technology.</p>
<p>2.  <a title="AMD" href="http://dojotoolkit.org/blog/learn-more-about-amd" target="_blank">AMD</a></p>
<p>Following on the increasing emergence of microtoolkits in 2010 and 2011, 2012 will be the year everything becomes an AMD module, making it easier for Dojo, jQuery, MooTools and other toolkits to play nicely together.</p>
<p>3.  <a title="Builders and Loaders" href="http://www.sitepen.com/support/index.html" target="_blank">Builders &amp; Loaders</a></p>
<p>With so many modules, performance, loading and building will need to be optimized.  Use of package management will become increasingly important.</p>
<p>4&#8230; Check out the rest of Dylan’s <a title="11 Trends for 2012" href="http://www.slideshare.net/sitepen/2012-the-year-of-dojo" target="_blank">11 Trends for 2012</a>! And don&#8217;t forget that SitePen&#8217;s got your back when it comes to implementing efficient and scalable solutions.  <a title="Contact SitePen" href="http://www.sitepen.com/site/contact.html" target="_blank">Contact us today</a>!</p>


<p>Related posts:<ol><li><a href='http://www.sitepen.com/blog/2011/12/05/we%e2%80%99ve-unofficially-declared-2012-as-the-year-of-dojo/' rel='bookmark' title='Permanent Link: We’ve (unofficially) declared 2012 as the Year of Dojo!'>We’ve (unofficially) declared 2012 as the Year of Dojo!</a></li>
<li><a href='http://www.sitepen.com/blog/2012/01/17/the-year-of-dojo-is-here/' rel='bookmark' title='Permanent Link: The Year of Dojo is Here!'>The Year of Dojo is Here!</a></li>
<li><a href='http://www.sitepen.com/blog/2011/10/19/sitepen-at-blackberry-devcon-americas-2011/' rel='bookmark' title='Permanent Link: SitePen at BlackBerry DevCon Americas 2011'>SitePen at BlackBerry DevCon Americas 2011</a></li>
</ol></p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/01/30/eleven-trends-for-2012-the-year-of-dojo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 data-dojo Attribute Support</title>
		<link>http://www.sitepen.com/blog/2012/01/19/html5-data-dojo-attribute-support/</link>
		<comments>http://www.sitepen.com/blog/2012/01/19/html5-data-dojo-attribute-support/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 16:05:08 +0000</pubDate>
		<dc:creator>Kris Zyp</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[HTML5]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=2212</guid>
		<description><![CDATA[<p>Dojo has long provided support for declaring widgets and specifying other information directly in HTML. This support makes it extremely quick and easy to get an application started. You can start instantiating widgets by adding attributes to HTML elements before even writing any code. This is not only a very convenient tool, but using a [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>


Related posts:<ol><li><a href='http://www.sitepen.com/blog/2007/11/02/html-widget-prototyping-with-the-dojo-toolkit/' rel='bookmark' title='Permanent Link: HTML Widget Prototyping with the Dojo Toolkit'>HTML Widget Prototyping with the Dojo Toolkit</a></li>
<li><a href='http://www.sitepen.com/blog/2008/05/27/dojo-charting-event-support-has-landed/' rel='bookmark' title='Permanent Link: Dojo Charting: Event Support Has Landed!'>Dojo Charting: Event Support Has Landed!</a></li>
<li><a href='http://www.sitepen.com/blog/2009/11/05/dijit-prepackaged/' rel='bookmark' title='Permanent Link: Dijit: Prepackaged'>Dijit: Prepackaged</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Dojo has long provided support for declaring widgets and specifying other information directly in HTML. This support makes it extremely quick and easy to get an application started. You can start instantiating widgets by adding attributes to HTML elements before even writing any code. This is not only a very convenient tool, but using a declarative approach to binding widgets to elements can be viewed as cleaner and more organized than using the imperative mechanics of JavaScript.<img style="float: left;" title="HTML5 Powered with Semantics" src="http://www.w3.org/html/logo/badge/html5-badge-h-semantics.png" alt="HTML5 Powered with Semantics" width="133" height="64" /> Widgets declared in markup have an encapsulated construction, avoiding instantiation that requires spanning and synchronizing HTML and code manually.</p>
<p>However, the use of Dojo&#8217;s declarative tools has been avoided by some because it uses custom attributes that are outside the HTML specification. While this approach works in every browser on the market and is implicitly allowed, it does not validate against the HTML4 validators. Now, the new HTML5 specification provides a namespace for custom attributes. The data-* attributes are available for libraries and authors to use for their own purposes and extensions while still having validating markup. The HTML5 specification further recommends that library use a sub-namespace for their custom attributes to avoid conflicts with other code. All of the Dojo custom attributes begin with data-dojo-. Let&#8217;s look at the new Dojo attributes.</p>
<p><span id="more-2212"></span></p>
<h2>data-dojo-config</h2>
<p>The data-dojo-config attribute replaces the djConfig attribute on the dojo.js script element to allow for declaration of Dojo&#8217;s configuration properties. Here we can specify settings like parseOnLoad, and isDebug. For example, we can load dojo.js with configuration information:</p>
<pre lang="html4">
&lt;script src="dojo.js" data-dojo-config="parseOnLoad: true, isDebug: true">&lt;/script>
</pre>
<h2>data-dojo-* for widgets</h2>
<p>The new data-dojo-type attribute replaces the dojoType attribute to specify the widget class to instantiate a target element. We can add the data-dojo-type to an HTML tag and the Dojo parser will create a widget on that element. This works in conjunction with the new data-dojo-props which replaces the attribute-to-property mapping previously used by the Dojo parser. We can also use the new data-dojo-id to create a new globally rooted variable to reference the new widget. For example, to declare a widget:</p>
<pre lang="html4">
	&lt;div data-dojo-type="dijit.Dialog" data-dojo-props='title:"My Dialog",
		onFocus:function(){ /* a focus event handler */ }'
		data-dojo-id="myDialog">
	&lt;/div>
</pre>
<p>This will create a new dijit.Dialog widget, with the title property and onFocus handler set. It will make the widget available from the myDialog global variable. Remember to have <code>parseOnLoad</code> set to true or explicitly execute <code>dojo.parser()</code> (from <code>dojo/parser</code>) after the page is loaded to ensure the widget gets instantiated.</p>
<p>Within widget templates, we can also use the new data-dojo-attach-event and data-dojo-attach-point as replacement for dojoAttachEvent and dojoAttachPoint to register attach points and attach event handlers. And finally, we can also use a data-dojo-event to define the event to register for <code>&lt;script type="dojo/method"&gt;</code> scripts.</p>
<h2>When to go Declarative</h2>
<p>Even when leveraging the new HTML5-valid custom attributes, there are still pros and cons to declaring widgets within HTML instead of with JavaScript. Declaring JavaScript components from within HTML introduces semantic impurity since the HTML is no longer purely semantic markup, but includes tight coupling to particular visual components. The declarative approach also incurs extra CPU cycles because dojo.parse() must traverse the DOM tree to find elements with Dojo custom attributes. Programmatic instantiation avoids unnecessary cycles and preserves semantic purity of HTML. However, markup-based widget declaration still has a powerful advantage by allowing us to define and create a widget in a single place, facilitating rapid application development and progressive enhancement with minimal effort.</p>
<p>Dojo still provides backward compatibility with the old custom attributes, but the new data-dojo-* attributes leverage the new HTML5 specification to provide fast and efficient declaration of widgets and configuration with clean and validating syntax.</p>


<p>Related posts:<ol><li><a href='http://www.sitepen.com/blog/2007/11/02/html-widget-prototyping-with-the-dojo-toolkit/' rel='bookmark' title='Permanent Link: HTML Widget Prototyping with the Dojo Toolkit'>HTML Widget Prototyping with the Dojo Toolkit</a></li>
<li><a href='http://www.sitepen.com/blog/2008/05/27/dojo-charting-event-support-has-landed/' rel='bookmark' title='Permanent Link: Dojo Charting: Event Support Has Landed!'>Dojo Charting: Event Support Has Landed!</a></li>
<li><a href='http://www.sitepen.com/blog/2009/11/05/dijit-prepackaged/' rel='bookmark' title='Permanent Link: Dijit: Prepackaged'>Dijit: Prepackaged</a></li>
</ol></p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/01/19/html5-data-dojo-attribute-support/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Year of Dojo is Here!</title>
		<link>http://www.sitepen.com/blog/2012/01/17/the-year-of-dojo-is-here/</link>
		<comments>http://www.sitepen.com/blog/2012/01/17/the-year-of-dojo-is-here/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 16:19:43 +0000</pubDate>
		<dc:creator>Angela Segovia</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Support]]></category>
		<category><![CDATA[dgrid]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=3833</guid>
		<description><![CDATA[<p>Welcome to 2012 – The Year of Dojo!  We are expecting an amazing year! Make SitePen your one stop shop for all of your web application needs; Dojo workshops, JavaScript support and web app development.  Together, with SitePen, you will meet your 2012 goals!  When you’re happy, so are we. Learn Dojo - We are dedicated [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>


Related posts:<ol><li><a href='http://www.sitepen.com/blog/2012/01/30/eleven-trends-for-2012-the-year-of-dojo/' rel='bookmark' title='Permanent Link: Eleven Trends for 2012: The Year of Dojo'>Eleven Trends for 2012: The Year of Dojo</a></li>
<li><a href='http://www.sitepen.com/blog/2011/12/05/we%e2%80%99ve-unofficially-declared-2012-as-the-year-of-dojo/' rel='bookmark' title='Permanent Link: We’ve (unofficially) declared 2012 as the Year of Dojo!'>We’ve (unofficially) declared 2012 as the Year of Dojo!</a></li>
<li><a href='http://www.sitepen.com/blog/2012/02/01/dojo-1-7-tutorial-update/' rel='bookmark' title='Permanent Link: Dojo 1.7 Tutorial Update'>Dojo 1.7 Tutorial Update</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Welcome to 2012 – The Year of Dojo!  We are expecting an amazing year! Make SitePen your one stop shop for all of your web application needs; <a title="Dojo workshops" href="http://www.sitepen.com/services/workshops/index.php" target="_blank">Dojo workshops</a>, <a title="JavaScript Support" href="https://www.sitepen.com/services/support.php" target="_blank">JavaScript support</a> and <a title="Web App Development" href="http://www.sitepen.com/services/development.php" target="_blank">web app development</a>.  Together, with SitePen, you will meet your 2012 goals!  When you’re happy, so are we.</p>
<p><strong>Learn Dojo </strong>- We are <em>dedicated</em> to providing you with the highest quality Dojo Toolkit workshops in the industry.  Whether you want to learn the basics of Dojo or sharpen your Dojo skills, we have a workshop just for you.  All of our Dojo Workshops are taught by our Dojo experts.  We <em>promise</em> you won’t be subjected to listening to some trainer who can’t live without his slides.  Wondering if our Dojo Workshops will cover <a title="Dojo 1.7" href="http://dojotoolkit.org/" target="_blank">Dojo 1.7</a>?  The answer is yes!</p>
<p>Ready to learn Dojo?  <a title="SitePen Dojo Workshops" href="http://www.sitepen.com/services/workshops/index.php" target="_blank">Check out our full list of 2012 workshop dates and locations</a>.  Sign up for any of our 2012 Dojo Workshops by January 31, 2012 with promo code IHEARTDOJO and get 10% off!</p>
<p><strong>Here to help </strong>- Did you know we also have support plans to fit every size and every need?  No matter which support plan you choose, our expert engineers will help you by <em>answering questions, resolving bugs, and solving problems</em>. We offer no-hassle ways to get in touch with your SitePen Support team, which means no waiting on hold, or having to explain your issue over and over again until you get to the right person.  With us, you always have access to the <em>right people</em>. If your project runs in to a critical issue, our <em>expert SitePen engineers</em> will jump in to help you quickly get back on track. Oh, and yes, all of our support plans include support for <a title="dGrid" href="http://dojotoolkit.org/blog/dojo-1-7-released" target="_blank">dGrid </a>and <a title="Dojo 1.7" href="http://dojotoolkit.org/" target="_blank">Dojo 1.7</a>! Having a SitePen Support plan is preparing for possibilities.  Even football teams have backup quarterbacks.</p>
<p>From 2 support hours to 200 support hours, SitePen has a support plan to fit your needs.  <a title="SitePen Support" href="https://www.sitepen.com/services/support.php" target="_blank">Take a look</a>!</p>
<p><strong>Perfect match of design and development </strong>- We are your one stop shop for your next project, including mobile web applications! Our expert team will take your web application from concept to launch.  We&#8217;ve mastered the front end and are here to help you build powerful, simple, and usable web apps, every single time.</p>
<p>Whether you need a traditional web application, mobile web application or installable mobile web app store application, <a title="SitePen Development" href="http://www.sitepen.com/services/development.php" target="_blank">SitePen can help</a>!</p>
<p>Still not sure how we can help you?  <a title="Contact SitePen" href="http://www.sitepen.com/contact/" target="_blank">Contact us today!</a> (You can even call us if you want.)  Celebrate 2012 &#8211; The Year of Dojo!</p>


<p>Related posts:<ol><li><a href='http://www.sitepen.com/blog/2012/01/30/eleven-trends-for-2012-the-year-of-dojo/' rel='bookmark' title='Permanent Link: Eleven Trends for 2012: The Year of Dojo'>Eleven Trends for 2012: The Year of Dojo</a></li>
<li><a href='http://www.sitepen.com/blog/2011/12/05/we%e2%80%99ve-unofficially-declared-2012-as-the-year-of-dojo/' rel='bookmark' title='Permanent Link: We’ve (unofficially) declared 2012 as the Year of Dojo!'>We’ve (unofficially) declared 2012 as the Year of Dojo!</a></li>
<li><a href='http://www.sitepen.com/blog/2012/02/01/dojo-1-7-tutorial-update/' rel='bookmark' title='Permanent Link: Dojo 1.7 Tutorial Update'>Dojo 1.7 Tutorial Update</a></li>
</ol></p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/01/17/the-year-of-dojo-is-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Native JSON Parsing in Dojo</title>
		<link>http://www.sitepen.com/blog/2012/01/05/native-json-parsing-in-dojo/</link>
		<comments>http://www.sitepen.com/blog/2012/01/05/native-json-parsing-in-dojo/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 15:05:38 +0000</pubDate>
		<dc:creator>Kris Zyp</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[dojo/json]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=2259</guid>
		<description><![CDATA[<p>Dojo 1.7 introduces a new JSON module available at dojo/json. This differs from the legacy dojo.fromJson and dojo.toJson in that it is based on the new native JSON API in the JavaScript language (introduced in EcmaScript 5). It also delegates to the native JSON parser and serializer when they are available, providing the fastest possible [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>


Related posts:<ol><li><a href='http://www.sitepen.com/blog/2011/06/14/how-do-you-serialize-dates-from-forms-to-json-with-dojo/' rel='bookmark' title='Permanent Link: How Do You Serialize Dates from Forms to JSON with Dojo?'>How Do You Serialize Dates from Forms to JSON with Dojo?</a></li>
<li><a href='http://www.sitepen.com/blog/2008/06/17/json-referencing-in-dojo/' rel='bookmark' title='Permanent Link: JSON Referencing in Dojo'>JSON Referencing in Dojo</a></li>
<li><a href='http://www.sitepen.com/blog/2008/10/31/json-schema/' rel='bookmark' title='Permanent Link: JSON Schema in Dojo'>JSON Schema in Dojo</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Dojo 1.7 introduces a new JSON module available at <code>dojo/json</code>. This differs from the legacy <code>dojo.fromJson</code> and <code>dojo.toJson</code> in that it is based on the new native JSON API in the JavaScript language (introduced in EcmaScript 5). It also delegates to the native JSON parser and serializer when they are available, providing the fastest possible execution for any given browser.</p>
<p><span id="more-2259"></span></p>
<p>Using the new API is very easy, and should be familiar if you have used json.org&#8217;s library or the browser native library. We get the JSON object from the &#8220;dojo/json&#8221; module and then can use the parse and stringify methods. For example, to parse JSON:</p>
<pre lang="javascript">define(["dojo/json"], function(JSON){
  var jsonStr = '{"name": "value"}';
  var object = JSON.parse(jsonStr);
  object.name -&gt; "value";
});</pre>
<p>Again, note that this will use the native parsing facilities of the browser/platform if they are available, otherwise they will use the library implementation.</p>
<p>To reverse the process and serialize an object to JSON:</p>
<pre lang="javascript">define(["dojo/json"], function(JSON){
  var object = {"name": "value"};
  var jsonStr = JSON.stringify(object);
  jsonStr -&gt; '{"name": "value"}'
});</pre>
<h3>Date Serialization</h3>
<p>The new JSON module now properly serializes dates. While previously, dojo.fromJson <a href="http://bugs.dojotoolkit.org/ticket/5726">incorrectly serialized dates as &#8220;{}&#8221;</a>, serialization now conforms to native date serialization. Dates are serialized to the standard ISO format in UTC.</p>
<pre lang="javascript">JSON.stringify({now:new Date()}) -&gt; "{"now":"2011-06-13T19:02:19.650Z"}"</pre>
<h3>Native Performance</h3>
<h3>Staying Light</h3>
<p>The new JSON module uses <code>has()</code> branching to determine whether or not to use the native JSON capability or not. This is not only a solid feature-detection based approach, but it means when you leverage <a href="http://www.sitepen.com/blog/?p=2203">browser-specific builds</a>, the module is only a few bytes for modern browsers, particularly valuable for mobile applications.</p>
<p>The legacy <code>dojo.fromJson</code> and <code>dojo.toJson</code> will still be available in Dojo base, but it is recommended that you use <code>parse</code> and <code>stringify</code> functions from <code>dojo/json</code> now for better performance and standards conformance.</p>


<p>Related posts:<ol><li><a href='http://www.sitepen.com/blog/2011/06/14/how-do-you-serialize-dates-from-forms-to-json-with-dojo/' rel='bookmark' title='Permanent Link: How Do You Serialize Dates from Forms to JSON with Dojo?'>How Do You Serialize Dates from Forms to JSON with Dojo?</a></li>
<li><a href='http://www.sitepen.com/blog/2008/06/17/json-referencing-in-dojo/' rel='bookmark' title='Permanent Link: JSON Referencing in Dojo'>JSON Referencing in Dojo</a></li>
<li><a href='http://www.sitepen.com/blog/2008/10/31/json-schema/' rel='bookmark' title='Permanent Link: JSON Schema in Dojo'>JSON Schema in Dojo</a></li>
</ol></p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/01/05/native-json-parsing-in-dojo/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Learn about AMD at SitePen&#8217;s Dojo Workshops</title>
		<link>http://www.sitepen.com/blog/2011/12/08/learn-about-amd-at-sitepens-dojo-workshops/</link>
		<comments>http://www.sitepen.com/blog/2011/12/08/learn-about-amd-at-sitepens-dojo-workshops/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 21:49:51 +0000</pubDate>
		<dc:creator>Angela Segovia</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=3761</guid>
		<description><![CDATA[<p>If you’ve been reading about Dojo 1.7, the first thing you’re probably wondering is, what is this AMD thing that everyone is talking about? Check out Dylan&#8217;s post at the Dojo Toolkit blog to &#8220;Learn more about AMD!&#8220;. In addition to the useful links Dylan provides, you can also learn more about AMD at a SitePen [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>


Related posts:<ol><li><a href='http://www.sitepen.com/blog/2011/03/11/dojo-public-workshops/' rel='bookmark' title='Permanent Link: Dojo Public Workshops'>Dojo Public Workshops</a></li>
<li><a href='http://www.sitepen.com/blog/2011/10/19/sitepen-at-blackberry-devcon-americas-2011/' rel='bookmark' title='Permanent Link: SitePen at BlackBerry DevCon Americas 2011'>SitePen at BlackBerry DevCon Americas 2011</a></li>
<li><a href='http://www.sitepen.com/blog/2011/10/17/sitepen-dojo-skills-seattle/' rel='bookmark' title='Permanent Link: SitePen. Dojo Skills. Seattle.'>SitePen. Dojo Skills. Seattle.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you’ve been reading about Dojo 1.7, the first thing you’re probably wondering is, what is this AMD thing that everyone is talking about? Check out Dylan&#8217;s post at the Dojo Toolkit blog to &#8220;<a title="Learn more about AMD" href="http://dojotoolkit.org/blog/learn-more-about-amd" target="_blank">Learn more about AMD!</a>&#8220;.</p>
<p>In addition to the useful links Dylan provides, you can also learn more about AMD at a <a title="SitePen Dojo Workshops" href="http://www.sitepen.com/services/workshops/index.php">SitePen Dojo Workshop</a>.  AMD + Dojo 1.7= Awesomeness.</p>


<p>Related posts:<ol><li><a href='http://www.sitepen.com/blog/2011/03/11/dojo-public-workshops/' rel='bookmark' title='Permanent Link: Dojo Public Workshops'>Dojo Public Workshops</a></li>
<li><a href='http://www.sitepen.com/blog/2011/10/19/sitepen-at-blackberry-devcon-americas-2011/' rel='bookmark' title='Permanent Link: SitePen at BlackBerry DevCon Americas 2011'>SitePen at BlackBerry DevCon Americas 2011</a></li>
<li><a href='http://www.sitepen.com/blog/2011/10/17/sitepen-dojo-skills-seattle/' rel='bookmark' title='Permanent Link: SitePen. Dojo Skills. Seattle.'>SitePen. Dojo Skills. Seattle.</a></li>
</ol></p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2011/12/08/learn-about-amd-at-sitepens-dojo-workshops/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Touching and Gesturing on iPhone, Android, and More</title>
		<link>http://www.sitepen.com/blog/2011/12/07/touching-and-gesturing-on-iphone-android-and-more/</link>
		<comments>http://www.sitepen.com/blog/2011/12/07/touching-and-gesturing-on-iphone-android-and-more/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 17:46:52 +0000</pubDate>
		<dc:creator>Colin Snover</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=3425</guid>
		<description><![CDATA[<p>One of the most important parts of creating an effective and intuitive user interface on touch-enabled smartphones has nothing to do with visual appearance—instead, it has to do with creating an interface that properly responds to user input based on touch. For Web applications, this means replacing mouse events with touch events. In Dojo 1.7, [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>


Related posts:<ol><li><a href='http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/' rel='bookmark' title='Permanent Link: Touching and Gesturing on the iPhone'>Touching and Gesturing on the iPhone</a></li>
<li><a href='http://www.sitepen.com/blog/2008/04/23/sdk-showdown-iphone-vs-android/' rel='bookmark' title='Permanent Link: SDK showdown: iPhone vs. Android'>SDK showdown: iPhone vs. Android</a></li>
<li><a href='http://www.sitepen.com/blog/2007/07/02/cometd-on-the-iphone/' rel='bookmark' title='Permanent Link: Cometd on the iPhone'>Cometd on the iPhone</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>One of the most important parts of creating an effective and intuitive user interface on touch-enabled smartphones has nothing to do with visual appearance—instead, it has to do with creating an interface that properly responds to user input based on touch. For Web applications, this means replacing mouse events with touch events. In Dojo 1.7, new touch APIs help make this process easy.</p>
<p style="font-style: italic;">This is an updated version of the post <a href="http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/">Touching and Gesturing on the iPhone</a>, published in 2008.</p>
<p><span id="more-3425"></span></p>
<h2>In the beginning…</h2>
<p>Before we discuss the new features in Dojo 1.7 that make touch interfaces easier to create, it helps to understand some of the underlying technology and concepts. With iPhone, Apple introduced two new event concepts: <em>touches</em> and <em>gestures</em>. Touches are important for keeping track of how many fingers are on the screen, where they are, and what they’re doing. Gestures are important for determining what the user is actually doing when they are interacting with the device at a higher level: pinching, rotating, swiping, double-tapping, and so on.</p>
<p>While <em>touch</em> events are available on most platforms (the <a href="http://developer.apple.com/library/IOS/#documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html<br />
">touch event model originally established on iOS</a> has been standardized in the <a href="http://www.w3.org/TR/touch-events/">W3C Touch Events specification</a> and is supported by iOS, Android, and BlackBerry), native <em>gesture</em> events are not available everywhere, and the gesture event API in iOS is limited in the sorts of gestures it supports. The <code>dojox/gesture</code> package steps in to fill these gaps in functionality; we’ll discuss it shortly.</p>
<h2>Touches</h2>
<p>When you put a finger down on the screen, it kicks off the lifecycle of touch events. Each time a new finger touches the screen, a new <code>touchstart</code> event happens. As each finger lifts up, a <code>touchend</code> event happens. If, after touching the screen, you move any of your fingers around, <code>touchmove</code> events happen. If too many fingers are on the screen, or another action (such as a push notification from the phone’s OS) interferes with the touch, a <code>touchcancel</code> event happens.</p>
<p>The following touch events exist:</p>
<ul>
<li><code>touchstart</code>: Occurs when a finger is placed on the screen</li>
<li><code>touchend</code>: Occurs when a finger is removed from the screen</li>
<li><code>touchmove</code>: Occurs when a finger already placed on the screen is moved across the screen</li>
<li><code>touchcancel</code>: Occurs when a touch is cancelled before the finger is actually removed from the screen</li>
</ul>
<p>While it might seem that there should be a 1:1 mapping between a touch event and a mouse event—after all, your finger works much like a cursor—it turns out that <a href="http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/TouchEventClassReference/TouchEvent/TouchEvent.html<br />
"><code>TouchEvent</code></a> objects do not include properties that you might expect to see. For example, <code>pageX</code> and <code>pageY</code> properties are not populated. This is because, with a mouse, you really only have one point of contact: the cursor. With a multi-touch device, though, you could (for example) keep two fingers held down on the left of the screen while you tap the right side of the screen, and all three points are registered.</p>
<p>In order to provide information about all touch points at once, every <code>TouchEvent</code> object has a property containing information about every finger that’s currently touching the screen. It also has two other properties: one which contains a list of information for fingers that originated from the current target node, and one which contains only the information for fingers that are associated with the current event. These properties are:</p>
<ul>
<li><code>touches</code>: A list of information for every finger currently touching the screen</li>
<li><code>targetTouches</code>: Like <code>touches</code>, but is filtered to only the information for finger touches that started out within the same node</li>
<li><code>changedTouches</code>: A list of information for every finger that has changed state due to the event (see below)</li>
</ul>
<p>To better understand what might be in these lists, let&#8217;s go over some examples quickly.</p>
<ul>
<li>When you put one finger down, all three lists will provide the same information.</li>
<li>When you put a second finger down, <code>touches</code> will contain two items, one for each finger. <code>targetTouches</code> will have two items only if the second finger was placed in the same node as the first finger (otherwise it will only contain the second finger). <code>changedTouches</code> will only have information related to the second finger, because it’s what triggered the event.</li>
<li>If you put two fingers down at exactly the same time, you will get two items in <code>changedTouches</code>, one for each finger that triggered the event.</li>
<li>If you move your fingers, the only list that will change is <code>changedTouches</code>. It will contain information about the finger or fingers that moved.</li>
<li>When you lift a finger, it will be removed from <code>touches</code> and <code>targetTouches</code>, and will appear in <code>changedTouches</code>, since it’s what caused the event.</li>
<li>Removing your last finger will leave <code>touches</code> and <code>targetTouches</code> empty, and <code>changedTouches</code> will contain information about the last finger.</li>
</ul>
<p>Using these lists, it is possible to keep very close tabs on what the user is doing. Imagine creating a(nother) Super Mario clone in JavaScript—you’d be able to tell what direction pad the user currently has his or her thumb on, while also being able to watch for when the user wants to jump or shoot a fireball when they touch another virtual button elsewhere.</p>
<p>So far, we’ve been discussing lists of information about fingers on the screen, but we haven’t talked about what this information looks like. The objects contained in the touches lists have properties similar to what you&#8217;d see on a <code>MouseEvent</code> object. The following is the full list of properties for these objects:</p>
<ul>
<li><code>clientX</code>: X coordinate of touch relative to the viewport (excludes scroll offset)</li>
<li><code>clientY</code>: Y coordinate of touch relative to the viewport (excludes scroll offset)</li>
<li><code>screenX</code>: Relative to the screen</li>
<li><code>screenY</code>: Relative to the screen</li>
<li><code>pageX</code>: Relative to the full page (includes scrolling)</li>
<li><code>pageY</code>: Relative to the full page (includes scrolling)</li>
<li><code>identifier</code>: An identifying number, unique to each touch point (finger) currently active on the screen</li>
<li><code>target</code>: The DOM node that the finger is touching</li>
</ul>
<p>One of the annoyances of writing Web applications for smartphones has been that even if you set a viewport for your application, dragging your finger around will move the page. Fortunately, the <code>touchmove</code> event object has a <code><a href="http://developer.mozilla.org/en/docs/DOM:event.preventDefault">preventDefault</a></code> method that can be used to keep the page still.</p>
<h3>Drag and drop with the Touch API</h3>
<p>Creating drag and drop functionality on touchscreen devices is made easier due to the fact that <code>touchmove</code> events only fire when a finger is already touching the screen’s surface. This means we don’t need to track button states like we would with a <code>mousemove</code> event. A basic drag and drop implementation, then, can look as simple as this:</p>
<pre lang="javascript">node.addEventListener("touchmove", function(event){
    // Only deal with one finger
    if(event.touches.length == 1){
        // Get the information for finger #1
        var touch = event.touches[0],
            // Find the style object for the node the drag started from
            style = touch.target.style;
        // Position the element under the touch point
        style.position = "absolute";
        style.left = touch.pageX + "px";
        style.top = touch.pageY + "px";
    }
}, false);</pre>
<h2>Better touching in Dojo 1.7</h2>
<p>One of the problems with using low-level touch events is that, if you are creating an application that you want to function on both touch-enabled <em>or</em> mouse-enabled devices, you end up needing to set up two sets of event listeners. The new <a href="http://dojotoolkit.org/reference-guide/dojo/touch.html"><strong>dojo/touch</strong></a> module in Dojo 1.7 normalizes these two types of events, using touch events where available and falling back to mouse events on other platforms in order to provide device-neutral events. Using it is just as easy as listening for a regular event, except instead of passing a string for the event name, you instead pass a function in place of the event name:</p>
<pre lang="javascript">require([ "dojo", "dojo/touch" ], function(dojo, touch){
    dojo.connect(dojo.byId("myElement"), touch.press, function(event){
        // handle a mousedown/touchstart event
    });
    dojo.connect(dojo.byId("myElement"), touch.release, function(event){
        // handle a mouseup/touchend event
    });
});</pre>
<h2>Gestures</h2>
<p>On iOS devices, a gesture event occurs any time two or more fingers are touching the screen. If any finger lands in a node you are listening for gesture events on (<code>gesturestart</code>, <code>gesturechange</code>, <code>gestureend</code>), you’ll receive the corresponding gesture events.</p>
<p>Gesture events provide a <a href="http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/GestureEventClassReference/GestureEvent/GestureEvent.html<br />
"><code>GestureEvent</code></a> object with these properties:</p>
<ul>
<li><code>rotation</code>: The amount the user has rotated their fingers, in degrees.</li>
<li><code>scale</code>: A multiplier indicating the amount the user has pinched or pushed their fingers, where numbers larger than 1 indicate a push, and numbers smaller than 1 indicate a pinch.</li>
</ul>
<p>When listening for both gesture events and touch events, the event pattern looks like this:</p>
<ol>
<li><code>touchstart</code> for finger 1.</li>
<li><code>gesturestart</code> when the second finger touches the surface.</li>
<li><code>touchstart</code> for finger 2.</li>
<li><code>gesturechange</code> sent every time both fingers move while still touching the surface.</li>
<li><code>gestureend</code> when the second finger leaves the surface.</li>
<li><code>touchend</code> for finger 2.</li>
<li><code>touchend</code> for finger 1.</li>
</ol>
<h3>Resizing and rotating with the Gestures API</h3>
<p>Using the CSS <code>transform</code>, <code>width</code>, and <code>height</code> properties, we can easily rotate and scale any element in response to these gestures.</p>
<pre lang="javascript">var width = 100,
    height = 200,
    rotation = 0;

node.addEventListener("gesturechange", function(event){
    var style = event.target.style;
    // scale and rotation are relative values,
    // so we wait to change our variables until the gesture ends
    style.width = (width * event.scale) + "px";
    style.height = (height * event.scale) + "px";
    style.webkitTransform = "rotate(" + ((rotation
      + event.rotation) % 360) + "deg)";
}, false);

node.addEventListener("gestureend", function(event){
    // Update the values for the next time a gesture happens
    width *= event.scale;
    height *= event.scale;
    rotation = (rotation + event.rotation) % 360;
}, false);</pre>
<h2>Better gestures with Dojo 1.7</h2>
<p>Dojo 1.7 includes a new package, <a href="http://dojotoolkit.org/reference-guide/dojox/gesture.html"><strong>dojox/gesture</strong></a>, that provides functionality for handling more complex gestures on touch-sensitive devices. In addition to defining a basic framework for creating your own custom gestures through extension of the <code>dojox/gesture/Base</code> module, it comes with built-in support for several common gestures, including tap, tap and hold, double tap, and swipe.</p>
<p>Using dojox gestures couldn’t be much simpler. Just like dojo/touch, in order to listen for a gesture, you simply connect to a gesture event using <code>dojo.connect</code>, passing the gesture function in place of the event name:</p>
<pre lang="javascript">require([ "dojo", "dojox/gesture/swipe", "dojox/gesture/tap" ],
        function(dojo, swipe, tap){
    dojo.connect(dojo.byId("myElement"), swipe, function(event){
        // handle swipe event
    });

    dojo.connect(dojo.byId("myElement"), tap.doubletap, function(event){
        // handle double tap event
    });
});</pre>
<p>In time, dojox/gesture will be extended to include more complex event types and behaviors, such as pinching and zooming. For now, it provides several new events that were difficult to handle before, as well as an excellent framework that can be used to create complex gesture events across all platforms.</p>


<p>Related posts:<ol><li><a href='http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/' rel='bookmark' title='Permanent Link: Touching and Gesturing on the iPhone'>Touching and Gesturing on the iPhone</a></li>
<li><a href='http://www.sitepen.com/blog/2008/04/23/sdk-showdown-iphone-vs-android/' rel='bookmark' title='Permanent Link: SDK showdown: iPhone vs. Android'>SDK showdown: iPhone vs. Android</a></li>
<li><a href='http://www.sitepen.com/blog/2007/07/02/cometd-on-the-iphone/' rel='bookmark' title='Permanent Link: Cometd on the iPhone'>Cometd on the iPhone</a></li>
</ol></p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2011/12/07/touching-and-gesturing-on-iphone-android-and-more/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dojo Drag’n’Drop Redux</title>
		<link>http://www.sitepen.com/blog/2011/12/05/dojo-drag-n-drop-redux/</link>
		<comments>http://www.sitepen.com/blog/2011/12/05/dojo-drag-n-drop-redux/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 20:33:14 +0000</pubDate>
		<dc:creator>Colin Snover</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[dnd]]></category>
		<category><![CDATA[dojo.dnd]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=3198</guid>
		<description><![CDATA[<p>dojo/dnd is one of Dojo’s core APIs and is designed to manage the process of dragging and dropping items between two or more containers. It offers advanced features like multiple selections, item acceptance filtering on drop targets, and other behavioral tweaks. Let’s learn how to use it! This is an updated version of the original [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>


Related posts:<ol><li><a href='http://www.sitepen.com/blog/2008/06/10/dojo-drag-and-drop-1/' rel='bookmark' title='Permanent Link: Dojo Drag and Drop, Part 1: dojo.dnd'>Dojo Drag and Drop, Part 1: dojo.dnd</a></li>
<li><a href='http://www.sitepen.com/blog/2009/04/16/queued-drag-and-drop-in-the-queue/' rel='bookmark' title='Permanent Link: Queued: Drag and Drop in the Queue'>Queued: Drag and Drop in the Queue</a></li>
<li><a href='http://www.sitepen.com/blog/2008/10/24/inside-dojo-dnd-drag-handles/' rel='bookmark' title='Permanent Link: Inside Dojo DnD: Drag Handles'>Inside Dojo DnD: Drag Handles</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><strong>dojo/dnd</strong> is one of Dojo’s core APIs and is designed to manage the process of dragging and dropping items between two or more containers. It offers advanced features like multiple selections, item acceptance filtering on drop targets, and other behavioral tweaks. Let’s learn how to use it!</p>
<p style="font-style: italic;">This is an updated version of the original article, <a href="http://www.sitepen.com/blog/2008/06/10/dojo-drag-and-drop-1/">Dojo Drag and Drop, Part 1</a>, published in 2008.</p>
<p><span id="more-3198"></span></p>
<h2>Simple Single Source DnD</h2>
<p>Meet Dylan. Collecting junk is his passion. A while back, he decided that he needed to get rid of some of it to make room for more interesting junk, so he got a booth at the local farmers’ market and started a small junk outlet business. Like most people passionate about sharing their junk with the world, he decided to open an online storefront. <img style="float: right; margin: 20px 0 20px 6px;" src="/labs/code/dnd/intro/dnd/images/blog/dylans-original.jpg" alt="Dylan’s Original Junk Outlet" /> His brother, currently working towards a degree in Marketing, convinced him that he needed to brand himself as a form of differentiation; thus was born <em>Dylan’s Original</em>. He decided that his best bet would be to create a user experience so ridiculously awesome that people wouldn’t be able to help buying his junk. That’s where we come in. To demonstrate drag and drop techniques, we’ll help build a mockup of <em>Dylan’s Original Junk Outlet</em>.</p>
<p>Let’s start with the basics. Just about the easiest way to get drag and drop working is to demonstrate a single list that the user can reorder dynamically. First, we’ll create our page skeleton, using Dojo from the <a href="https://code.google.com/apis/libraries/devguide.html#dojo">Google CDN</a> spiced up with a bit of CSS. <a href="http://sitepen.github.com/sp-dnd-demo/0-dnd.html">View the starting point</a>.</p>
<p>As you can see, we’re starting with a simple wish list:</p>
<pre lang="html4strict">
&lt;div id="store">
&lt;div class="wishlistContainer">
&lt;h2>Wishlist&lt;/h2>
&lt;ol id="wishlistNode" class="container">
	&lt;li>Wrist watch&lt;/li>
	&lt;li>Life jacket&lt;/li>
	&lt;li>Toy bulldozer&lt;/li>
	&lt;li>Vintage microphone&lt;/li>
	&lt;li>TIE fighter&lt;/li>
&lt;/ol>
&lt;/div>
&lt;/div></pre>
<h3>The DnD Workhorse, dojo/dnd/Source</h3>
<p><img style="float: right; position:relative; z-index:2; margin: 0 0 10px 10px;" src="/labs/code/dnd/intro/dnd/images/blog/wishlist-1.jpg" alt="An online store wishlist" /><br />
 To enable drag and drop, dojo/dnd gives us a class called <a href="http://dojotoolkit.org/api/dojo/dnd/Source">Source</a>, which is basically just what it sounds like: a source for dragged items (as well as a target for dropped items). To instantly turn a DOM node into such a source, create a dojo/dnd/Source out of it:</p>
<pre lang="javascript">require([ "dojo/dnd/Source",
	"dojo/domReady!" ],
    function(Source){
    var wishlist =
        new Source("wishlistNode");
    wishlist.insertNodes(false, [
        "Wrist watch",
        "Life jacket",
        "Toy bulldozer",
        "Vintage microphone",
        "TIE fighter"
    ]);
});</pre>
<p>That’s all there is to it! <a href="http://sitepen.github.com/sp-dnd-demo/1-dnd.html">View the single container DnD example</a>. If you like to create UIs declaratively, instantiate the list in markup with <code>data-dojo-type="dojo.dnd.Source"</code> and use <code>class="dojoDndItem"</code> on draggable child nodes, like so:</p>
<pre lang="html4strict">
&lt;ol data-dojo-type="dojo.dnd.Source" id="wishlistNode" class="container">
	&lt;li class="dojoDndItem">Wrist watch&lt;/li>
	&lt;li class="dojoDndItem">Life jacket&lt;/li>
	&lt;li class="dojoDndItem">Toy bulldozer&lt;/li>
	&lt;li class="dojoDndItem">Vintage microphone&lt;/li>
	&lt;li class="dojoDndItem">TIE fighter&lt;/li>
&lt;/ol>
</pre>
<p>Of course, when working declaratively, you have to make sure to add <code>dojo/parser</code> and <code>dojo/dnd/Source</code> to the loader’s <code>deps</code> list and enable <code>parseOnLoad</code>, but there you go. <a href="http://sitepen.github.com/sp-dnd-demo/1-dnd.markup.html">View the demo, declarative style</a>.</p>
<p>What can you turn into a DnD source? Well sheesh, what <em>can’t</em> you turn into a DnD source? Take a look at the <a href="http://dojotoolkit.org/reference-guide/dojo/dnd.html">reference guide</a>. The Source class will take into account the node type of your container when creating child nodes:</p>
<ul>
<li>If the container is <code>&lt;div></code> or <code>&lt;p></code>, it will create <code>&lt;div></code> nodes.</li>
<li>If the container is <code>&lt;ul></code> or <code>&lt;ol></code>, it will create <code>&lt;li></code> nodes.</li>
<li>If the container is a <code>&lt;table></code>, it will create a set of <code>&lt;tr>&lt;td></code> and add it to the table’s <code>&lt;tbody></code>.</li>
<li>All other times, it will create <code>&lt;span></code> nodes.</li>
</ul>
<p>So basically, turn whatever you want into a Source, and Dojo will intelligently set up your DOM. Pretty nifty! Out of the box, dojo/dnd/Source has quite a lot of functionality baked in:</p>
<ul>
<li><strong>Multiple selection.</strong> Each container has the notion of a selection; click on an item and it’s “selected”. ⌘-click/ctrl-click or shift-click do multiple selection, just like in a regular application.</li>
<li><strong>Child node introspection.</strong> In addition to the <code>insertNodes</code> method demonstrated above, the Source provides a few methods to work with the list of child nodes:
<ul>
<li><code>getAllNodes()</code> – returns a Dojo <code>NodeList</code> of the contained items.</li>
<li><code>forInItems(fn, ctx)</code> – calls <code>fn</code> in the context of <code>ctx</code> for each contained node. Similar to <code>dojo.forEach</code>.</li>
<li><code>selectNone()</code>, <code>selectAll()</code>, <code>getSelectedNodes()</code>, <code>deleteSelectedNodes()</code> – just what they sound like: methods for manipulating the selection state.</li>
<li>plus a few other things you can hook into for customizing the way the internal list gets handled. See the <a href="http://dojotoolkit.org/reference-guide/dojo/dnd.html">reference guide</a> for details.</li>
</ul>
</li>
<li><strong>Copy vs. move semantics.</strong> By default, nodes are moved when you drag them around. However, holding ⌘/ctrl and dragging performs a copy operation instead, similar to most desktop file managers. This is useful when you don’t want your DnD source to change in response to a user’s drag operations.</li>
<li><strong>Drag cancellation.</strong> This isn’t technically a property of the Source, but it’s worth noting here that pressing the Esc key cancels the current drag operation. You can do this programmatically, too, if you need to.</li>
<li><strong>Automatic avatar creation.</strong> The dojo/dnd framework uses “avatars” to represent the nodes you drag around. It creates these for you automatically, based on the data itself. You can customize this, of course; more on that later.</li>
</ul>
<p><img style="float: right; margin: 0 0 10px 10px;" src="/labs/code/dnd/intro/dnd/images/blog/catalog-2.jpg" alt="An online store product list, mid-drag" /></p>
<h2>Using Multiple Sources</h2>
<p>Of course, if you’re only using a single Source in your application, the move/copy distinction is only useful for duplicating nodes in the list. Let’s help Dylan expand. Check out <a href="http://sitepen.github.com/sp-dnd-demo/2-dnd.html">Dylan’s Original Junk Outlet, version 2</a> (and the <a href="http://sitepen.github.com/sp-dnd-demo/2-dnd.markup.html">declarative version</a>).</p>
<p>What have we changed? Well, for starters, we now have three Sources: the Catalog, the Cart, and the Wishlist. Now you can drag items back and forth between them to see multiple-container dojo/dnd in action. Some items are marked as “out of stock” (more on this in a bit), and… hey, some of these items aren’t junk at all—they’re food! Yes, while we weren’t looking, Dylan merged his junk outlet with <em>Dylan’s Nutritious Dietarium</em>, the company he uses to unload what he doesn’t eat from his garden.</p>
<h3>DnD Item Types</h3>
<p>The biggest change here is the introduction of item types. Notice the new <code>accept</code> and <code>type</code> properties:</p>
<pre lang="javascript">require([ "dojo/dom-class", "dojo/dnd/Source", "dojo/domReady!" ],
		function(domClass, Source){
	var catalog = new Source("catalogNode",
		{ accept: [ "inStock", "outOfStock" ] });
	catalog.insertNodes(false, [
		{ data: "Wrist watch",        type: [ "inStock" ] },
		{ data: "Life jacket",        type: [ "inStock" ] },
		{ data: "Toy bulldozer",      type: [ "inStock" ] },
		{ data: "Vintage microphone", type: [ "outOfStock" ] },
		{ data: "TIE fighter",        type: [ "outOfStock" ] },
		{ data: "Apples",             type: [ "inStock" ] },
		{ data: "Bananas",            type: [ "inStock" ] },
		{ data: "Tomatoes",           type: [ "outOfStock" ] },
		{ data: "Bread",              type: [ "inStock" ] }
	]);
	catalog.forInItems(function(item, id, map){
		domClass.add(id, item.type[0]);
	});

	var cart = new Source("cartNode", { accept: [ "inStock" ] });
	var wishlist = new Source("wishlistNode",
		{ accept: [ "inStock", "outOfStock" ] });
});</pre>
<p>In the declarative version, it looks like this:</p>
<pre lang="html4strict">&lt;div class="catalogContainer">
    &lt;h2>Catalog&lt;/h2>
    &lt;ul data-dojo-type="dojo.dnd.Source" id="catalogNode" class="container"
		data-dojo-props="accept: [ 'inStock', 'outOfStock' ]" >
      &lt;li class="dojoDndItem inStock" dndType="inStock">Wrist watch&lt;/li>
      &lt;li class="dojoDndItem inStock" dndType="inStock">Life jacket&lt;/li>
      &lt;li class="dojoDndItem inStock" dndType="inStock">Toy bulldozer&lt;/li>
      &lt;li class="dojoDndItem outOfStock" dndType="outOfStock">
		Vintage microphone&lt;/li>
      &lt;li class="dojoDndItem outOfStock" dndType="outOfStock">
		TIE fighter&lt;/li>
      &lt;li class="dojoDndItem inStock" dndType="inStock">Apples&lt;/li>
      &lt;li class="dojoDndItem inStock" dndType="inStock">Bananas&lt;/li>
      &lt;li class="dojoDndItem outOfStock" dndType="outOfStock">
		Tomatoes&lt;/li>
      &lt;li class="dojoDndItem inStock" dndType="inStock">Bread&lt;/li>
    &lt;/ul>
&lt;/div>

&lt;div class="cartContainer">
    &lt;h2>Cart&lt;/h2>
    &lt;ol data-dojo-type="dojo.dnd.Source" id="cartNode" class="container"
		data-dojo-props="accept: [ 'inStock' ]" >
    &lt;/ol>
&lt;/div>
&lt;div class="wishlistContainer">
    &lt;h2>Wishlist&lt;/h2>
    &lt;ol data-dojo-type="dojo.dnd.Source" id="wishlistNode"
		data-dojo-props="accept: [ 'inStock', 'outOfStock' ]"
		class="container">
    &lt;/ol>
&lt;/div></pre>
<p>Each DnD item can be given one or more types. In JavaScript, this is done by setting the <code>type</code> property of any object you pass to <code>insertNodes</code>. In markup, a comma-separated list of strings in the non-standard <code>dndType</code> attribute is used. Correspondingly, each DnD container can be given a list of item types to accept in the <code>accept</code> property. If left unspecified, the default type for all items and containers is &#8220;text&#8221;.</p>
<p>Here, we’re using the DnD type to denote whether an item is in stock or not, which then determines which items can be dropped where. The Cart only accepts items that are in stock, while the Wishlist accepts anything. If you drag around multiple items at once, you’ll notice that you can only drop a set of items on a container that accepts every type of item in the set—no partial drops allowed!</p>
<p>This is a good start, but there are still a few issues with this demo that need to be addressed:</p>
<ul>
<li>Unless you explicitly invoke copy semantics by pressing the appropriate key, dragging items removes them from the catalog, which doesn’t make much sense for this application.</li>
<li>You can do a copy/drag, but then it becomes easy to duplicate items, which shouldn’t be possible.</li>
<li>Using simple lists like this doesn’t really give a great user experience for an establishment as dignified as <em>Dylan’s Original Junk Outlet / Dylan’s Nutritious Dietarium</em> (DOJO/DND, get it? I kill me (groan)).</li>
</ul>
<p>Let’s start with improving the appearance.</p>
<h2>Customizing Item Creation</h2>
<p>As was discussed above, the default drag and drop implementation is intelligent enough to create nodes according to the context in the DOM. However, if you want to display more than a string of text, the default can be lacking, since all it does is set the child node’s <code>innerHTML</code> property to whatever is assigned to <code>data</code>. Fortunately, dojo/dnd gives us a way to customize this: the <code>creator</code> function.</p>
<p>Since Dylan wants the product catalog to be both prettier and more informative, let’s give each item an image, short description, and quantity indicator. Our data structures will look like this:</p>
<pre lang="javascript">{
    name: "Wrist watch",
    image: "watch.jpg",
    description: "Tell time with Swiss precision",
    quantity: 3
}</pre>
<p>Instead of a string, we’ll pass these objects in the <code>data</code> property of the object passed to <code>insertNodes</code>. To create visual representations of this object, we’ll need a function we can pass to the dojo/dnd/Source’s constructor to transform it into a DOM node:</p>
<pre lang="javascript">define([ "dojo/string", "dojo/dom-construct", "dojo/dom-class",
		"dojo/dnd/Source", "dojo/text!./itemTemplate.html",
		"dojo/text!./avatarTemplate.html" ],
		function(stringUtil, domConstruct, domClass, Source,
			template, avatarTemplate){
	// create the DOM representation for the given item
	function catalogNodeCreator(item, hint){
		var node = domConstruct.toDom(stringUtil.substitute(
			hint === "avatar" ? avatarTemplate : template, {
				name: item.name || "Product",
				imageUrl: "images/" + (item.image || "_blank.gif"),
				quantity: item.quantity || 0,
				description: item.description ? "&lt;br>&lt;span>"
					+ item.description + "&lt;/span>" : ""
			})),

			type = item.quantity ? [ "inStock" ] : [ "outOfStock" ];

		return { node: node, data: item, type: type };
	}
});</pre>
<p>Our item template looks like this:</p>
<pre lang="html">&lt;tr>
	&lt;td class="itemImg dojoDndHandle">&lt;img src="${imageUrl}">&lt;/td>
	&lt;td class="itemText">${name} ${description}&lt;/td>
	&lt;td class="itemQty">${quantity}&lt;/td>
&lt;/tr></pre>
<p>Our avatar template looks like this:</p>
<pre lang="html">&lt;table>
	&lt;tr>
		&lt;td class="itemImg">&lt;img src="${imageUrl}">&lt;/td>
		&lt;td class="itemText">${name}&lt;/td>
	&lt;/tr>
&lt;/table></pre>
<p>Items of note from this code:</p>
<ul>
<li>We’re going to be using tables for our DnD sources now to help improve the presentation.</li>
<li>We’re dynamically choosing the DnD item type based on the quantity provided.</li>
<li>The creator function also accepts a second optional parameter, <code>hint</code>. When this is set to &#8220;avatar&#8221;, we’re being asked to create a DOM representation of the avatar, so our function takes that into account. For us, this means that we skip displaying the description and quantity when we make an avatar, and we put the entire avatar into its own table, since the default node that contains the avatar(s) is itself a table (and we don’t want to ruin our DOM).</li>
</ul>
<p><img style="display: block; margin-left: auto; margin-right: auto; padding: 10px; border: 1px solid #ccc;" src="/labs/code/dnd/intro/dnd/images/blog/catalog-3.jpg" alt="An online store product catalog" /></p>
<p>At this point, we can introduce <a href="http://sitepen.github.com/sp-dnd-demo/3-dnd.html">version 3 of the demo</a> (we’re doing it all programmatically from here on out, so there’s no declarative version). There’s a substantial overhaul in the appearance now thanks to our table-based DnD sources. We’ve also put the wishlist and shopping cart into a couple of <code>dijit/TitlePane</code>s so we can easily toggle their visibility. This change demonstrates a couple of concepts:</p>
<h3>Creating Pure Targets</h3>
<pre lang="javascript">var cart = new Target("cartPaneNode", { accept: [ "inStock" ] });</pre>
<p>We have a new class here: dojo/dnd/Target. This is just a thin wrapper around dojo/dnd/Source that sets <code>this.isSource</code> to false, making it a pure target. You can drop items on it, but can’t drag them back out again! Incidentally, you can freely manipulate this field at runtime on a regular Source object; we’ll do that later on.</p>
<h3>Changing the “Drop Parent”</h3>
<pre lang="javascript">cart.parent = dom.byId("cartNode");</pre>
<p>Here, we’re using the dojo/dnd/Source’s <code>parent</code> property to change which element dragged items are actually inserted into. In this case, we’re changing so that when users drop items on the TitlePane, they’ll actually be inserted to the enclosed <code>&lt;table id="cartNode"></code>.</p>
<p>Our store is starting to look pretty good, but there are still some other things we can do to demonstrate a few more concepts.</p>
<h2>Handling Events</h2>
<p>The drag and drop framework uses Dojo’s pub/sub system to handle event communication. We can polish up a few things if we take advantage of this. For example, it would be nice if we could show the number of items in the wishlist and cart when they’re closed so users don’t need to open them to check. It would also clean things up visually if we cleared the selection states of our containers when we drop an item. By listening for topics, we can do both.</p>
<h3>Building a Drop Handler</h3>
<p>Let’s hook into the drop notification. We can either listen for the DnD pub/sub topics directly or we can connect to event handlers on DnD objects depending upon what sort of action we are performing.</p>
<pre lang="javascript">// sets the count of items in a TitlePane
function setListCount(){
	query(".count", this.node)[0].innerHTML = this.getAllNodes().length;
}

// update the cart’s displayed item count when dropped on
aspect.after(cart, "onDrop", setListCount);

// update the wishlist’s displayed item count when dropped on
aspect.after(wishlist, "onDrop", setListCount);</pre>
<p>Here, we connect to the cart’s and wishlist’s <code>onDrop</code> event to update the number of items in the respective list when an item is dropped. Unlike <code>onDndDrop</code>, which fires for all DnD elements on the page regardless of whether or not they were dropped on, the <code>onDrop</code> event only fires for the target of the drop, so is suitable when you only want to perform an action on a single target.</p>
<h3>Listening Directly to the Topics</h3>
<p>Since I mentioned that you can subscribe to the topics yourself when it makes sense, let’s cook up an example. When you start dragging items around, it’s not completely intuitive where you’re allowed to drop them; you have to keep dragging until the avatar turns green. On top of that, there’s no immediate feedback that your drop was successful. We can create a better experience than that. First, we create some functions to highlight valid targets:</p>
<pre lang="javascript">// highlights available drop targets
function highlightTargets(show, source, nodes){
	domClass.toggle("wishlistPaneNode", "highlight", show);
	domClass.toggle("cartPaneNode", "highlight",
			show &#038;&#038; arrayUtil.every(nodes, function(node){
		return domClass.contains(node, "inStock");
	}));
}

// glows the target of a drop
function glowTarget(source, nodes, copy, target){
	domClass.add(target.node, "glow");
	setTimeout(lang.hitch(domClass, "remove",
		target.node, "glow"), 1000);
}</pre>
<p>Then, in our initialization function, we hook them up to the DnD system:</p>
<pre lang="javascript">// highlight valid drop targets when a drag operation is started
// (/dnd/start)
topic.subscribe("/dnd/start", lang.partial(highlightTargets, true));

// remove the highlight when a drag operation is finished
// (/dnd/cancel or /dnd/drop)
topic.subscribe("/dnd/cancel, /dnd/drop",
	lang.partial(highlightTargets, false));

// give the target of a drop an extended glow
topic.subscribe("/dnd/drop", glowTarget);</pre>
<p>Since we’re listening to the topic broadcast itself, we know these functions will only run once per event. Manipulating a bit of CSS with dojo/dom-class helps make the drag and drop system a bit friendlier for users, and that’s always a good thing.</p>
<p>Armed with knowledge of how to run code at various times during the drag and drop lifecycle, we can see that it wouldn’t be difficult to extend this further. For example, our item quantities currently only determine whether or not you can drop something on the shopping cart; they could easily be updated when they are dropped on the Cart (but not the Wishlist!). And of course, this little storefront doesn’t have any prices! In a real store you’d want to add that, and probably upgrade <code>setupCartTitle</code> to calculate and display a subtotal.</p>
<h3>Avoiding Duplicate Items</h3>
<p>One thing I hadn’t pointed out before was that in version 3 of our demo, in addition to specifying the node creator function when instantiating our Source objects, we also passed a parameter <code>copyOnly: true</code>. This overrides the default drag semantics and performs a copy operation by default instead of a move. This is nice because it means we can avoid removing items from the catalog(s) when we drag them around. The downside is that if you copy an item on the container where it already lives, it duplicates the item.</p>
<p>Logically, this shouldn’t happen because we’re not specifying the <code>accept</code> type on the catalogs, so they should default to <code>"text"</code> and keep us from dropping the products on them (we’re explicitly giving them different types, remember). If you dig into the Dojo source, however, you’ll see that the function that checks for matches between item types and container accept values automatically accepts “self drops”, short circuiting the item type check. Often, that’s the correct behavior, but for our <code>copyOnly</code>–style DnD here, this is backwards. Fortunately again, overriding this is easy: just set the <code>selfAccept</code> property to <code>false</code>.</p>
<p>Take a look at <a href="http://sitepen.github.com/sp-dnd-demo/4-dnd.html">version 4 of our demo</a> to see it all working together. Some of the code has been reorganized and/or moved to an external file to reduce clutter, but the new stuff is all there if you view the page source.</p>
<p><a href="http://sitepen.github.com/sp-dnd-demo/4-dnd.html"><img style="display:block;margin-left:auto;margin-right:auto" src="/labs/code/dnd/intro/dnd/images/blog/dylans-original-4.jpg" alt="An online storefront" /></a></p>
<h3>Tweaking DnD Behavior</h3>
<p>The final thing left to talk about for this demo is the set of buttons we introduce in version 4. We have buttons to clear the wishlist and shopping cart now, but notice the buttons at the bottom of the page: these demonstrate different ways to change the way DnD behaves. You can read the code to see how they work, but here’s what they do:</p>
<ul>
<li><strong>Enable DnD (sets <code>isSource</code>)</strong> – If you’ve ever wondered how to turn DnD on and off completely, here’s one way. This toggles the <code>isSource</code> member of each of our sources. I mentioned this earlier, but recall that when this is false, the manager won’t initiate any drag operations. Objects will still accept drops, but if there’s nothing acting as a source, we’ve effectively disabled the DnD system.</li>
<li><strong>Drag via handles only (sets <code>withHandles</code>)</strong> – If you give a DOM node the <code>dojoDndHandle</code> class, dojo/dnd will consider it a handle. Each Source has a member variable <code>withHandles</code> that determines whether you can drag <em>any</em> part of an item, or just the handle. This demo sets up the product images as the handles, so if you toggle the button, you’ll see the drag behavior change accordingly.</li>
</ul>
<h2>Finishing Up</h2>
<p>For reference, here are the steps we’ve taken so far:</p>
<ul>
<li><a href="http://sitepen.github.com/sp-dnd-demo/0-dnd.html">Step 0: skeleton page</a></li>
<li><a href="http://sitepen.github.com/sp-dnd-demo/1-dnd.html">Step 1: a single list</a></li>
<li><a href="http://sitepen.github.com/sp-dnd-demo/2-dnd.html">Step 2: multiple lists</a></li>
<li><a href="http://sitepen.github.com/sp-dnd-demo/3-dnd.html">Step 3: customizing item creation</a></li>
<li><a href="http://sitepen.github.com/sp-dnd-demo/4-dnd.html">Step 4: listening to events</a></li>
</ul>
<p>There’s quite a lot left to discuss in dojo/dnd that we haven’t touched on. For example, there’s been little discussion about the CSS classes that are used by DnD (you can see what this demo uses in <a href="http://sitepen.github.com/sp-dnd-demo/dnd.css">dnd.css</a>). We also didn’t discuss how to cleanly set up your own custom DnD sources by extending dojo/dnd/Source using <code>dojo/_base/declare</code>. A lot of dojo/dnd’s internals are specifically set up to be easy to override with your own code so you can customize just about any part necessary. These are all areas that you should explore on your own to get a feel for how DnD can be useful in your own projects. You can download an <a href="https://github.com/sitepen/sp-dnd-demo/zipball/gh-pages">archive of the entire demo</a> so you can play with it yourself locally.</p>
<p>Happy dragging and dropping!</p>


<p>Related posts:<ol><li><a href='http://www.sitepen.com/blog/2008/06/10/dojo-drag-and-drop-1/' rel='bookmark' title='Permanent Link: Dojo Drag and Drop, Part 1: dojo.dnd'>Dojo Drag and Drop, Part 1: dojo.dnd</a></li>
<li><a href='http://www.sitepen.com/blog/2009/04/16/queued-drag-and-drop-in-the-queue/' rel='bookmark' title='Permanent Link: Queued: Drag and Drop in the Queue'>Queued: Drag and Drop in the Queue</a></li>
<li><a href='http://www.sitepen.com/blog/2008/10/24/inside-dojo-dnd-drag-handles/' rel='bookmark' title='Permanent Link: Inside Dojo DnD: Drag Handles'>Inside Dojo DnD: Drag Handles</a></li>
</ol></p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2011/12/05/dojo-drag-n-drop-redux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>We’ve (unofficially) declared 2012 as the Year of Dojo!</title>
		<link>http://www.sitepen.com/blog/2011/12/05/we%e2%80%99ve-unofficially-declared-2012-as-the-year-of-dojo/</link>
		<comments>http://www.sitepen.com/blog/2011/12/05/we%e2%80%99ve-unofficially-declared-2012-as-the-year-of-dojo/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 19:50:33 +0000</pubDate>
		<dc:creator>Angela Segovia</dc:creator>
				<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=3730</guid>
		<description><![CDATA[<p>2012 Year of Dojo SitePen is so dedicated to providing you with the highest quality Dojo Toolkit education in the industry that we will be in 11 states, providing 22 Dojo Workshops throughout 2012.  Whether you want to learn the basics of Dojo or sharpen your Dojo skills, we have a workshop just for you. [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>


Related posts:<ol><li><a href='http://www.sitepen.com/blog/2012/01/30/eleven-trends-for-2012-the-year-of-dojo/' rel='bookmark' title='Permanent Link: Eleven Trends for 2012: The Year of Dojo'>Eleven Trends for 2012: The Year of Dojo</a></li>
<li><a href='http://www.sitepen.com/blog/2012/01/17/the-year-of-dojo-is-here/' rel='bookmark' title='Permanent Link: The Year of Dojo is Here!'>The Year of Dojo is Here!</a></li>
<li><a href='http://www.sitepen.com/blog/2011/10/06/dojo-dontcha-know-sitepen-dojo-minnesota/' rel='bookmark' title='Permanent Link: Dojo. Dontcha know?  SitePen. Dojo. Minnesota.'>Dojo. Dontcha know?  SitePen. Dojo. Minnesota.</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h3>2012 Year of Dojo</h3>
<p style="text-align: left;">SitePen is so <em>dedicated</em> to providing you with the highest quality Dojo Toolkit education in the industry that we will be in 11 states, providing 22 Dojo Workshops throughout 2012.  Whether you want to learn the basics of Dojo or sharpen your Dojo skills, we have a workshop just for you.  We <em>guarantee</em> that all of our Dojo Workshops will be taught by our expert engineers.  We <em>promise</em> you won’t be subjected to listening to some trainer who can’t live without his slides.  Wondering if our Dojo Workshops will cover <a title="Dojo 1.7" href="http://dojotoolkit.org/blog/dojo-1-7-released]" target="_blank">Dojo 1.7</a>?  The answer is yes.</p>
<p><strong>Register in 2011. Attend in 2012.</strong> <strong>Where will you start your 2012 Year of Dojo celebration? </strong>Check out the full list of <a title="2012 Dojo Workshops" href="http://www.sitepen.com/services/workshops/index.php" target="_blank">SitePen&#8217;s 2012 Dojo workshops</a>.</p>
<p><strong>Dojo Toolkit has some vocal fans. </strong>Here’s a random sample of what we’ve found recently on Twitter:</p>
<p style="padding-left: 30px;">Have I been living under a rock? How come I&#8217;ve never come across Dojo toolkit? I am going to have to learn the ins and outs&#8230; @ deshiknaves</p>
<p style="padding-left: 30px;">Working on my <a title="#Dojo" href="https://twitter.com/#!/search?q=%23Dojo">#Dojo</a> 1.7 presentation, it&#8217;s so tough to pick the best new bits in 1.7, there&#8217;s so much amazing stuff! @ thomasj</p>
<p style="padding-left: 30px;">i&#8217;ve been working with design part of this system and found out that <a title="#dojo" href="https://twitter.com/#!/search?q=%23dojo">#dojo</a> is better than #JQuery in terms of performance.. #toolkit @ hayadeen</p>
<p><strong>Psst! What’s that you say?  You want to learn Dojo in January? </strong> No problem! Join us in Las Vegas, NV or Raleigh, NC. (Did we mention all of our 2012 workshops will cover <a title="Dojo 1.7" href="http://dojotoolkit.org/blog/dojo-1-7-released]" target="_blank">Dojo 1.7</a>?)</p>
<p style="padding-left: 30px;"><a title="jUMP into Dojo Las Vegas" href="http://www.sitepen.com/services/workshops/index.php?dojo-workshop-lasvegas-01-2012" target="_blank"><strong>jUMP into Dojo - Las Vegas, NV - January 9, 2012</strong></a><br />
jUMP into Dojo is the best starting point for any developer wanting to learn about Dojo, Ajax and Rich Internet Application development. This workshop gives a rapid introduction to the capabilities of Dojo as well as the experience in applying them to solve real-world problems.  And did we mention this one is in Las Vegas?  Enuff said.</p>
<p style="padding-left: 30px;"><a title="Dojo Master Raleigh" href="http://www.sitepen.com/services/workshops/index.php?dojo-workshop-raleigh-01-2012" target="_blank"><strong>Dojo Master &#8211; Raleigh, NC - January 18-19, 2012</strong></a><br />
Dojo Master is our black diamond workshop, taking the advanced scripter through the expert techniques needed when tackling the unique problems web applications can bring. This workshop is best for the intermediate-advanced developer who has used Dojo in several projects and who wants to get the most out of Dojo and JavaScript to make reliable and scalable applications.</p>
<p>What are you waiting for? <a title="SitePen Dojo Workshops" href="http://www.sitepen.com/services/workshops/index.php" target="_blank">Register today!</a> Use promo code IHEARTDOJO and get 10% off!</p>


<p>Related posts:<ol><li><a href='http://www.sitepen.com/blog/2012/01/30/eleven-trends-for-2012-the-year-of-dojo/' rel='bookmark' title='Permanent Link: Eleven Trends for 2012: The Year of Dojo'>Eleven Trends for 2012: The Year of Dojo</a></li>
<li><a href='http://www.sitepen.com/blog/2012/01/17/the-year-of-dojo-is-here/' rel='bookmark' title='Permanent Link: The Year of Dojo is Here!'>The Year of Dojo is Here!</a></li>
<li><a href='http://www.sitepen.com/blog/2011/10/06/dojo-dontcha-know-sitepen-dojo-minnesota/' rel='bookmark' title='Permanent Link: Dojo. Dontcha know?  SitePen. Dojo. Minnesota.'>Dojo. Dontcha know?  SitePen. Dojo. Minnesota.</a></li>
</ol></p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2011/12/05/we%e2%80%99ve-unofficially-declared-2012-as-the-year-of-dojo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rich Web Experience 2011 – And so it was!</title>
		<link>http://www.sitepen.com/blog/2011/12/02/rich-web-experience-2011-%e2%80%93-and-so-it-was/</link>
		<comments>http://www.sitepen.com/blog/2011/12/02/rich-web-experience-2011-%e2%80%93-and-so-it-was/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 16:55:53 +0000</pubDate>
		<dc:creator>Angela Segovia</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=3719</guid>
		<description><![CDATA[<p>SitePen’s Dylan Schiemann delivered the last of his three Rich Web Experience 2011 presentations yesterday, Never Bet Against the Open Web. Dylan had this to say about his time at #RWX2011: The level of interest in AMD, object stores, and mobile is impressive. And the excitement around the potential of xstyle and put-selector was also [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>


Related posts:<ol><li><a href='http://www.sitepen.com/blog/2011/12/01/rich-web-experience-2011-day-2-dojo-2-0/' rel='bookmark' title='Permanent Link: Rich Web Experience 2011- Day 2- Dojo 2.0'>Rich Web Experience 2011- Day 2- Dojo 2.0</a></li>
<li><a href='http://www.sitepen.com/blog/2011/11/21/sitepen%e2%80%99s-dylan-schiemann-to-keynote-at-rich-web-experience-2011/' rel='bookmark' title='Permanent Link: SitePen’s Dylan Schiemann to Keynote at Rich Web Experience 2011'>SitePen’s Dylan Schiemann to Keynote at Rich Web Experience 2011</a></li>
<li><a href='http://www.sitepen.com/blog/2011/11/30/rich-web-experience-2011-day-1-%e2%80%93-killer-keynote/' rel='bookmark' title='Permanent Link: Rich Web Experience 2011- Day 1 – Killer Keynote'>Rich Web Experience 2011- Day 1 – Killer Keynote</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>SitePen’s Dylan Schiemann delivered the last of his three Rich Web Experience 2011 presentations yesterday, <a title="Never Bet Against The Open Web" href="http://www.slideshare.net/sitepen/never-bet-against-the-open-web-10435744" target="_blank">Never Bet Against the Open Web</a>.</p>
<p>Dylan had this to say about his time at #RWX2011:</p>
<blockquote><p>The level of interest in AMD, object stores, and mobile is impressive. And the excitement around the potential of xstyle and put-selector was also very cool to see. The community is seemingly rabid for new tools and features that make development easier, and it&#8217;s incredible to be part of that.</p></blockquote>
<p>And if you haven’t seen this already- <a title="Dojo 1.7 Released!" href="http://dojotoolkit.org/blog/dojo-1-7-released]" target="_blank">Dojo 1.7 Released</a>!</p>
<p>We have made all of Dylan’s Rich Web Experience 2011 (and many other) presentations <a title="SitePen SlideShare" href="http://www.slideshare.net/sitepen" target="_blank">available here</a>.  Don’t forget to follow SitePen on <a title="Twitter - SitePen" href="https://twitter.com/#!/sitepen">Twitter</a> and <a title="Google+ SitePen" href="https://plus.google.com/b/103329577501148757527/">Google+</a>!</p>


<p>Related posts:<ol><li><a href='http://www.sitepen.com/blog/2011/12/01/rich-web-experience-2011-day-2-dojo-2-0/' rel='bookmark' title='Permanent Link: Rich Web Experience 2011- Day 2- Dojo 2.0'>Rich Web Experience 2011- Day 2- Dojo 2.0</a></li>
<li><a href='http://www.sitepen.com/blog/2011/11/21/sitepen%e2%80%99s-dylan-schiemann-to-keynote-at-rich-web-experience-2011/' rel='bookmark' title='Permanent Link: SitePen’s Dylan Schiemann to Keynote at Rich Web Experience 2011'>SitePen’s Dylan Schiemann to Keynote at Rich Web Experience 2011</a></li>
<li><a href='http://www.sitepen.com/blog/2011/11/30/rich-web-experience-2011-day-1-%e2%80%93-killer-keynote/' rel='bookmark' title='Permanent Link: Rich Web Experience 2011- Day 1 – Killer Keynote'>Rich Web Experience 2011- Day 1 – Killer Keynote</a></li>
</ol></p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2011/12/02/rich-web-experience-2011-%e2%80%93-and-so-it-was/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

