Dojo组合框[Enter]键事件终止数据存储响应

|| 我已经将dojo组合框配置如下:
this.autoComplete = new dijit.form.ComboBox( {
  id : this.name + \"_term\",
  name : \"search_id\",
  store : this.dataStore,
  searchAttr : \"term\",
  pageSize : \"30\",
  searchDelay:500,
  value : this.config.inputText,
  hasDownArrow : false
}, this.name + \"_term\");
这里的问题是,当用户输入搜索词并在500毫秒之前按[Enter]时,服务请求将被取消(在复制和粘贴搜索词时很常见)。我希望发生的事情是,它可以忽略[Enter]事件,直到请求完成并且下拉列表中显示选项。然后,用户可以再次按Enter键以提交响应中的第一项。 希望获得有关如何处理这种情况的一些建议。我已经浏览了dijit.form.ComboBox的api,但没有发现任何令人信服的解决方案。请注意,如果我使用FilteringSelect而不是ComboBox,则存在完全相同的行为。有趣的是,FilteringSelect将这种情况视为由\“ invalidMessage \”参数处理的错误。我不明白将其视为错误的好处。     
已邀请:
我(暂时)通过覆盖_onKeyPress函数来修补dijit.form.ComboBox来解决此问题。我正在使用dojo v1.5,并注意到v1.6将_onKeyPress更改为_onKey。因此,升级显然会破坏事情。 我已经更新了[Enter]事件处理,如下所示:
  case dk.ENTER:
    // prevent submitting form if user presses enter. Also
    // prevent accepting the value if either Next or Previous
    // are selected
    if(highlighted){
      // only stop event on prev/next
      if(highlighted == pw.nextButton){
        this._nextSearch(1);
        dojo.stopEvent(evt);
        break;
      }else if(highlighted == pw.previousButton){
        this._nextSearch(-1);
        dojo.stopEvent(evt);
        break;
      }
    }else{
      if (!module.autoComplete.item) {
        doSearch = true;
      }
      // Update \'value\' (ex: KY) according to currently displayed text
      this._setBlurValue(); // set value if needed
      this._setCaretPos(this.focusNode, this.focusNode.value.length); // move cursor to end and cancel highlighting
    }
    // default case:
    // prevent submit, but allow event to bubble
    evt.preventDefault();
    // fall through
    break;
有问题的代码是:
if (!module.autoComplete.item) {
  doSearch = true;
}
我基本上是告诉它仅在自动完成对象实例存在并且尚未收到任何项目时才进行搜索。这是一个丑陋的骇客,但目前正在解决该问题。我仍然会喜欢一些有关如何更好地处理此问题的建议。     

要回复问题请先登录注册