<?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>Dave McDermid</title>
	<atom:link href="http://www.davemcdermid.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davemcdermid.co.uk</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 19 Jan 2010 00:59:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Migrating to ASP.NET MVC</title>
		<link>http://www.davemcdermid.co.uk/2010/01/migrating-to-asp-net-mvc/</link>
		<comments>http://www.davemcdermid.co.uk/2010/01/migrating-to-asp-net-mvc/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 18:48:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[Headscape]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://www.davemcdermid.co.uk/?p=90</guid>
		<description><![CDATA[A few months ago, maybe around November time last year when ASP.NET MVC 2 was being previewed, I was looking for excuses to build something to take advantage of as many new features as possible. Building a test site gets very dull very quickly, it just ain&#8217;t the same as a real project with real [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago, maybe around November time last year when ASP.NET MVC 2 was being previewed, I was looking for excuses to build something to take advantage of as many new features as possible. Building a test site gets very dull very quickly, it just ain&#8217;t the same as a real project with real world problems. So I took the current site I was working on and decided to implement a small part of it in MVC. I figured it might be interesting, and had this crazy idea that I could one day convince everyone we should move the whole site.</p>
<p>The benefits of such a migration to a developer are clear, but I&#8217;m not naive. The site in question is our flagship e-commerce site built on tried-and-proven classic ASP (VBScript) technology, with huge amounts of legacy code, multiple franchise systems, admin systems, and large numbers of paying customers. If it ain&#8217;t broke, there&#8217;s no chance we&#8217;ll be spending months on a risky rewrite. So I knew I had to be cunning.</p>
<p>My goal was simple. If I could get a small part of the front-end site to run under MVC, and show significant benefit to our client, it might just happen. The bait? Performance. One of the big benefits of moving from a scripting language to a modern framework is the tools available for various levels of caching. The other main drive was to move from using several 3rd party tools (such as Java and ISAPI ReWrite) to a common language and framework (C#.NET). This would make site maintenance less of a headache for everyone.</p>
<p>Over the course of a few lunchtimes, evenings and Saturday mornings I threw together a test site. A few demos and a series comparison stats later and we had a proposal.</p>
<p>Over the course of a series of blog posts, I&#8217;ll be outlining the various challenges associated with this project and how we tackle them. This will include advanced and customised routing, caching, best practices and running new code side-by-side with legacy code. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davemcdermid.co.uk/2010/01/migrating-to-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A wordpress plugin to sort pages</title>
		<link>http://www.davemcdermid.co.uk/2009/11/a-wordpress-plugin-to-sort-pages/</link>
		<comments>http://www.davemcdermid.co.uk/2009/11/a-wordpress-plugin-to-sort-pages/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 18:50:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpres]]></category>

		<guid isPermaLink="false">http://www.davemcdermid.co.uk/?p=88</guid>
		<description><![CDATA[Mike Badgley has built a handy wordpress plugin based on my sortable sitemap to sort pages.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lifeatistudio.com/">Mike Badgley</a> has built <a href="http://bit.ly/77mCW1">a handy wordpress plugin</a> based on my <a href="http://www.davemcdermid.co.uk/2009/08/sortable-sitemap/">sortable sitemap</a> to sort pages.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.davemcdermid.co.uk/2009/11/a-wordpress-plugin-to-sort-pages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Boagworld podcast 191</title>
		<link>http://www.davemcdermid.co.uk/2009/11/boagworld-podcast-191/</link>
		<comments>http://www.davemcdermid.co.uk/2009/11/boagworld-podcast-191/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 13:00:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[boagworld]]></category>
		<category><![CDATA[podcast]]></category>

		<guid isPermaLink="false">http://www.davemcdermid.co.uk/2009/11/boagworld-podcast-191/</guid>
		<description><![CDATA[Co-hosted this weeks Boagworld podcast. Available on iTunes
http://boagworld.com/podcast/191
]]></description>
			<content:encoded><![CDATA[<p>Co-hosted this weeks Boagworld podcast. Available on iTunes</p>
<p><a href="http://boagworld.com/podcast/191">http://boagworld.com/podcast/191</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davemcdermid.co.uk/2009/11/boagworld-podcast-191/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evolution of a jQuery plugin</title>
		<link>http://www.davemcdermid.co.uk/2009/11/evolution-of-a-jquery-plugin/</link>
		<comments>http://www.davemcdermid.co.uk/2009/11/evolution-of-a-jquery-plugin/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 12:00:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.davemcdermid.co.uk/2009/11/evolution-of-a-jquery-plugin/</guid>
		<description><![CDATA[My article on scrunchup.com &#8211; a great new resource for those getting started in web stuff
http://scrunchup.com/issue-2/the-evolution-of-a-jquery-plugin/
]]></description>
			<content:encoded><![CDATA[<p>My article on scrunchup.com &#8211; a great new resource for those getting started in web stuff</p>
<p><a href="http://scrunchup.com/issue-2/the-evolution-of-a-jquery-plugin/">http://scrunchup.com/issue-2/the-evolution-of-a-jquery-plugin/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davemcdermid.co.uk/2009/11/evolution-of-a-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a sortable sitemap with jQuery UI.</title>
		<link>http://www.davemcdermid.co.uk/2009/08/sortable-sitemap/</link>
		<comments>http://www.davemcdermid.co.uk/2009/08/sortable-sitemap/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 15:34:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.davemcdermid.co.uk/?p=69</guid>
		<description><![CDATA[A coupe of weeks ago I was tasked with building a drag-and-drop sortable sitemap for our in-house content management system. There are a handful of javascript libraries and plugins available that attempt this task, but none of them worked flawlessly with our HTML. The real issue here is that javascript alone cannot produce a slick [...]]]></description>
			<content:encoded><![CDATA[<p>A coupe of weeks ago I was tasked with building a drag-and-drop sortable sitemap for our in-house content management system. There are a handful of javascript libraries and plugins available that attempt this task, but none of them worked flawlessly with our HTML. The real issue here is that javascript alone cannot produce a slick solution, the HTML and CSS need to be carefully contructed to ensure that the experience is seamless and pleasant.</p>
<p><strong>The HTML.</strong><br />
Our HTML consists of nested unordered lists, with each list item containing a definition list for the title, page type, Pubish status, and action links for editing or deleting the page. The feature for expanding and collapsing child pages already existed, making things extra fun.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sitemap&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">dl</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">dt</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>expand/collapse<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span> <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>Page Title<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">dt</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">dd</span>&gt;</span>Text Page<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">dd</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">dd</span>&gt;</span>Published<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">dd</span>&gt;</span>
			<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">dd</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>delete<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">dd</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">dl</span>&gt;</span>
		<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span><span style="color: #808080; font-style: italic;">&lt;!--child pages--&gt;</span><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>

<p><strong>The requirements.</strong><br />
The behaviour had to intuitive for the user, they need to be able to reorder pages and move entire sections to new parents. It had to be clear to the user where a page would end up when they dropped it (ie. between pages or as a child page).</p>
<p><strong>Simplifying the task.</strong><br />
When one page is dropped over another page, there are three possible outcomes. The page can end up before, after or as a child. This gets particularly tricky at the boundary point between the last child of a sub list and the following sibling. If the resulting location of where a page ends up is the difference of a couple of pixels, the user could become frustrated. We decided to simplfy the problem so that a page could be dropped only before items or as children of items. The only limitation here is that you couldn&#8217;t easily drop an item as the last child of a list, but this is only a minor issue as moving the last child up would achieve the same result. You can also drop an item on the parent to cause it to become the last child, but this isn&#8217;t so obvious really.</p>
<p>This means for each item on our list we now need to identify two areas where the user can drop the page, on the page to be a child, and above the page to be a sibling.</p>
<p><strong>The javascript.</strong><br />
The great thing about jQuery / jQuery UI is how it lets me write the code I want to write, and takes care of cross-browser behaviours and gaps in DOM manipulation. Anyone who has attempted at creating drag and drop functionality for a website will be well aware of the headaches involved in getting everything to work smoothly across browsers. jQuery UI seems to handle this brilliantly.</p>
<p>The first thing I want to do is create a div inside the list item to act as a dropzone for placing items as siblings.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#sitemap li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prepend</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div&gt;&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>piece of cake.</p>
<p>To allow an item to be dragged, we simply call the draggable() function on the items that can be dragged.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#sitemap li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draggable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    handle<span style="color: #339933;">:</span> <span style="color: #3366CC;">' &gt; dl'</span><span style="color: #339933;">,</span>
    opacity<span style="color: #339933;">:</span> .8<span style="color: #339933;">,</span>
    addClasses<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
    helper<span style="color: #339933;">:</span> <span style="color: #3366CC;">'clone'</span><span style="color: #339933;">,</span>
    zIndex<span style="color: #339933;">:</span> <span style="color: #CC0000;">100</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As we are dealing with nested lists, it is important that only the definition list inside our list item acts as a handle, otherwise our old friend Internet Explorer can get a little confused over who&#8217;s meant to be moving and who should be staying where they are. By specifying &#8216;clone&#8217; we create a duplicate list item that follows the mouse, while the original item waits patiently for us to decide where it should belong. An opacity of 0.8 and a high zIndex keeps the clone on top of everyone else and slightly opaque. It&#8217;s the little touches that really count.</p>
<p><strong>The magic.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#sitemap dl, #sitemap .dropzone'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">droppable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    accept<span style="color: #339933;">:</span> <span style="color: #3366CC;">'#sitemap li'</span><span style="color: #339933;">,</span>
    tolerance<span style="color: #339933;">:</span> <span style="color: #3366CC;">'pointer'</span><span style="color: #339933;">,</span>
    drop<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> ui<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> li <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> child <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'dropzone'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//If this is our first child, we'll need a ul to drop into.</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>child <span style="color: #339933;">&amp;&amp;</span> li.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            li.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;ul/&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #006600; font-style: italic;">//ui.draggable is our reference to the item that's been dragged.</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>child<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            li.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>ui.<span style="color: #660066;">draggable</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            li.<span style="color: #660066;">before</span><span style="color: #009900;">&#40;</span>ui.<span style="color: #660066;">draggable</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #006600; font-style: italic;">//reset our background colours.</span>
        li.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'dl,.dropzone'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> backgroundColor<span style="color: #339933;">:</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">,</span> borderColor<span style="color: #339933;">:</span> <span style="color: #3366CC;">''</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    over<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'dl'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> backgroundColor<span style="color: #339933;">:</span> <span style="color: #3366CC;">'#ccc'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.dropzone'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> borderColor<span style="color: #339933;">:</span> <span style="color: #3366CC;">'#aaa'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    out<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'dl'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> backgroundColor<span style="color: #339933;">:</span> <span style="color: #3366CC;">''</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.dropzone'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> borderColor<span style="color: #339933;">:</span> <span style="color: #3366CC;">''</span> <span style="color: #009900;">&#125;</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></pre></div></div>

<p>Ok. That&#8217;s a fair chunk of code, let&#8217;s break it down.<br />
We only want to accept sitemap list items, we don&#8217;t care about other items they care to drop here.<br />
The tolerance specifys the drop item to be the element under mouse pointer, we&#8217;re expecting the user to place their mouse where the item should end up.<br />
When the drop happens, this is how we decide what to do:<br />
We set the variable &#8216;li&#8217; to be the parent of the dropzone (as both the definition list and the dropzone div are children of the list item). This is just for convenience.<br />
When the user drops the page, we need to decide what they landed on, if it has a class &#8216;dropzone&#8217; then we are placing the dropped item before us. Otherwise we are placing this as a child.<br />
As the item is being dragged around, it is imperitive to give an indication as to where it will end up. We can do this by conditionally applying a background colour to whichever item we are hovering over. For the &#8216;dropzone&#8217;, we instead apply a border colour, as we want it to display as a solid line between the two items.</p>
<p>At this point we can also fire off our update in an ajax post to the server, in order to commit the change.</p>
<p><strong>The CSS.</strong><br />
The secret to the interface working really well is CSS. By making sure we have the right paddings and heights in the right places we give the user enough space to comfortably drop items. If we keep the space around the definition list tight, and apply a 4px border plus 6px height to the &#8216;dropzone&#8217; div, we give the user 10 pixels of droppable area. This is plenty to guarantee the user will be comfortable. The 4px border gives us a strong, clear indication that the item will be dropped as a sibling.</p>
<p><strong>Extra spice</strong><br />
In the demo you&#8217;ll notice the addition of an undo stack. This is a great fall back for when a user moves a page to the wrong place but forgets where it came from. This will be covered in a separate tutorial.</p>
<p>Demo: <a href="http://boagworld.com/demos/sitemap">http://boagworld.com/demos/sitemap</a></p>
<p>For more info, checkout the jQuery UI docs: <a href="http://jqueryui.com/demos/">http://jqueryui.com/demos/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davemcdermid.co.uk/2009/08/sortable-sitemap/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.375 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-03-11 18:00:48 -->
