setting.callback.onDrop.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(event, treeId, treeNodes, targetNode, moveType, isCopy)</span><span class="path">setting.callback.</span>onDrop</h2>
  4. <h3>Overview<span class="h3_info">[ depends on <span class="highlight_green">jquery.ztree.exedit</span> js ]</span></h3>
  5. <div class="desc">
  6. <p></p>
  7. <div class="longdesc">
  8. <p>Used to capture the drop event when drag-drop node.</p>
  9. <p class="highlight_red">If you set 'setting.callback.beforeDrop',and return false, zTree will restore the dragged nodes, and will not trigger the 'onDrop' callback.</p>
  10. <p>Default: null</p>
  11. </div>
  12. </div>
  13. <h3>Function Parameter Descriptions</h3>
  14. <div class="desc">
  15. <h4><b>event</b><span>js event Object</span></h4>
  16. <p>event Object</p>
  17. <h4 class="topLine"><b>treeId</b><span>String</span></h4>
  18. <p>zTree unique identifier: <b class="highlight_red">treeId</b>, the id of the containing tree.</p>
  19. <h4 class="topLine"><b>treeNodes</b><span>Array(JSON)</span></h4>
  20. <p>A collection of the nodes which has been dragged</p>
  21. <p class="highlight_red">The treeNodes are the data of the nodes which be dragged, when move nodes.</p>
  22. <p class="highlight_red">The treeNodes are the clone data of the nodes which be dragged, when copy nodes.</p>
  23. <h4 class="topLine"><b>targetNode</b><span>JSON</span></h4>
  24. <p>JSON data object of the target node which treeNodes are drag-dropped.</p>
  25. <p class="highlight_red">If the treeNodes will be root node, the targetNode = null</p>
  26. <h4 class="topLine"><b>moveType</b><span>String</span></h4>
  27. <p>the relative position of move to the target node</p>
  28. <p class="highlight_red">"inner": will be child of targetNode</p>
  29. <p class="highlight_red">"prev": will be sibling node, and be in front of targetNode</p>
  30. <p class="highlight_red">"next": will be sibling node, and be behind targetNode</p>
  31. <p class="highlight_red">If moveType is null, means drag & drop is cancel.</p>
  32. <h4 class="topLine"><b>isCopy</b><span>Boolean</span></h4>
  33. <p>the flag used to judge copy node or move node</p>
  34. <p class="highlight_red">true: copy node; false: move node</p>
  35. </div>
  36. <h3>Examples of setting & function</h3>
  37. <h4>1. When drag-drop nodes complete, alert the number of dragged nodes and info about targetNode.</h4>
  38. <pre xmlns=""><code>function myOnDrop(event, treeId, treeNodes, targetNode, moveType) {
  39. alert(treeNodes.length + "," + (targetNode ? (targetNode.tId + ", " + targetNode.name) : "isRoot" ));
  40. };
  41. var setting = {
  42. callback: {
  43. onDrop: myOnDrop
  44. }
  45. };
  46. ......</code></pre>
  47. </div>
  48. </div>