<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
  <channel>
    <title>Recent Posts in 'Drag &amp; drop question about revert behavior' | Pragmatic Forums</title>
    <link>http://fora.pragprog.com/forums/45/topics/387</link>
    <language>en-us</language>
    <ttl>60</ttl>
    <description></description>
    <item>
      <title>Drag &amp;amp; drop question about revert behavior posted by Christophe Porteneuve @ Sat, 26 Apr 2008 18:54:10 -0000</title>
      <description>&lt;p&gt;Glad I could help.  Keep reading! :-)&lt;/p&gt;</description>
      <pubDate>Sat, 26 Apr 2008 18:54:10 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:45:387:2647</guid>
      <author>Christophe Porteneuve</author>
      <link>http://fora.pragprog.com/forums/45/topics/387</link>
    </item>
    <item>
      <title>Drag &amp;amp; drop question about revert behavior posted by Jeff Cohen @ Sat, 26 Apr 2008 13:29:50 -0000</title>
      <description>&lt;p&gt;That worked perfectly!  Awesome.&lt;/p&gt;


	&lt;p&gt;And now I see it&amp;#8217;s explained on p. 289 in the description of the revert option.  I totally missed it before even though I read that section.&lt;/p&gt;


	&lt;p&gt;Thanks again.&lt;br /&gt;Jeff&lt;/p&gt;</description>
      <pubDate>Sat, 26 Apr 2008 13:29:50 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:45:387:2643</guid>
      <author>Jeff Cohen</author>
      <link>http://fora.pragprog.com/forums/45/topics/387</link>
    </item>
    <item>
      <title>Drag &amp;amp; drop question about revert behavior posted by Christophe Porteneuve @ Sat, 26 Apr 2008 12:11:39 -0000</title>
      <description>&lt;p&gt;Hey Jeff,&lt;/p&gt;


	&lt;p&gt;I believe the special &lt;code&gt;'failure'&lt;/code&gt; value for the &lt;code&gt;revert&lt;/code&gt; option is exactly what you&amp;#8217;re looking for: it will trigger the revert effect only if the drop failed (if the piece was refused on dropping).  This occurs &lt;strong&gt;after&lt;/strong&gt; any custom checking on the &lt;code&gt;Dropppables&lt;/code&gt; side (including custom &lt;code&gt;accept&lt;/code&gt;/@containment@&#8230;&lt;/p&gt;


	&lt;p&gt;Let me know if that cut it out for you!&lt;/p&gt;


	&lt;p&gt;Cheers,&lt;/p&gt;</description>
      <pubDate>Sat, 26 Apr 2008 12:11:39 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:45:387:2642</guid>
      <author>Christophe Porteneuve</author>
      <link>http://fora.pragprog.com/forums/45/topics/387</link>
    </item>
    <item>
      <title>Drag &amp;amp; drop question about revert behavior posted by Jeff Cohen @ Sat, 26 Apr 2008 04:55:59 -0000</title>
      <description>&lt;p&gt;Hi,&lt;/p&gt;


	&lt;p&gt;Just wondering if there&amp;#8217;s any known technique to cancel the revert action of a draggable depending on where it&amp;#8217;s dropped?&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;m using Rails to build a simple chess app as a demo for a Rails class.  Players can drag pieces to move them on the board.  I&amp;#8217;m successfully using the &lt;code&gt;accept&lt;/code&gt; parameter to help restrict where a piece can land (empty square or enemy square). If dropped on an acceptable square, the drop succeeds and it calls the controller as expected.&lt;/p&gt;


	&lt;p&gt;But when dropped on an invalid square, the controller is not called (which is good), but the piece remains where it was dropped (which is bad). I&amp;#8217;d like the piece to be reverted if the drop is not on an acceptable region.  If I use &lt;code&gt;:revert =&amp;gt; true&lt;/code&gt; on the draggable element, it will always revert even on a valid move, which causes a flash effect since it reverts and then the board updates with the new position right after that.&lt;/p&gt;


	&lt;p&gt;I actually expected this to be the default behavior when I first learned about the &lt;code&gt;accept&lt;/code&gt; option using &lt;span class="caps"&gt;CSS&lt;/span&gt; classes.  If a piece is not dropped on an acceptable region, then of course it should be reverted, no?&lt;/p&gt;


	&lt;p&gt;Is there any way to achieve this functionality, either with &lt;span class="caps"&gt;RJS&lt;/span&gt; (hopefully?) or with direct Javascript?&lt;/p&gt;


	&lt;p&gt;Thanks!&lt;br /&gt;Jeff&lt;/p&gt;</description>
      <pubDate>Sat, 26 Apr 2008 04:55:59 -0000</pubDate>
      <guid isPermaLink="false">fora.pragprog.com:45:387:2641</guid>
      <author>Jeff Cohen</author>
      <link>http://fora.pragprog.com/forums/45/topics/387</link>
    </item>
  </channel>
</rss>
