setting.view.addHoverDom.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(treeId, treeNode)</span><span class="path">setting.view.</span>addHoverDom</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 display custom control when mouse move over the node. (e.g. the rename and remove button)</p>
  9. <p class="highlight_red">If you use this function, so must set <span class="highlight_red">setting.view.removeHoverDom</span>, please make sure that a better understanding of zTree before you use it.</p>
  10. <p>Default: null</p>
  11. </div>
  12. </div>
  13. <h3>Function Parameter Descriptions</h3>
  14. <div class="desc">
  15. <h4><b>treeId</b><span>String</span></h4>
  16. <p>zTree unique identifier: <b class="highlight_red">treeId</b>, easy for users to control.</p>
  17. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  18. <p>JSON data object of the node which need to display the custom control.</p>
  19. </div>
  20. <h3>Examples of setting & function</h3>
  21. <h4>1. Display a button when mouse move over the node, and hide the button when mouse move out.</h4>
  22. <pre xmlns=""><code>var setting = {
  23. view: {
  24. addHoverDom: addHoverDom,
  25. removeHoverDom: removeHoverDom,
  26. ......
  27. }
  28. };
  29. function addHoverDom(treeId, treeNode) {
  30. var aObj = $("#" + treeNode.tId + "_a");
  31. if ($("#diyBtn_"+treeNode.id).length>0) return;
  32. var editStr = "&lt;span id='diyBtn_space_" +treeNode.id+ "' &gt;&nbsp;&lt;/span&gt;"
  33. + "&lt;button type='button' class='diyBtn1' id='diyBtn_" + treeNode.id
  34. + "' title='"+treeNode.name+"' onfocus='this.blur();'&gt;&lt;/button&gt;";
  35. aObj.append(editStr);
  36. var btn = $("#diyBtn_"+treeNode.id);
  37. if (btn) btn.bind("click", function(){alert("diy Button for " + treeNode.name);});
  38. };
  39. function removeHoverDom(treeId, treeNode) {
  40. $("#diyBtn_"+treeNode.id).unbind().remove();
  41. $("#diyBtn_space_" +treeNode.id).unbind().remove();
  42. };
  43. ......</code></pre>
  44. </div>
  45. </div>