JSTree 回调问题
来源:2-8 使用JSTree组件构建树形结构数据列表

lph0
2017-07-24
你好 我想用 jstree 自定义一个删除方法 配置如下:
<?= \yiidreamteam\jstree\JsTree::widget([
'containerOptions' => [
'class' => 'data-tree',
],
'jsOptions' => [
'core' => [
'check_callback' => true,
'multiple' => false,
'data' => [
// url获取分类接口
// [{"id" : 1, "text" : "服装", "children" : [{}, {}]}, {}]
'url' => \yii\helpers\Url::to(['project/categorytree', "page" => $page, "per-page" => $perpage]),
],
'themes' => [
"stripes" => true,
"variant" => "large",
]
],
"plugins" => [
'contextmenu', 'dnd', 'search', 'state', 'types', 'wholerow'
],
"contextmenu" => [
'items' =>[
'remove' => [
"label" => '删除'
]
]
],
]
]) ?>
js部分
<?php
$rename = yii\helpers\Url::to(['category/rename']);
$delete = yii\helpers\Url::to(['category/delete']);
$csrfvar = Yii::$app->request->csrfParam;
$csrfval = Yii::$app->request->getCsrfToken();
$js = <<<JS
$("#w0").on("remove.jstree", function(e, data){//删除
console.log("触发删除");
var id = data.node.id;
$.get('$delete', {id: id}, function(data){
if (data.code != 0) {
alert('删除失败:'+data.message);
window.location.reload();
}
});
})
JS;
$this->registerJs($js);
?>
但是函数触发不到,请大神指教
2回答
-
lph0
提问者
2017-07-27
包callback 回调不了,后面直接通过 引用 jstree.js,jstree.css的方式解决,觉得yii2 这种封装的插件对比 直接引用js 有好也有坏
012017-07-28 -
Jason
2017-07-25
看一下页面上面报JS错误了没,根据错误进行排查
00
相似问题