1

I have checked observableArray word declared in js file at top position.

I have been seen this function like this items: ko.observableArray([]). Is this function related to AJAX while response is getting and pushing json data in object ? or is it useful when pageload ? PLEASE someone clear this concept about observableArray

How it can be useful this function?

1

ko.observableArray is not much different from ko.observable , if you want to detect and respond to changes on one object, you’d use observables. If you want to detect and respond to changes of a collection of things, use an observableArray.

This function is not related to ajax directly in any way, it's use is same as obsevable with difference that it is used for arrays/ collection of items . But if you want that the updated values of a array/json are sent after updating a viewModel then you will have to declare it as observable or it will just send initial values.

Observable arrays are defined in the form of json objects as defined below ;

var observableArray = ko.observableArray([
    { name: "Bungle", type: "Bear" },
    { name: "George", type: "Hippo" },
    { name: "Zippy", type: "Unknown" }
]);

You can read up more about this here - http://knockoutjs.com/documentation/observableArrays.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.