<?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>Emad Alashi&#039;s Blog &#187; list</title>
	<atom:link href="http://www.emadashi.com/index.php/tag/list/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emadashi.com</link>
	<description></description>
	<lastBuildDate>Sun, 15 Jan 2012 10:05:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Clear jQuery Droppable List</title>
		<link>http://www.emadashi.com/index.php/2009/05/clear-jquery-droppable-list/</link>
		<comments>http://www.emadashi.com/index.php/2009/05/clear-jquery-droppable-list/#comments</comments>
		<pubDate>Tue, 19 May 2009 18:25:19 +0000</pubDate>
		<dc:creator>Emad Alashi</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[clean]]></category>
		<category><![CDATA[clear]]></category>
		<category><![CDATA[destroy]]></category>
		<category><![CDATA[drag]]></category>
		<category><![CDATA[draggable]]></category>
		<category><![CDATA[drop]]></category>
		<category><![CDATA[droppable]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[list]]></category>

		<guid isPermaLink="false">http://www.emadashi.com/?p=269</guid>
		<description><![CDATA[The other day at work I finally had the chance to get my hands on code (see here why I&#8217;m so anxious about it   ).
We were using the jQuery&#8217;s Drag and Drop feature, where the droppable areas (DIV&#8217;s) are marked as droppable and registered for the events like the following:

  126 function RegisterDroppable(DomID) {
  128        $(&#8216;#&#8217; + [...]]]></description>
			<content:encoded><![CDATA[<p>The other day at work I finally had the chance to get my hands on code (see <a title="Technical Team Leader...Who Is Not" href="http://www.emadashi.com/index.php/2009/04/technical-team-leaderwho-is-not/" target="_blank">here</a> why I&#8217;m so anxious about it <img src='http://www.emadashi.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ).</p>
<p>We were using the jQuery&#8217;s Drag and Drop feature, where the droppable areas (DIV&#8217;s) are marked as droppable and registered for the events like the following:</p>
<div style="font-family: Courier New; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: #2b91af;">  126</span> <span style="color: blue;">function</span> RegisterDroppable(DomID) {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">  </span><span style="color: #2b91af;">128</span>        $(<span style="color: #a31515;">&#8216;#&#8217;</span> + DomID).droppable({</p>
<p style="margin: 0px;"><span style="color: #2b91af;">  129</span>             activeClass: <span style="color: #a31515;">&#8216;Droppable-active&#8217;</span>,</p>
<p style="margin: 0px;"><span style="color: #2b91af;">  130</span>             tolerance: <span style="color: #a31515;">&#8216;pointer&#8217;</span>,</p>
<p style="margin: 0px;"><span style="color: #2b91af;">  131</span>             hoverClass: <span style="color: #a31515;">&#8216;Droppable-hover&#8217;</span>,</p>
<p style="margin: 0px;"><span style="color: #2b91af;">  132</span>             drop: <span style="color: blue;">function</span>(ev, ui) {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">  133</span>                <span style="color: green;">//some code for the drop event here</span></p>
<p style="margin: 0px;"><span style="color: #2b91af;">  134</span> </p>
<p style="margin: 0px;"><span style="color: #2b91af;">  135</span>             }</p>
<p style="margin: 0px;"><span style="color: #2b91af;">  136</span>         });</p>
<p style="margin: 0px;"><span style="color: #2b91af;">  137</span>     }</p>
</div>
<p> The issue was that those droppable DIV&#8217;s were created at client side, and they would change upon a user interaction with the page (old DIV&#8217;s disappear and new droppable DIV&#8217;s are created), all at client side.<br />
The problem appeared when we tried to drag a &#8220;draggable&#8221; area AFTER changing the DIV&#8217;s the first time, the following javascript error showed:</p>
<p><strong> &#8220;Error: Unspecified error.&#8221;</strong></p>
<p>After investigating, it appeared that the plugin preserves a list of the droppables objects, and when we drag the &#8220;draggable&#8221; object, a loop that traverses the droppable objects would be called. But  those DIV&#8217;s do not really exist any more, hence the error shows up.</p>
<p>So the solution was to empty that list of lost references of the droppables so we can make a new clean droppables list, I did the following: </p>
<div style="font-family: Courier New; font-size: 10pt; color: black; background: white;">
<p style="margin: 0px;"><span style="color: #2b91af;">   87</span> <span style="color: blue;">var</span> drop = $.ui.ddmanager.droppables[<span style="color: #a31515;">'default'</span>];</p>
<p style="margin: 0px;"><span style="color: #2b91af;">   88</span> </p>
<p style="margin: 0px;"><span style="color: #2b91af;">   89</span>         <span style="color: blue;">var</span> count = drop.length;</p>
<p style="margin: 0px;"><span style="color: #2b91af;">   90</span>         <span style="color: blue;">for</span> (<span style="color: blue;">var</span> i = count; i &gt; 0; i-<span>-</span> ) {</p>
<p style="margin: 0px;"><span style="color: #2b91af;">   91</span>             drop[i-1].destroy();</p>
<p style="margin: 0px;"><span style="color: #2b91af;">   92</span>         }</p>
</div>
<p> </p>
<p>I couldn&#8217;t find better way to access the list, there was scarse information on the web for a solution, I hope this helps you just in case.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.emadashi.com/index.php/2009/05/clear-jquery-droppable-list/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

