类中有一个变量:
this.Grid; 这个变量用来指向该类的实例化后的对象。下面有个语句怎么老是过不去:var temp = "this.CheckBoxSelectAll.onclick = function(){SelectAllRow("+this.VV+")};"
eval(temp); 
alert(this.CheckBoxSelectAll.onclick);不知道怎么回事,总是倒不了alert;
分不多,请高手指点一二

解决方案 »

  1.   

    敲错了,
    var temp = "this.CheckBoxSelectAll.onclick = function(){SelectAllRow("+this.Grid+")};" 
      

  2.   

    不知道this的上下文是什么, 试试看var temp = "this.CheckBoxSelectAll.onclick = function(){SelectAllRow(this.Grid)};"
      

  3.   

    或者试试看 
    window.xxx = this.Grid;
    var temp = "this.CheckBoxSelectAll.onclick = function(){SelectAllRow(window.xxx)};"
      

  4.   

    这样子,设置this.CheckBoxSelectAll.onclick 属性的时候,不能取到变量的值嘛。
    所以搞了个eval(temp); 这句执行有问题
      

  5.   

    引号里的this肯定不会指向当前的上下文,应该是指向了window。所以eval会失败(因为找不到对象),然后抛异常,然后alert就到不了了。感觉没有必要eval,直接用
    his.CheckBoxSelectAll.onclick = function() {SelectAllRow(this.Grid);};
    这样应该是可以的。不知道你说的什么变量取不到值?
      

  6.   

    this.CheckBoxSelectAll.onclick = function(){SelectAllRow("+this.VV+")};
    alert(eval(this.CheckBoxSelectAll.click));
      

  7.   

    alert([this,this.CheckBoxSelectAll])
    eval('alert([this,this.CheckBoxSelectAll])')替换原来的语句执行下看看