MzTree2.0梅花雪树单击Node页面跳动问题解决及单击展开子节点

MzTree梅花雪树单击Node页面跳动问题解决及单击展开子节点


问题:
1.
梅花雪树2.0 中单击一个URL: #的节点的时候,会是页面跳动到最顶部,很麻烦,影响使用
2.
梅花雪树2.0 中单击节点名称展开子节点功能实现


故修改了mztreeview2\scripts\system\web\ui\webcontrols 下的mztreeview.js文件
添加了2个 String 方法:endsWith 和 startsWith
并且修改了
//private: attachEvent tree onClick
MzTreeView.prototype.clickHandle = function(e) 方法

代码如下:

//public:String startsWith endsWith  by feiding 20091209
String.prototype.startsWith = function(prefix) {
    return this.indexOf(prefix) == 0;
};

String.prototype.endsWith = function(suffix) {
    return this.match(suffix+"$") == suffix;
};

//private: attachEvent tree onClick update by feiding 20091209
MzTreeView.prototype.clickHandle = function(e)
{
  e = window.event || e; var B;
  e = e.srcElement || e.target;
  if(B=(e.id && 0==e.id.indexOf(this.index +"_")))
  {
    var n=this.currentNode=this.nodes[e.id.substr(e.id.lastIndexOf("_")+1)];
  }
  switch(e.tagName)
  {
    case "IMG" :
      if(B)
      {
        if(e.id.indexOf(this.index +"_expand_")==0){
          n.expanded ? n.collapse() : n.expand();}
        else if(e.id.indexOf(this.index +"_icon_")==0){
          n.focus();}
        else if(e.id.indexOf(this.index +"_checkbox_")==0){
          n.check(!n.checked); n.upCheck();}
      }
      break;
    case "A":
        if(e.href.endsWith("#")){
        {
            e=this.nodes[e.id.substr(e.id.lastIndexOf("_") +1)];
            e.expanded ? e.collapse() : e.expand();
            this.currentNode=e;
            n.focus();
        }
        window.event.returnValue = false; 

    }else{
        if(B){ n.focus(); this.dispatchEvent(new System.Event("onclick"));}
    }
      break;
    default :
      if(System.ns) e = e.parentNode;
      break;
  }
};



附件上传 梅花雪树2.0 ---MzTreeView20.rar  的 未修改的 完整文件
至此问题解决。。。。。hoho。。。仅此记录解决方法。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值