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

  • Home
  • SEARCH
  • 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 9173713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:37:51+00:00 2026-06-17T16:37:51+00:00

So, in my first week using knockout, I think I have gotten a good

  • 0

So, in my first week using knockout, I think I have gotten a good prototype:
(Trimmed down and removing the ajaxy calls)

http://jsfiddle.net/NelsonLamprecht/39dfx/

"use strict";

var steeringTeamSheetViewModel = function (serviceUrl) {
var self = this;
self.viewModel = ko.mapping.fromJS([]);

self.InitializeAjax = function () {
    //abbreviated  
};

self.GetData = function () {
    //abbreviated
    var data = {
        "Sections": [{
            "ProjectType": "BUSINESS EXPANSION",
                "Projects": [{
                "ID": "767a46a2-ddba-435c-a9f9-fdb9f0175337",
                    "ItemOrder": 0,
                    "ProjectName": "project abc"
            }, {
                "ID": "0e36d7da-92e6-4f1b-939d-936d6e759115",
                    "ItemOrder": 0,
                    "ProjectName": "project abc"
            }, {
                "ID": "f6e447d4-955d-48e0-bcdf-6db9044b7a89",
                    "ItemOrder": 0,
                    "ProjectName": "project a"
            }]
        }, {
            "ProjectType": "OPER & MAINT - EFFICIENCY",
                "Projects": [{
                "ID": "9883a3c8-d01e-4fc9-8f66-9b46d720afde",
                    "ItemOrder": 0,
                    "ProjectName": "project q"
            }]
        }, {
            "ProjectType": "OTHER",
                "Projects": [{
                "ID": "f1ccfa79-c5b1-4880-b5a1-1c2350e709e1",
                    "ItemOrder": 0,
                    "ProjectName": "project 1"
            }]
        }]
    };
    self.ProcessRetrievedData(data);
};

self.ProcessRetrievedData = function (retrievedData) {
    self.viewModel(retrievedData);
};   

self.GetData();
};
var steeringTeamSheetService = 'someurl';
var sts = new steeringTeamSheetViewModel(steeringTeamSheetService);
ko.applyBindings(sts);

What I am now trying to do is to change the ko.oberservableArray into another binding, like
the .indexed() one that is floating around out there.

http://jsfiddle.net/NelsonLamprecht/39dfx/19/

"use strict";

var steeringTeamSheetViewModel = function (serviceUrl) {
var self = this;
var mapping = {
'sections': {
    create: function(options) {
        alert(options);
    }
}
}
self.viewModel = ko.mapping.fromJS([],mapping);

self.InitializeAjax = function () {
    //abbreviated  
};

self.GetData = function () {
    //abbreviated
    var data = {
        "Sections": [{
            "ProjectType": "BUSINESS EXPANSION",
                "Projects": [{
                "ID": "767a46a2-ddba-435c-a9f9-fdb9f0175337",
                    "ItemOrder": 0,
                    "ProjectName": "project abc"
            }, {
                "ID": "0e36d7da-92e6-4f1b-939d-936d6e759115",
                    "ItemOrder": 0,
                    "ProjectName": "project abc"
            }, {
                "ID": "f6e447d4-955d-48e0-bcdf-6db9044b7a89",
                    "ItemOrder": 0,
                    "ProjectName": "project a"
            }]
        }, {
            "ProjectType": "OPER & MAINT - EFFICIENCY",
                "Projects": [{
                "ID": "9883a3c8-d01e-4fc9-8f66-9b46d720afde",
                    "ItemOrder": 0,
                    "ProjectName": "project q"
            }]
        }, {
            "ProjectType": "OTHER",
                "Projects": [{
                "ID": "f1ccfa79-c5b1-4880-b5a1-1c2350e709e1",
                    "ItemOrder": 0,
                    "ProjectName": "project 1"
            }]
        }]
    };
    self.ProcessRetrievedData(data);
};

self.ProcessRetrievedData = function (retrievedData) {
    self.viewModel(retrievedData);
    //I think I should be using something like
    //self.viewModel = ko.mapping.fromJSON(retrievedData,mapping,{});
};   

self.GetData();
};
var steeringTeamSheetService = 'someurl';
var sts = new steeringTeamSheetViewModel(steeringTeamSheetService);
ko.applyBindings(sts);

However, without all that, I don’t think I am following the right pattern in setting up a model and getting the data from a web service (c#).

Can someone validate I am doing this right as well as help with the create pattern?

  • 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-06-17T16:37:51+00:00Added an answer on June 17, 2026 at 4:37 pm

    As I understand your problem, you try to download data via ajax and store it in the property ‘viewModel’ of your steeringTeamSheetViewModel. Your way looks ok to me.

    You should not overwrite self.viewModel. Because if ko.applyBindings had run to that point you would break the binding.

    self.ProcessRetrievedData = function (retrievedData) {
        // map the data from the viewModel and update self.viewModel
        self.viewModel(ko.mapping.fromJSON(retrievedData,mapping,{}));
    };   
    

    Keep in mind that ko.mapping will become very slow if you have large view models.

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

Sidebar

Related Questions

I'm using Socket.IO on Node.js. The Example here: http://socket.io/#how-to-use First Example. I have tested
Suppose I have 2011-01-03 and I want to get the first of the week,
I have the following expression within a report: = Switch( Fields!RATE_CODE.Value = First, £/Week,
I have been using ojective c for almost a week, and I am mainly
Is it possible to get the first / last date of a week using
Platform: C# 2.0 Using: Castle.DynamicProxy2 I have been struggling for about a week now
I have googled this problem one week and no thing useful I think am
This is the first week I've been playing with jQuery so I have a
This is my first attempt at using JSCookMenu and its homepage ( http://jscook.yuanheng.org/JSCookMenu/ )
I am on my first week of a summer programming internship and have been

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.