Note that there are some explanatory texts on larger screens.

plurals
  1. POUse Dojo Drag and Drop together with Dojo Moveable
    text
    copied!<p>I'm using Dojo.dnd to transfer items between to areas. The problem is: the items will snap into place once I drop them, but I'd like to have them stay where I drop them, but only for one area.</p> <p>Here's a little code to explain this better:</p> <pre><code> &lt;div id="dropZone" class="dropZone"&gt; &lt;div id="itemNodes"&gt;&lt;/div&gt; &lt;div id="targetZone" dojoType="dojo.dnd.Source"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>"dropZone" is a DIV that contains two <code>dojo.dnd.Source</code>-areas, "itemNodes" (created programmatically) and "targetZone". Items (DIVs with images) should be dragged from a simple list out of "itemNodes" into "targetZone" and stay where they are dropped. As soon as they are dragged out of "targetZone" they should snap back to the list inside "itemNodes".</p> <p>Here's the code I use to create the items:</p> <pre><code> var nodelist = new dojo.dnd.Source("itemNodes"); {Smarty-Loop} nodelist.insertNodes(false, ['&lt;img class="dragItem" src="{$items-&gt;info.itemtext}" alt="{$items-&gt;info.itemtext}" border="0" /&gt;']); {/Smarty-Loop} </code></pre> <p>But this way I just have two lists of items, the items dropped into "targetZone" won't stay where I dropped them. I've tried a loop <code>dojo.query(".dojoDndItem").forEach(function(node)</code> to grab all items and change them to a "moveable"-type:</p> <ul> <li>using <code>dojo.dnd.move.constrainedMoveable</code> will change the items so they can <em>always</em> be moved around (even in "itemNodes")</li> <li>using <code>dojo.dnd.move.boxConstrainedMoveable</code> and defining the "box" to the borders of "targetZone" makes it possible to just move the items around inside "targetZone", but as soon as I drop them, I can't grab and move them back out. (Strange: <code>dojo.connect(node, "onMoved"</code> doesn't work here, the even won't fire, no matter what.)</li> </ul> <p>So here's the question: is it possible to create two dnd.Sources where I can move items back and forth and let the items be "moveable" only in one of the sources?<br />Or is there a workaround like making the items moveable and if they're not dropped into "targetZone" they'll be moved back to the list in "itemNodes" automatically?</p> <p>Once the page is submitted, I have to save the position of every item that has been placed into "targetZone". (The next step will be positioning the items inside "targetZone" on page load if the grid has already been filled before, but I'd be happy to just get the thing working in the first place.)</p> <p>Any hint is appreciated.</p> <p>Greetings, Select0r</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload