I am new to working with knockoutjs so need some assistance around what I am trying to achieve and best practise.
I am working on an mvc4 application where I am calling a controller action that returns json and I am then binding it to my view model eg.
$.getJSON("/cart/summary", function (data) {
myModel = ko.mapping.fromJS(items);
ko.applyBindings(myModel , document.getElementById("my-container"));
});
The myModel view model is a direct representation of the json object returned from the controller.
The object contains a property (Prop1) which is an object and another property (Prop2) with a list of objects.
Prop1 object contains a decimal property that I would like to format as currency using the Globalize plugin. What is the best practise, should this be done in the viewmodel and binded to the view? If so, how can I extend my model to do this? Or done in the view?
I want to show a div if Prop2 has more than 0 items, ie. its not empty. Similar question again, should I return a property signalling this or do it in the markup?
I would like to bind a property to append text to a div, how is this done?
Finally, after binding is completed, I would like to animate the fact that binding is complete - dont care what the affect is, just like to know how its done?
Thanks for any feedback.