<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Drag and drop reordering of database fields (sortables) with jQuery</title>
	<atom:link href="http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/</link>
	<description>Tim Roberts CakePHP, MySQL and jQuery Developer</description>
	<lastBuildDate>Fri, 03 Feb 2012 01:34:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: Top 10 jQuery Database Plugins &#124; jQuery4u</title>
		<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/comment-page-1/#comment-6592</link>
		<dc:creator>Top 10 jQuery Database Plugins &#124; jQuery4u</dc:creator>
		<pubDate>Sun, 02 Oct 2011 09:53:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=143#comment-6592</guid>
		<description>[...]   [...]</description>
		<content:encoded><![CDATA[<p>[...]   [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luke</title>
		<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/comment-page-1/#comment-6479</link>
		<dc:creator>Luke</dc:creator>
		<pubDate>Wed, 10 Aug 2011 11:07:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=143#comment-6479</guid>
		<description>You can&#039;t really just update the ones that have been swapped, as if you move an element to position two, you probably already have a record in position two, which will cause a conflict. You could potentially solve this by having a &#039;date_last_sorted&#039; field and order by this, also, but then you run the risk of encountering the dreaded &#039;unexpected behaviour&#039;. This approach is probably the best (and the safest) for most applications. 

As for tackling multiple concurrent users, you&#039;d probably have to employ some kind of a locking mechanism to the sorter when any other user is logged on and currently using the sorter. Considering the query will be almost instantaneous for most applications, though, I don&#039;t see this being such a problem for most.

Cheers for the tutorial though - this is a far simpler approach to the one I&#039;ve used in the past, where I&#039;ve used toArray() instead of toSerialize() to the same end.</description>
		<content:encoded><![CDATA[<p>You can&#8217;t really just update the ones that have been swapped, as if you move an element to position two, you probably already have a record in position two, which will cause a conflict. You could potentially solve this by having a &#8216;date_last_sorted&#8217; field and order by this, also, but then you run the risk of encountering the dreaded &#8216;unexpected behaviour&#8217;. This approach is probably the best (and the safest) for most applications. </p>
<p>As for tackling multiple concurrent users, you&#8217;d probably have to employ some kind of a locking mechanism to the sorter when any other user is logged on and currently using the sorter. Considering the query will be almost instantaneous for most applications, though, I don&#8217;t see this being such a problem for most.</p>
<p>Cheers for the tutorial though &#8211; this is a far simpler approach to the one I&#8217;ve used in the past, where I&#8217;ve used toArray() instead of toSerialize() to the same end.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Geo</title>
		<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/comment-page-1/#comment-6294</link>
		<dc:creator>Geo</dc:creator>
		<pubDate>Thu, 02 Jun 2011 21:51:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=143#comment-6294</guid>
		<description>Hi,

Okay this was my thoughts originally too. But in the last step - updating the ENTIRE table (especially if you have hundreds or even thousands of records) just because few records were changed or even only 2 records were &quot;swapped&quot; like Wes suggests above, is very very ineffective..

I was thinking of a better solution like updating only the involved records, swapping them, etc. but it seems that all solutions have their bugs.

Things to keep in mind if you are trying to avoid updating the entire table (like I suggest):
- how to insert a new record
- how to delete a record
- what if the same list is updated simultaneously by 2 different users in 2 different browsers (this one is the trickiest)

Please send me your opinions to my email if i don&#039;t receive notifications from this blog.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Okay this was my thoughts originally too. But in the last step &#8211; updating the ENTIRE table (especially if you have hundreds or even thousands of records) just because few records were changed or even only 2 records were &#8220;swapped&#8221; like Wes suggests above, is very very ineffective..</p>
<p>I was thinking of a better solution like updating only the involved records, swapping them, etc. but it seems that all solutions have their bugs.</p>
<p>Things to keep in mind if you are trying to avoid updating the entire table (like I suggest):<br />
- how to insert a new record<br />
- how to delete a record<br />
- what if the same list is updated simultaneously by 2 different users in 2 different browsers (this one is the trickiest)</p>
<p>Please send me your opinions to my email if i don&#8217;t receive notifications from this blog.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wes</title>
		<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/comment-page-1/#comment-6119</link>
		<dc:creator>wes</dc:creator>
		<pubDate>Mon, 14 Mar 2011 15:49:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=143#comment-6119</guid>
		<description>Thanks!  Just wondering if you know how to get it to just send down the items in the list that have been swapped... as only 2 rows in the backend database really need to change every time the user drops a row into a new position.  I&#039;m trying this but it gets slow when I&#039;m updating hundreds of rows in the database when only 2 of them have changed position each time!</description>
		<content:encoded><![CDATA[<p>Thanks!  Just wondering if you know how to get it to just send down the items in the list that have been swapped&#8230; as only 2 rows in the backend database really need to change every time the user drops a row into a new position.  I&#8217;m trying this but it gets slow when I&#8217;m updating hundreds of rows in the database when only 2 of them have changed position each time!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seborgarsen</title>
		<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/comment-page-1/#comment-5672</link>
		<dc:creator>seborgarsen</dc:creator>
		<pubDate>Thu, 04 Mar 2010 13:17:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=143#comment-5672</guid>
		<description>solved it by using &#039;toArray&#039; instead and then 

	$pikand  = ($_GET[&#039;data&#039;]);
	
	$array = explode(&quot;,&quot;, $pikand);

	foreach ($array as $position=&gt;$id</description>
		<content:encoded><![CDATA[<p>solved it by using &#8216;toArray&#8217; instead and then </p>
<p>	$pikand  = ($_GET['data']);</p>
<p>	$array = explode(&#8220;,&#8221;, $pikand);</p>
<p>	foreach ($array as $position=&gt;$id</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seborgarsen</title>
		<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/comment-page-1/#comment-5670</link>
		<dc:creator>seborgarsen</dc:creator>
		<pubDate>Wed, 03 Mar 2010 18:13:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=143#comment-5670</guid>
		<description>oh, this is what&#039;s returned via POST:

	item[]=200&amp;item[]=196&amp;item[]=206&amp;item[]=207</description>
		<content:encoded><![CDATA[<p>oh, this is what&#8217;s returned via POST:</p>
<p>	item[]=200&amp;item[]=196&amp;item[]=206&amp;item[]=207</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: seborgarsen</title>
		<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/comment-page-1/#comment-5669</link>
		<dc:creator>seborgarsen</dc:creator>
		<pubDate>Wed, 03 Mar 2010 18:01:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=143#comment-5669</guid>
		<description>Hi,

First of all thanks for the tutorial.

A little snafu, though. I am getting this response:

&quot;Invalid argument supplied for foreach()&quot;

[php]
foreach($_POST[&#039;array&#039;] as $key=&gt;$value) {
		$wpdb-&gt;query(&quot;UPDATE $playlists SET order =&#039;&quot; . $key . &quot;&#039; WHERE id =&#039;&quot; . $value . &quot;&#039;&quot;);
	}
[/php]

any hints? the foreach looks perfectly alright to me. stumped.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>First of all thanks for the tutorial.</p>
<p>A little snafu, though. I am getting this response:</p>
<p>&#8220;Invalid argument supplied for foreach()&#8221;</p>
<p>[php]<br />
foreach($_POST['array'] as $key=&gt;$value) {<br />
		$wpdb-&gt;query(&#8220;UPDATE $playlists SET order =&#8217;&#8221; . $key . &#8220;&#8216; WHERE id =&#8217;&#8221; . $value . &#8220;&#8216;&#8221;);<br />
	}<br />
[/php]</p>
<p>any hints? the foreach looks perfectly alright to me. stumped.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Levi</title>
		<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/comment-page-1/#comment-690</link>
		<dc:creator>Levi</dc:creator>
		<pubDate>Wed, 21 Jan 2009 17:28:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=143#comment-690</guid>
		<description>Never mind I figured it out...  It was just a combination of me sending the wrong parameters to the server_items_reorder.php and missing a few brackets and parentheses.</description>
		<content:encoded><![CDATA[<p>Never mind I figured it out&#8230;  It was just a combination of me sending the wrong parameters to the server_items_reorder.php and missing a few brackets and parentheses.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Levi</title>
		<link>http://www.wiseguysonly.com/2008/12/07/drag-and-drop-reordering-of-database-fields-sortables-with-jquery/comment-page-1/#comment-688</link>
		<dc:creator>Levi</dc:creator>
		<pubDate>Wed, 21 Jan 2009 17:12:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.wiseguysonly.com/?p=143#comment-688</guid>
		<description>I have tried all three of these tutorials now in hopes that I might be able to get one of them to work.  

I had problems with Mootools because I could not find the ajax section of javascript from anywhere. (its not on there site any longer)

I had scriptaculous working minus the server side updating and I just tried this one (jQuery) and my Firebug Debugging Console keeps telling me &quot;missing } after property list.&quot;

For the life of me I cannot get this to work.  Any suggestions?  BTW, I am using a local server. Are there any settings relating to Ajax, that I need to change?</description>
		<content:encoded><![CDATA[<p>I have tried all three of these tutorials now in hopes that I might be able to get one of them to work.  </p>
<p>I had problems with Mootools because I could not find the ajax section of javascript from anywhere. (its not on there site any longer)</p>
<p>I had scriptaculous working minus the server side updating and I just tried this one (jQuery) and my Firebug Debugging Console keeps telling me &#8220;missing } after property list.&#8221;</p>
<p>For the life of me I cannot get this to work.  Any suggestions?  BTW, I am using a local server. Are there any settings relating to Ajax, that I need to change?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

