现在,我有一个JSP页面,里面同时存在普通javascript的代码和layui的代码,我想调用layui里面的方法,该怎么引用?
这是javascript代码:
var treeSetting = { data: { simpleData: { enable: true, idKey: "id", pIdKey: "pId", rootPId: "root" } },
callback:{ onClick:function(event, treeId, treeNode) { openFile(treeNode.id,treeNode.name); tabAdd;我想要在这引用layui的方法,增加一个Tab } } }
这是layui:
layui.use('element', function(){ var $ = layui.jquery ,element = layui.element(); //Tab的切换功能,切换事件监听等,需要依赖element模块 //触发事件 var active = { tabAdd: function(fileId,fileName){ //新增一个Tab项 element.tabAdd('demo', { title: fileName //打开文件的文件名 ,content: '内容'+ (Math.random()*1000|0) ,id: fileId //打开文件的ID }) } ,tabDelete: function(othis){ //删除指定Tab项 element.tabDelete('demo', '44'); //删除:“商品管理” othis.addClass('layui-btn-disabled'); } ,tabChange: function(){ //切换到指定Tab项 element.tabChange('demo', '22'); //切换到:用户管理 } }; $('#ztree_attachment').on('click', function(){ var othis = $(this), type = othis.data('type'); active[type] ? active[type].call(this, othis) : ''; }); //Hash地址的定位 var layid = location.hash.replace(/^#test=/, ''); element.tabChange('test', layid); element.on('tab(test)', function(elem){ location.hash = 'test='+ $(this).attr('lay-id'); }); });
添加回答
举报
0/150
提交
取消
