jstree - 完成AJAX后做一些事情

问题描述 投票:0回答:1

简单的问题,我想每次jstree AJAX加载完成时执行一些事情..例如$('[data-toggle="tooltip"]').tooltip(); ..

以下是我的代码:

$('#jstree').jstree({
  "core": {
    'themes': {
      //dots:false
    },
    'data': {
      'url': function(node) {
        return 'http://localhost:4044/admin/users/tree/get';
      },
      'success': function(){ //currently, this is not working
        $('[data-toggle="tooltip"]').tooltip();
      }
    }
  },
  'types': {
    'default': {
      "icon": "mdi mdi-account text-warning-dark",
    }
  },
  "plugins": [
    "types"
  ]
});
javascript ajax jstree
1个回答
1
投票

我不知道为什么......实际上success属性已经是正确的,但为了使tooltip工作,我需要将它包含在setTimeout内...

我写了下面的代码,它的确有效!

$('#jstree').jstree({
  "core": {
    'themes': {
      //dots:false
    },
    'data': {
      'url': function(node) {
        return 'http://localhost:4044/admin/users/tree/get';
      },
      'success': function(){
        setTimeout(function(){ //add setTimeout
          $('[data-toggle="tooltip"]').tooltip();
        }, 100);
      }
    }
  },
  'types': {
    'default': {
      "icon": "mdi mdi-account text-warning-dark",
    }
  },
  "plugins": [
    "types"
  ]
});
© www.soinside.com 2019 - 2024. All rights reserved.