setting.callback.beforeAsync.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <div class="apiDetail">
  2. <div>
  3. <h2><span>Function(treeId, treeNode)</span><span class="path">setting.callback.</span>beforeAsync</h2>
  4. <h3>Overview<span class="h3_info">[ depends on <span class="highlight_green">jquery.ztree.core</span> js ]</span></h3>
  5. <div class="desc">
  6. <p></p>
  7. <div class="longdesc">
  8. <p>This callback is made before zTree makes an ajax request, giving you an opportunity to decide if it should proceed or not.
  9. Return false to prevent zTree from sending the ajax request.</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>.</p>
  17. <h4 class="topLine"><b>treeNode</b><span>JSON</span></h4>
  18. <p>JSON data object of the parent node</p>
  19. <p class="highlight_red">When asynchronously loading the root, treeNode = null</p>
  20. <h4 class="topLine"><b>Return </b><span>Boolean</span></h4>
  21. <p>return true or false</p>
  22. <p class="highlight_red">If the function returns false, zTree will not send the ajax request, and will not trigger the 'onAsyncSuccess / onAsyncError' callback.</p>
  23. </div>
  24. <h3>Examples of setting & function</h3>
  25. <h4>1. If the parent node's attribute 'id' is 1, don't send the ajax request.</h4>
  26. <pre xmlns=""><code>function myBeforeCallBack(treeId, treeNode) {
  27. return (treeNode.id !== 1);
  28. };
  29. var setting = {
  30. callback: {
  31. beforeAsync: myBeforeCallBack
  32. }
  33. };
  34. ......</code></pre>
  35. </div>
  36. </div>