jQuery EasyUI1.3.2 comobotree 组件弹出后自动滚动到选择的节点


  jQuery EasyUI1.3.2  comobotree 组件弹出后自动滚动到选择的节点

 

jQuery EasyUI1.3.2 comobotree 组件弹出后自动滚动到选择的节点

 

在加载完成Easyui JS加载完成后,添加默认事件:弹出后自动滚动到对应的节点。

 

<script type='text/javascript' src='/js/jquery.easyui-1.3.2.js'></script>
<script type='text/javascript' src='/js/jquery.easyui-extends.js'></script> //jquery.easyui-extends.js 的内容就是下面的那段代码

//当combotree弹出显示时自动滚动到对应位置
$.fn.combotree.defaults.onShowPanel = function(){
	var panel = $(this).combo('panel');//取得面板
	var value = $(this).combo("getValue");//取得当前值
	var item = panel.find("div[node-id='" + value + "']");//找到树节点
	if (item.length){
		if (item.position().top <= 0){
			var h = panel.scrollTop() + item.position().top;
			panel.scrollTop(h);
		} else if (item.position().top + item.outerHeight() > panel.height()){
			var h = panel.scrollTop() + item.position().top + item.outerHeight() - panel.height();
			panel.scrollTop(h);
		}
	}
};

  

  

你可能感兴趣的:(JavaScript,easyui)