js模块化的使用

function createKnowledgeCategoryTree(_treeDivId){ var tree = $(_treeDivId).jstree({ json_data: { ajax: { type:"post", url : "event!getCategoryTree.action", data: {'types': 'knowledge'}, dataType: 'json' } }, "plugins" : [ "themes", "json_data", "ui", "crrm", "cookies", "dnd", "search", "types", "hotkeys"] }); $(_treeDivId).jstree("set_theme","apple"); return tree; } /**根据知识分类查询知识*/ selectEventCategory1=function(e,data){ var _name=data.rslt.obj.attr('cname'); var postData = $("#list").jqGrid("getGridParam", "postData"); $.extend(postData, {'knowledgeQueryDto.category': _name} ); //将postData中的查询参数覆盖为空值 var _url = 'knowledgeInfo!findAllKnowledges.action'; $('#list').jqGrid('setGridParam',{url:_url,page:1}) .trigger('reloadGrid').jqGrid('setGridParam',{url:_url,page:1}); } /**新增知识获取树节点的值*/ selectEventCategory2=function(e,data){ var _name=data.rslt.obj.attr('cname'); $("#add_knCategory").val(_name); $("#addKnowledgeCategoryDiv").window('close'); } /**编辑知识获取树节点的值*/ selectEventCategory3=function(e,data){ var _name=data.rslt.obj.attr('cname'); $("#edit_knCategory").val(_name); $("#addKnowledgeCategoryDiv1").window('close'); } /**搜索知识获取树节点的值*/ selectEventCategory4=function(e,data){ var _name=data.rslt.obj.attr('cname'); $("#search_knCategory").val(_name); $("#addKnowledgeCategoryDiv2").window('close'); } $(document).ready(function(){ var knowledgeCategory1 = createKnowledgeCategoryTree('#knowledgeCategoryTree1'); knowledgeCategory1.bind("select_node.jstree", selectEventCategory1); var knowledgeCategory2 = createKnowledgeCategoryTree('#knowledgeCategoryTree2'); knowledgeCategory2.bind("select_node.jstree", selectEventCategory2); var knowledgeCategory3 = createKnowledgeCategoryTree('#knowledgeCategoryTree3'); knowledgeCategory3.bind("select_node.jstree", selectEventCategory3); var knowledgeCategory4 = createKnowledgeCategoryTree('#knowledgeCategoryTree4'); knowledgeCategory4.bind("select_node.jstree", selectEventCategory4); });

 

 

data: {'types': 'knowledge'}   为action中的getCategoryTree方法传参数

你可能感兴趣的:(js模块化的使用)