日期:2014-05-16  浏览次数:20523 次

为什么这个判断不成立它还是会执行??
在用EXTJS 的panel
 

        for (a = 0; a < strspot.length; a++) {

                //    if (findpanel == "undefined") {
                var findpanel = Ext.getCmp(strspot[a]);
                alert(findpanel);
                if (findpanel != "undefined") {
                    Ext.create('Ext.Panel', {

                        height: 100,
                        width: 100,
                        id: strspot[a],
                        title: strspot[a],
                        renderTo: 'Div1',
                        closable: true,
                        frame: true,
                        componentCls: 'floatpl'//排序样式
                    })
                }


                //    alert("created")
                //  }
                //  else {
                //   alert("已经创建了"+strspot[a]);
                //  }
            }
        }

strspot 是一个数组 存的是名称
我的界面上有个Tree ,strspot 就是tree上的节点名称  
每单击一次节点添加一个panel
为了不重复添加 加上了一个判断
但我的结果如下图

第一个是我第一次单击添加的panel
第二个是我第二次单击后出现的、、、、 
求解~~
JavaScript 界面 Ext?JS