Guest User

Untitled

a guest
May 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. $.getJSON(application_area, function(area){
  2. try{
  3. (function ($, undefined) {
  4. $.jstree.defaults.conditionalselect = function () { return true; };
  5. $.jstree.plugins.conditionalselect = function (options, parent){
  6. this.activate_node = function (obj, e) {
  7. if(this.settings.conditionalselect.call(this, this.get_node(obj))) {
  8. parent.activate_node.call(this, obj, e);
  9. }
  10. };
  11. };
  12. })(jQuery);
  13. createJSTree(area)
  14. }catch(ex){
  15. console.log(ex)
  16. }
  17. });
  18.  
  19. function createJSTree(area) {
  20. $("#search_tree").keypress(function(){
  21. var searchString = $(this).val();
  22. $("#tree").jstree('search', searchString);
  23. })
  24.  
  25.  
  26. var j1 = $('#tree')
  27. const pplication_area = []
  28.  
  29. j1.jstree({
  30. "conditionalselect" : function (node) {
  31. return node.parent === '#' || node.parent === "1" || node.parent === "415" ? false : true;
  32. },
  33. 'core': {
  34. "multiple": true,
  35. "themes": {
  36. "theme": "classic",
  37. "dots": true,
  38. "variant": "small",
  39. "icons": false,
  40. "responsive":true,
  41. },
  42. 'data':area
  43. },
  44. "search":{
  45. "case_insensitive":true,
  46. "show_only_matches":true
  47. },
  48. "checkbox": {
  49. "keep_selected_style": false,
  50. },
  51. "plugins": ["wholerow", "checkbox", "search","conditionalselect"],
  52. }).bind("before.jstree", function (e, data) {
  53. if (data.func === "check_node") {
  54. if (j1.jstree('get_checked').length >= 1) {
  55. e.preventDefault();
  56. return false;
  57. }
  58. }
  59. });
  60. }
Add Comment
Please, Sign In to add comment