<?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>Lacisoft&#039;s &#187; sortable</title>
	<atom:link href="http://www.lacisoft.com/blog/tag/sortable/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lacisoft.com/blog</link>
	<description>SELECT * FROM lacisoft</description>
	<lastBuildDate>Mon, 30 Jan 2012 17:42:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to make a drag and drop sorted list with jQuery Sortable</title>
		<link>http://www.lacisoft.com/blog/2009/04/10/how-to-make-a-drag-and-drop-sorted-list-with-jquery-sortable/</link>
		<comments>http://www.lacisoft.com/blog/2009/04/10/how-to-make-a-drag-and-drop-sorted-list-with-jquery-sortable/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 12:21:28 +0000</pubDate>
		<dc:creator>lacisoft</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[drag and drop]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[sortable]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.lacisoft.com/blog/?p=28</guid>
		<description><![CDATA[A while ago i wanted to build a functionality where some blocks of html had to be sortable (with drag and drop). After searching a little i found jQuery&#8217;s Sortable plugin. With the help of this nice little plugin i could build the functionality i required in no time. I will show you below how [...]
Related posts:<ol>
<li><a href='http://www.lacisoft.com/blog/2011/02/01/mysql-sort-results-in-order-by-list/' rel='bookmark' title='MySQL &#8211; Sort results in order by list'>MySQL &#8211; Sort results in order by list</a></li>
<li><a href='http://www.lacisoft.com/blog/2009/04/09/how-to-build-a-clickmap-using-php-and-jquery/' rel='bookmark' title='How to build a clickmap using PHP and jQuery'>How to build a clickmap using PHP and jQuery</a></li>
<li><a href='http://www.lacisoft.com/blog/2008/09/19/6-books-for-developers-working-with-drupal-6-and-jquery/' rel='bookmark' title='6 books for developers working with Drupal 6 and Jquery'>6 books for developers working with Drupal 6 and Jquery</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>A while ago i wanted to build a functionality where some blocks of html had to be sortable (with drag and drop). After searching a little i found jQuery&#8217;s Sortable plugin. With the help of this nice little plugin i could build the functionality i required in no time. I will show you below how to do it if you need to do this yourself.</p>
<p>For start we need jQuery, ui.core and ui.sortable, make sure you download them and include them in the header of your application:</p>
<p><em>&lt;script src=&#8221;jquery-latest.js&#8221;&gt;&lt;/script&gt;<br />
&lt;script src=&#8221;ui.core.js&#8221;&gt;&lt;/script&gt;<br />
&lt;script src=&#8221;ui.sortable.js&#8221;&gt;&lt;/script&gt;</em></p>
<p>after that we use this little code snippet to make the magic:</p>
<p><em>&lt;script&gt;</em></p>
<p><em>$(document).ready(function(){</em></p>
<p><em>$(&#8220;.thelist&#8221;).sortable({</em></p>
<p><em>cursor: &#8216;.handle&#8217;,</em></p>
<p><em>update : function () {</em></p>
<p><em>serial=$(&#8216;.thelist&#8217;).sortable(&#8216;serialize&#8217;,'id&#8217;);</em></p>
<p><em>$(&#8220;#target&#8221;).load(&#8220;load.php&#8221;, { list: serial } );</em></p>
<p><em>}</em></p>
<p><em>});</em></p>
<p><em>});</em></p>
<p><em>&lt;/script&gt;</em></p>
<p><em><br />
</em></p>
<p>In the html we have a div with the class <strong>thelist</strong>, this is the div that contains the sortable elements, each having a unique id.</p>
<p><em>&lt;div class=&#8221;thelist&#8221;&gt;</em></p>
<p><em>&lt;div class=&#8221;divo&#8221; id=&#8221;el_1&#8243;&gt;Item 1&lt;/div&gt;</em></p>
<p><em>&lt;div class=&#8221;divo&#8221; id=&#8221;el_2&#8243;&gt;Item 2&lt;/div&gt;</em></p>
<p><em>&lt;div class=&#8221;divo&#8221; id=&#8221;el_3&#8243;&gt;Item 3&lt;/div&gt;</em></p>
<p><em>&lt;div class=&#8221;divo&#8221; id=&#8221;el_4&#8243;&gt;Item 4&lt;/div&gt;</em></p>
<p><em>&lt;div class=&#8221;divo&#8221; id=&#8221;el_5&#8243;&gt;Item 5&lt;/div&gt;</em></p>
<p><em>&lt;/div&gt;</em></p>
<p><em><br />
</em></p>
<p>After each drag and drop operation in load.php will receive a string with the order of the divs, the result will be something like this:</p>
<p><strong><em>el[]=3&amp;el[]=4&amp;el[]=5&amp;el[]=2&amp;el[]=1</em></strong></p>
<p>This data is sent to load.php with POST, beeing contained in the list variable: <strong>$_POST['list']</strong></p>
<p>This is only a basic demonstration, you can do much advanced functionality with jQuery Sortable, you just need a little time and a little coffee.</p>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.lacisoft.com%2Fblog%2F2009%2F04%2F10%2Fhow-to-make-a-drag-and-drop-sorted-list-with-jquery-sortable%2F&amp;title=How%20to%20make%20a%20drag%20and%20drop%20sorted%20list%20with%20jQuery%20Sortable" id="wpa2a_2"><img src="http://www.lacisoft.com/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>Related posts:<ol>
<li><a href='http://www.lacisoft.com/blog/2011/02/01/mysql-sort-results-in-order-by-list/' rel='bookmark' title='MySQL &#8211; Sort results in order by list'>MySQL &#8211; Sort results in order by list</a></li>
<li><a href='http://www.lacisoft.com/blog/2009/04/09/how-to-build-a-clickmap-using-php-and-jquery/' rel='bookmark' title='How to build a clickmap using PHP and jQuery'>How to build a clickmap using PHP and jQuery</a></li>
<li><a href='http://www.lacisoft.com/blog/2008/09/19/6-books-for-developers-working-with-drupal-6-and-jquery/' rel='bookmark' title='6 books for developers working with Drupal 6 and Jquery'>6 books for developers working with Drupal 6 and Jquery</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.lacisoft.com/blog/2009/04/10/how-to-make-a-drag-and-drop-sorted-list-with-jquery-sortable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

