setting.view.removeHoverDom.html 2.1 KB

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