FAQ Database Discussion Community


why knockout does not auto update by model changes?

javascript,knockout.js,knockout-2.0
in parse.com I opened up this account [email protected]/12345678. I forked https://github.com/tachang/knockout_tasklist which synchronizes knockout to parse.com and when i start up the app i do see as the only item sometitle1 however if I change sometitle1 to sometitle2 in parse.com task class i don't see this being relfected automatically in...

Css negation giving type error

knockout.js,knockout-2.0
In my model I have self.isAssetForTradingEnabled = false; and when I try to bind it to add some style like this: <tr data-bind="css: { 'selected': quantity() > 0 , 'disabled': !isAssetForTradingEnabled() }"> Then Knockout gives a type error. It works if I change isAssetForTradingEnabled = true; and 'disabled': isAssetForTradingEnabled ...

Knockout.js binding css/js libraries in header

javascript,knockout.js,knockout-2.0
Is it possible, to bind links and scripts(css/js) with knockout? I tried to bind it like: <!-- ko text: headerLibs --> <!--/ko --> But it is just text. Property headerLibs can contain from 0 to 10 different libs....

Knockout Validation not working with a DatePicker bindingHandler

javascript,jquery-ui,knockout.js,knockout-2.0,knockout-validation
So I am using Knockout Validation to validate my viewmodel and a custom knockout datepicker bindingHandler to attach a jQuery-UI datepicker to dynamically added items in my observableArray. It seems my bindingHandler is destroying or breaking the validation rules on that field. Neither of the validation rules for the Start...

Knockout Mapping Issue

knockout.js,knockout-2.0,knockout-mapping-plugin
i am new to Ko and mapping plugin. I have to read data from weather api of a city from http://api.openweathermap.org/data/2.5/history/city?q=Vancouver,%20ca and display it in UI using ko and mapping. However I have a issue in mapping and due to that the data is not appearing in UI. ko.mapping.fromJS(models, self.ArrayOfModels);...

knockout js foreach binding is not updating when used in custom element (components.register)

knockout.js,knockout-2.0
ko.components.register("toast-container", { viewModel: ToastViewModel, template: '<div data-bind="foreach: array1"><div data-bind="text:someText"> </div></div>' }); function ToastViewModel(params) { var self = this; self.array1 = ko.observableArray(); self.Onclick = function () { self.array1.push({ someText: "some content" }); } } $(function () { ko.applyBindings(new ToastViewModel()); }); When i push some content in array1 dynamically, the UI...

How do I implement multiple select lists ensuring only unique values are available to all?

knockout.js,knockout-2.0
I need to ensure uniqueness within my select lists. I have a list of available options: var viewModel = { availableOptions : ['Bicycle','Car','Shuttle','Motorcycle','Motorcycle'], items : [{id:1, selectedOption: ko.observable('Car')}, {id:2, selectedOption: ko.observable()}, {id:3, selectedOption: ko.observable()}] } I want to foreach through my items but ensure no two items can have the...

checkbox label enabled disabled knockoutjs

javascript,knockout.js,knockout-2.0
I have html form which is using knockout to manipulate enable/disable mode for controls. I have textbox control and checkbox control which are manipulated by a button, if the button is clicked then they can be edited, otherwise they are disabled. The problem is happening with the checkbox controls because...

Populating dropdownlist using knockout observable array

javascript,json,knockout-2.0,knockout-mvc
I am trying to bind 2 drop down lists to knockout observable arrays.The condition is that the first drop down list has to get populated first.The second drop down list is dependent on the first drop down list.Hence I am subscribing to the first drop down list to populate the...

KnockoutJS and Jquery how to fill combo dynamically

jquery,knockout.js,knockout-2.0
I have a form that uses 2 combos. The first combo is filled when the form is loaded and the second one is filled from server (ajax) depending on the first combo selection. Here is the ajax code for filling my supervisors combo: // here go and get employee supervisors...

Adding data-bind and static text in textarea using Knockout.js

javascript,knockout-2.0
I want to add both static text and a property to a text area. For example I want to display " [Development x] started work on [Start Date]" where Development_Name() and Start_Date() are properties that store the name and date respectively This is what the text area looks like and...

Knockout Dropdown list Initial Value

knockout.js,knockout-2.0
I am trying to setup the initial value of the dropdown list on button click event. But its not selecting the item. var viewModel = function () { this.itemsSingle = ko.observableArray([ { id: 1, name: "Apple" }, { id: 2, name: "Orange"}, { id: 3, name: "Banana"} ]); this.selected =...

jQuery DOM manipulation from Knockout ViewModel - use bindingHandlers?

javascript,knockout.js,knockout-2.0
I've got a knockout viewModel which looks like this: function myViewModel() { this.update = function() { ... } ... } And a bindingHandler which looks like this: ko.bindingHandlers.myBindingHandler = { init: function(element, valueAccessor, allBindings, viewModel) { function manipulateDom(element) { ... } } } I want myViewModel to call manipulateDom whenever...

Is new line a separator in Javascript

javascript,google-chrome,knockout.js,google-chrome-devtools,knockout-2.0
While debugging a web SPA issue, I stumbled on something to which I could not find concrete references online: missing comma separator between function expressions in javascript. Here's the details: This works - explicit comma as a separator is there (note - intentionally on one line): var f1 = function()...