$("#refresh").click(function(){
alert(111)
refreshTree();
});
上面方法中的refreshTree方法无法被调用
代码如下:
<script type="text/javascript">
$(function(){
$("#refresh").click(function(){
alert(111)
refreshTree();
});
});
var setting = {data:{simpleData:{enable:true,idKey:"id",pIdKey:"pId",rootPId:'0'}},
callback:{onClick:function(event, treeId, treeNode){
var id = treeNode.id == '0' ? '' :treeNode.id;
$('#officeContent').attr("src","${ctx}/sys/dict/list?type="+treeNode.id);
}
}
};
function refreshTree(){
$.getJSON("${ctx}/sys/dict/treeUserData?type=1",function(data){
$.fn.zTree.init($("#ztree"), setting, data).expandAll(true);
});
}
refreshTree();
var leftWidth = 230; // 左侧窗口大小
var htmlObj = $("html"), mainObj = $("#main");
var frameObj = $("#left, #openClose, #right, #right iframe");
function wSize(){
var strs = getWindowSize().toString().split(",");
htmlObj.css({"overflow-x":"hidden", "overflow-y":"hidden"});
mainObj.css("width","auto");
frameObj.height(strs[0] - 5);
var leftWidth = ($("#left").width() < 0 ? 0 : $("#left").width());
$("#right").width($("#content").width()- leftWidth - $("#openClose").width() -5);
$(".ztree").width(leftWidth - 10).height(frameObj.height() - 46);
}
</script>
你这提问相当不专业,场景一个都没说,到底是pc端还是移动端,还有你这应该是在混合模版文件里面吧?
说几个解决方案你试试吧:
1.首先看你这代码有没有报错,chorme里面f12后看console;
2.修改你的代码如下:
$(document).ready(function(){
}).on("click","#refresh",function(){
alert(111)
refreshTree();
});
3.建议你注重下代码结构,你这代码非常乱
$("#refresh").on("click", function() {
alert("OK" + playerId);
});
换成上面代码试试
不行啊,调用的refreshTree方法还是没有反应