Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/408.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript YUI:字符串可以工作,但是包含字符串的变量不能工作?_Javascript_Yui - Fatal编程技术网

Javascript YUI:字符串可以工作,但是包含字符串的变量不能工作?

Javascript YUI:字符串可以工作,但是包含字符串的变量不能工作?,javascript,yui,Javascript,Yui,我不知道为什么,但是上面的代码没有为我的表中的每一行生成DDProxy对象。我已经通过向DOM元素传递字符串引用来验证DDProxy代码是否已正确加载和运行: var allRows = this.getTbodyEl().rows; for (var i = allRows.length - 1; i >= 0; i--){ var thisRowID = allRows[i].id; // Clean up any existing Drag instances if (myDT

我不知道为什么,但是上面的代码没有为我的表中的每一行生成DDProxy对象。我已经通过向DOM元素传递字符串引用来验证DDProxy代码是否已正确加载和运行:

var allRows = this.getTbodyEl().rows;
for (var i = allRows.length - 1; i >= 0; i--){
 var thisRowID = allRows[i].id;
 // Clean up any existing Drag instances
 if (myDTDrags[thisRowID]) {
    myDTDrags[thisRowID].unreg();
    delete myDTDrags[thisRowID];
 }
 // Create a Drag instance for each row
 myDTDrags[thisRowID] = new YAHOO.util.DDProxy(thisRowID);
};
这使得相应的行可以按预期拖动!我还使用typeof验证了thisRowID的值确实是“string”类型,并且该字符串包含相应行元素的id


我错过了什么?

更新:我上面发布的代码是正确的。我错了,因为我的thisRowID变量的内容没有包含对适当行元素的引用

迷人。如果是我,我会看到如果我将“thisRowID”设置为
新字符串(allRows[I].id)
会发生什么,但我很奇怪。干得好!我为你感到高兴。通常,当事情看起来不可能是真的时,它就不是:-)
myDTDrags[thisRowID] = new YAHOO.util.DDProxy('yui-rec30');