【问题标题】:jstree - do something after AJAX donejstree - 在 AJAX 完成后做一些事情
【发布时间】:2019-04-26 04:36:12
【问题描述】:

简单的问题,我想在每次 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】:

    我不知道为什么...实际上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"
      ]
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-06
      • 1970-01-01
      • 2013-11-04
      • 2011-10-09
      • 1970-01-01
      • 2021-06-25
      • 1970-01-01
      • 2020-10-06
      相关资源
      最近更新 更多