extjs如何动态添加treenode的click响应事件 各位,我的extjs页面有个树形菜单,请问能不能利用for循环动态地帮子节点加上click响应函数?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 直接监听它的click事件啊listeners:{ click:function(node,event){ event.stopEvent();//阻止默认的事件 if(node.isLeaf()){ //叶子节点事件处理 }else{ node.toggle(); } }} 添加完成后,重新绑定它的click事件嘛 请教一下如何重新绑定??麻烦能不能说得具体点??比如root是根节点,是否用for循环遍历node.childNodes[i]?? 请教一下如何重新绑定??麻烦能不能说得具体点??比如root是根节点,是否用for循环遍历root.childNodes[i]??(上面打错) 添加的是Node node吧?node.on("click",function(){//do something here}); 已经解决了,把代码贴出来共享一下:for(var j=0;j<root.data.items.length;j++){ var wz=new Ext.tree.TreeNode({ text:storeNews.getAt(j).get('title'), listeners:{ "click":function(node,event){ event.stopEvent(); //alert(node.text); addNewsTab(node.text,node.attributes.author, node.attributes.date,node.attributes.neirong); } } }); //动态子节点和响应函数addNewsTab()所需要的参数 wz.attributes={ author:storeNews.getAt(j).get('author'), date:storeNews.getAt(j).get('date'), neirong:storeNews.getAt(j).get('neirong')}; root.appendChild(wz);} 图片编辑 急求哪位大神帮我解决这个问题,其实挺容易,只是我不熟悉 js能否跨域操作? 求助地址带#号的图片库是怎么实现的 求助!=====限制表格某列操作的问题===== ▲关于Asp跳转页面的难题,高分求助! ▲ 模态窗口中框架页面的提交如何只提交框架页 而不是整个模态窗口 怎样在文本域中输出换行符? 面对网络的疑惑,请高手解答! ligerComboBox设置默认值问题 iframe兼容问题,查询不支持中文 yui框架 谁用过 哪位大哥能给点 学习资料吗
click:function(node,event){
event.stopEvent();//阻止默认的事件
if(node.isLeaf()){
//叶子节点事件处理
}else{
node.toggle();
}
}
}
比如root是根节点,是否用for循环遍历node.childNodes[i]??
比如root是根节点,是否用for循环遍历root.childNodes[i]??(上面打错)
node.on("click",function(){
//do something here
});
for(var j=0;j<root.data.items.length;j++)
{
var wz=new Ext.tree.TreeNode({
text:storeNews.getAt(j).get('title'),
listeners:{
"click":function(node,event){
event.stopEvent();
//alert(node.text);
addNewsTab(node.text,node.attributes.author,
node.attributes.date,node.attributes.neirong);
}
}
}); //动态子节点和响应函数addNewsTab()所需要的参数
wz.attributes={ author:storeNews.getAt(j).get('author'),
date:storeNews.getAt(j).get('date'),
neirong:storeNews.getAt(j).get('neirong')};
root.appendChild(wz);
}