Note that there are some explanatory texts on larger screens.

plurals
  1. POKendo-Knockout - how to bind AutoComplete to remote data?
    text
    copied!<p>I using Kendo-Knockout.</p> <p>I am trying to get the AutoComplete to bind to remote data. Using the basic example at <a href="http://rniemeyer.github.com/knockout-kendo/web/AutoComplete.html" rel="nofollow">http://rniemeyer.github.com/knockout-kendo/web/AutoComplete.html</a> I've tried the following. However, <strong>search</strong> is not updated until the input has lost focus.</p> <p>"<strong>search</strong>" only looks for something if it is <strong>already</strong> in the observableArray. </p> <p>The only event provided with the Kendo Autocomplete is "change", which again only fires after the input has lost focus.</p> <p>How would you intercept the key press, and access the value of search() so that you can make a remote call?</p> <p>In additon, how would you access the value of '<strong>id</strong>' once the item has been selected?</p> <p>Thanks Jeremy </p> <pre><code>&lt;strong&gt;&lt;p style="margin-top: 100px;" data-bind="text: search"&gt;&lt;/p&gt;&lt;/strong&gt; &lt;input data-bind="kendoAutoComplete: { data: choices, value: search, dataTextField: 'name', valueUpdate: 'afterkeydown' }" /&gt; &lt;script type='text/javascript'&gt; $(function () { var myViewModel = function () { var self = this; this.choices = ko.observableArray([ { id: "1", name: "apple" }, { id: "1", name: "apple2" }, { id: "1", name: "apple3" }, { id: "2", name: "orange" }, { id: "3", name: "banana" } ]); this.selectedChoice = ko.observable(); self.search = ko.observable(); self.search.subscribe(function() { console.log(self.search()); // would send search to $.ajax to get the remote data }); }; ko.applyBindings(new myViewModel()); }); </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload