Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7675059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:52:34+00:00 2026-05-31T16:52:34+00:00

In KnockoutJS, what’s the proper way to update an observableArray of JSON data each

  • 0

In KnockoutJS, what’s the proper way to update an observableArray of JSON data each time an AJAX command is run?

Right now, I’m blanking the array using something like viewmodel.items([]), then repopulating it with the JSON data from the server. Short of using the KnockoutJS mapping plugin (which might be the only way to do this) what is the correct path?

My server logic is going to send some of the same data each time, so I can’t just iterate and push the items into the array unless I want duplicates.

//// Adding how I’m doing it today ////

I’m not sure why I’m doing it this way, but this is just how I initially figured out how to update. So basically, like I said before, I get JSON data, then I pass it to something like this:

    _model.addIncident = function (json) {
       var checked = json.UserTouches > 0 ? true : false;
       _model.incidents.push({
          id: ko.observable(json.IncidentIDString),
          lastTouchId: ko.observable(json.UserLastTouchIDString),
          weight: ko.observable(json.Weight),
          title: ko.observable(json.Title),
          checked: ko.observable(checked),
          createdOn: ko.observable(json.IncidentCreatedOn),
          servicename: ko.observable(json.Servicename),
          inEdit: ko.observable(false),
          incidentHistory: ko.observableArray(),
          matchScore: ko.observable()
      });
   };

for each node in the JSON array. As you can see, I’ve got some custom observables in there that get build with every passing piece of data. Maybe this is the wrong way to go, but it’s worked great up until now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:52:36+00:00Added an answer on May 31, 2026 at 4:52 pm

    An observableArray is really just a normal observable with some extra methods for array operations.

    So, if you want to set the value of an observableArray to a new array, you can just do:

    viewModel.items(myNewArray)

    The mapping plugin can help you update the existing items in an array with any updates. In this case, your UI will only be updated from any differences.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following KnockoutJS template (render with jquery.tmpl): <script id=contactsTemplate type=text/html> <li data-bind=click:
I am trying to understand if KnockoutJS will work for my application. My data
I just now start using knockoutjs. In below code am just trying to bind
In knockoutjs 1.2.1 I could do: <div data-bind=template: {name: 'Bar', foreach: persons, templateOptions:{fooMode: true}
Is there any way in Knockoutjs binding where I can specify optionsGroup ? something
Tried to fiddle with knockoutjs for the first time, but can't get any examples
How do we populate data in the knockoutjs view model on the first call
I recently started working with KnockoutJs and quickly realized using the default Json(myModelWithADate) resulted
I'm trying to use KnockoutJS to build an interactive dashboard with data bindings on
I'm creating an app using the very slick KnockoutJS library, but I've run into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.