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 7814917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:21:20+00:00 2026-06-02T05:21:20+00:00

I am very very new to knockoutjs – having worked through the tutorials and

  • 0

I am very very new to knockoutjs – having worked through the tutorials
and I have made a nice start. I have application which seems well suited
to KO. In that I need to populate a table with data from JSON. This
data is nested, and can be nested at any depth, but my API will only
ever return data two levels deep.

E.g.

  • Node 1
    • Node A
    • Node B

I’ve managed to get the data to load into my table, lovely. I’ve taken
this a step further and have supported nesting. I have a requirement so that if a Node has children, it can be injected beneath the Node into the table.

An example of this would be…

  • Node 1 (HasChildren)
    • Node A
    • Node B (HasChildren)

As Node B ‘HasChildren’, I would like to allow the loading of it’s children into the table, beneath Node B. In this event, I would be able to query my API, and it would return the children for Node B

  • Node 1
    • Node A
    • Node B
      • Node B1
      • Node B2

I’ve got something roughly working, but it only works on a level 1
node. Once it get’s to level2, can’t seem to find my method
(addChild). I can’t work out why it cannot find the method, as it is
in my ViewModel.

The post below, goes a long way to fixing this part of the problem.

Help!

I’ve pasted the code here… (if you scroll to the right on the table,
you can click open, to see, what’s happening!)

http://jsfiddle.net/8k6pj/1/ – Original Version (18th April 2012)

http://jsfiddle.net/8k6pj/6/ – Latest Version

Many thanks in advance!

Laurence

p.s Have further updated my code, so although I’m a bit stuck on the above, have started looking into implementing how the code will postback so we can save.

It looks like the postback is working, however it does not post back the changed values, the original values are posted back. Think this is because I need to use an ObservableArray, exploring that 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-06-02T05:21:24+00:00Added an answer on June 2, 2026 at 5:21 am

    I’ve had a go at understanding what you would like to happen, I’m still a bit unclear but thought I’d submit what I did in order to provoke more info if needed.

    Your question title mentions nesting but from your code it appears you aren’t nesting anything, instead you are flattening your nested parent child objects.

    Instead of using jquery delegates which I would not recommend since it breaks encapsulation of your models, I changed your template to use click bindings and placed an open function on the Crew/Component objects.

    <td rowspan="3">
        <a data-bind="click: open">Open</a>
        <a>Save</a>
    </td>
    

    I also noticed that your addChild method requires you to pass an array to it. Your original code would not have worked as the Crew objects don’t themselves have a Crews collection so i took a guess an used the Crews collection on their parent Component.

    All these alterations meant I had to pass through the root viewModels and the parent components on the constructors.

    http://jsfiddle.net/madcapnmckay/fdb5r/2/

    FYI – This fiddle still throws errors when clicking Open as the Allocated objects don’t get initialized correctly. I’ve left this upto you to fix since I don’t understand the domain enough to fix it myself. The adding behavior works correctly though.

    EDIT after updated question

    Here’s a re factored and simplified example that should get you started. I removed a lot of the non-essential stuff to make it clearer how it works.

    http://jsfiddle.net/madcapnmckay/xxGam/

    Hope this helps.

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

Sidebar

Related Questions

Very new to this, and I have no idea where to start. I want
Very new to Iphone development here, I have a project which is successfully building
very new to EC2 and looking to start playing with it through the AWS
Very new to AJAX, but have learned a bit from online tutorials. If I
Very new to using Raphael.js I'm looking at the tutorials and I am able
I very new to Python, and fairly new to regex. (I have no Perl
Im very new to all coding including jquery. I though this would have been
I am very new to jQuery and javascript. I have an autocomplete box setup
Very new to Objective-C and Xcode and working my way through modifying the DrillDownApp
Very new to Business Objects, but I have a .NET background and PL/SQL background.

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.