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

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -