This is a migrated thread and some comments may be shown as answers.

[Solved] Onchange only fires when autocompletebox is deselected

1 Answer 140 Views
AutoCompleteBox for HTML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nikhil
Top achievements
Rank 1
Nikhil asked on 26 Nov 2013, 04:19 AM

Hello,

I'm trying to use populate the autocomplete box using a remote data source. This remote data source requires a query to be included in the URL. So I'd like to:

  1. Listen for a change in the value of the autocompletebox
  2. If there is a change then get the current value of the autocompletebox
  3. Get the current value and use that in my query to my remote data source, query data source
  4. Repeat (i.e. continue to listen)

The problem I'm running into is that the change events on the autocomplete box don't fire until I click off of the autocompletebox. Is there a way to listen for a change even when the autocompletebox is active?

Currently using:

var autoComplete = new Telerik.UI.RadAutoCompleteBox(document.getElementById("autocompleteBox"), {
    placeholder: 'Input',
    dataSource: customersSource,
    dataTextField: "name",
    //onchange: function (e) { new Windows.UI.Popups.MessageDialog("Message", "Title").showAsync().done(); }
});
var autocompletes = document.getElementById("autocompleteBox").winControl;
autocompletes.addEventListener("change", this.searchYahoo);

My eventListener is:

searchYahoo: function (eventInfo) {
    new Windows.UI.Popups.MessageDialog("Message", "Title").showAsync().done();
}

I get the same behavior when using onchange: during initialization.

Thanks,
Nikhil

1 Answer, 1 is accepted

Sort by
0
Nikhil
Top achievements
Rank 1
answered on 26 Nov 2013, 04:29 AM
Nevermind, I was getting thrown off by the "onchange" during initialization, I just needed to make my eventListener wait for "keydown" not "change".
Tags
AutoCompleteBox for HTML
Asked by
Nikhil
Top achievements
Rank 1
Answers by
Nikhil
Top achievements
Rank 1
Share this question
or