setting.view.removeHoverDom.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(treeId, treeNode)</span><span class="path">setting.view.</span>removeHoverDom</h2>
  4. <h3>概述<span class="h3_info">[ 依赖 <span class="highlight_green">jquery.ztree.exedit</span> 扩展 js ]</span></h3>
  5. <div class="desc">
  6. <p></p>
  7. <div class="longdesc">
  8. <p>用于当鼠标移出节点时,隐藏用户自定义控件,显示隐藏状态同 zTree 内部的编辑、删除按钮</p>
  9. <p class="highlight_red">请务必与 <span class="highlight_red">addHoverDom</span> 同时使用;属于高级应用,使用时请确保对 zTree 比较了解。</p>
  10. <p>默认值:null</p>
  11. </div>
  12. </div>
  13. <h3>Function 参数说明</h3>
  14. <div class="desc">
  15. <h4><b>treeId</b><span>String</span></h4>
  16. <p>对应 zTree 的 <b class="highlight_red">treeId</b>,便于用户操控</p>
  17. <h4><b>treeNode</b><span>JSON</span></h4>
  18. <p>需要隐藏自定义控件的节点 JSON 数据对象</p>
  19. </div>
  20. <h3>setting & function 举例</h3>
  21. <h4>1. 设置鼠标移到节点上,在后面显示一个按钮</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>