触发JQuery autocompleteselect时获取ASP.NET WebForms ComboBox元素

时间:2018-06-09 09:44:45

标签: javascript jquery asp.net webforms jquery-ui-autocomplete

当JQuery select被触发时,如何获取基础autocompleteselect元素?我需要该元素来激活它onchange()。底层select元素是ASP.NET DropDown控件。这是代码:

this._on(this.input, {
        autocompleteselect: function (event, ui) {
               var ele = this; //<---not working
               ui.item.option.selected = true;
               this._trigger("select", event, {
               item: ui.item.option
             });
        },

        autocompletechange: "_removeIfInvalid"
        });

1 个答案:

答案 0 :(得分:0)

最后我明白了:

autocompleteselect: function (event, ui) {

      ui.item.option.selected = true;
      this._trigger("select", event, {
                         item: ui.item.option
                   });

      var underlyingEle = document.getElementById(
      ui.item.option.parentElement.id // <-- fetching the underlying select element
      ); 
      underlyingEle.onchange();
}

希望这有助于将来的某些人。 :)