'选择'在xtype组合中的监听器,与IF的范围问题?

时间:2014-12-16 23:19:15

标签: javascript listener openlayers extjs3 geoext

我想知道这是否是范围问题。问题是我在xtype combo(extjs3.4)中选择了一个选项,并且首先可以在if部分(附加图像)的外部和内部读取该选项。现在,当我选择另一个选项时,该选择仅在if部分之外读取(即,它不在其中读取)。这是范围的正常问题吗?如果是的话,我怎么解决呢?

enter image description here

listeners: {
  'select': function(combo, record) {
    var comboLayer = this.getValue();
    var rawLayer = this.getRawValue();
    var loadedLayers = [];
    for(var i = 0; i < mapPanel.map.layers.length; i++) {
      loadedLayers.push(mapPanel.map.layers[i].name);
    }
    console.log('outsideIf: ' + loadedLayers);
    console.log('outsideIf: ' + rawLayer);
    console.log('outsideIf: ' + comboLayer);
    if (loadedLayers.indexOf(rawLayer) > -1) {
      console.log('insideIf: ' + loadedLayers);
      console.log('insideIf: ' + rawLayer);
      console.log('insideIf: ' + comboLayer);
      newUrl = '/pg?layers=' + comboLayer;
      protocol.options.url = newUrl;
    }
  }
}

0 个答案:

没有答案