68 lines
1.9 KiB
Plaintext
68 lines
1.9 KiB
Plaintext
|
|
@{
|
|
ViewBag.Title = "Index";
|
|
Layout = "~/Views/Shared/_Layout.cshtml";
|
|
}
|
|
|
|
<div class="x-body">
|
|
@*<ul id="menu"></ul>*@
|
|
<ul id="menu" class="dtree" data-id="0"></ul>
|
|
</div>
|
|
<script>
|
|
var selectRow = {};
|
|
|
|
//layui.use(['tree','layer'], function () {
|
|
// var layer = layui.layer
|
|
// , $ = layui.jquery;
|
|
|
|
// $.get('/Menu/GetMenuTreeJson', function (data) {
|
|
// //alert(data);
|
|
// //console.log(data);
|
|
// layui.tree({
|
|
// elem: '#menu' //指定元素
|
|
// , click: function (item) { //点击节点回调
|
|
// layer.msg('当前节名称:' + item.name + '<br>全部参数:' + JSON.stringify(item));
|
|
// console.log(item);
|
|
// }
|
|
// , nodes: data
|
|
// });
|
|
// });
|
|
|
|
// var active = {
|
|
// init: function () {
|
|
// $.get('/Menu/Init', function (data) {
|
|
// alert(data);
|
|
// console.log(data);
|
|
// });
|
|
// }
|
|
// };
|
|
|
|
|
|
// $('.layui-btn-group .layui-btn').on('click', function () {
|
|
// var othis = $(this), method = othis.data('method');
|
|
// active[method] ? active[method].call(this, othis) : '';
|
|
// });
|
|
|
|
//});
|
|
|
|
layui.config({
|
|
base: '/Scripts/layui_ext/dtree/' //配置 layui 第三方扩展组件存放的基础目录
|
|
}).extend({
|
|
dtree: 'dtree' //定义该组件模块名
|
|
}).use(['element', 'layer', 'dtree'], function () {
|
|
var layer = layui.layer,
|
|
dtree = layui.dtree,
|
|
$ = layui.$;
|
|
|
|
dtree.render({
|
|
elem: "#menu", //绑定元素
|
|
url: "/Menu/Index" //异步接口
|
|
});
|
|
|
|
//单击节点 监听事件
|
|
dtree.on("node('menu')", function (param) {
|
|
layer.msg(JSON.stringify(param));
|
|
});
|
|
});
|
|
|
|
</script> |