What’s the difference between ko.utils.unwrapObservable and ko.toJS?

There are differences between them. The ko.toJS takes an object and “opens up” and cleans the object from all observables. It does this for the entire object graph. I behaves much like a serializer which means that you’ll run into problems if you have circular references for instance. It uses mapJsObjectGraph internally which is way … Read more

Knockout Subscribe to any change in observable complex object

You can use the following trick: ko.computed(function() { return ko.toJSON(complexObject); }).subscribe(function() { // called whenever any of the properties of complexObject changes }); See http://jsfiddle.net/xcajt4qn/3/ The reason why this works is ko.toJSON will recursively read all the properties in the object, therefore making the computed depend on all the properties.

How can I do a knockout binding to a backgroundImage URL?

You need to concatenate your strings: data-bind=”style: { backgroundImage: ‘url(\” + image() + ‘\’)’ }” If image is actually an observable, you’ll need to call it, or you’ll end up concatenating the function instead. Note that since you’re binding to an expression involving the property, you must call the function (with ()). Otherwise, you will … Read more

knockout viewmodel property undefined

So, there are a few options that you have: KO will have an issue when you try to bind against undefined properties, unless they are off of an object. So, you can prefix your various bindings with $data. and KO will be able to parse your bindings. Sample: http://jsfiddle.net/rniemeyer/dLCL8/ If you know that several properties … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)