knockout.js api search form -


the goal of code search on api search string:

so if fill out form hits bij name.

i used following knockout.js script:

var viewmodel= {     query : ko.observable("wis"), };  function employeesviewmodel(query) {     var self = this;     self.employees = ko.observablearray();     self.query = ko.observable(query);     self.baseuri = base + "/api/v1/search?resource=employees&field=achternaam&q=";      self.apiurl = ko.computed(function() {         return self.baseuri + self.query();     }, self);     //$.getjson(baseuri, self.employees);     //$.getjson(self.baseuri, self.employees);     $.getjson(self.apiurl(), self.employees); };  $(document).ready(function () {     ko.applybindings(new employeesviewmodel(viewmodel.query())); }); 

the html binding is:

<input type="text" class="search-query" placeholder="search" id="global-search" data-bind="value: query, valueupdate: 'keyup'"/> 

but if fill text box onley default "wis" employees? doing wrong?

not entirely sure wrong here, have debugged , seen value of query in apiurl?

one potential issue passing employees getjson observable, not underlying array, try:

$.getjson(self.apiurl(), self.employees()); 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -