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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:59:16+00:00 2026-05-25T10:59:16+00:00

I have the following code: function Session(name, index) { this.Messages = []; this.Name =

  • 0

I have the following code:

function Session(name, index) {
    this.Messages = [];
    this.Name = name;
    this.Index = index;
}

var vm = {};
vm.Sessions = ko.observableArray([new Session("Foo", 0), new Session("Bar", 1)]);

ko.applyBindings();

vm.Sessions()[0].Messages.push("Hello foo");

Along this view:

<div data-bind="template: {name: 'TopTemplate', foreach: Sessions}">
</div>
<script type="text/html" id="TopTemplate">
    <p>
        ${$data.Name}
    <ul data-bind="template: {name: 'NestedTemplate', foreach: Sessions[${$data.Index}]}"></ul>
    </p>
</script>
<script type="text/html" id="NestedTemplate">
    <li>
    ${$data}
    </li>
</script>

As you can see there is an object with the containing array. So I make the observable array of sessions and it becomes observable including the internal properties. What I want here is to display nested ‘repeaters’.

Yesterday I somehow suceeded to execute this script. And what is interesting without showing property name, i.e. Sessions[${$data.Index}].Messages. Unfortunately, I deleted that test script.

Now I’ve tried to recreate and it doesn’t work.

PS. The thing is I don’t want to make it work witout showing the relevant property. I just want to make work the nested template.

  • 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-25T10:59:17+00:00Added an answer on May 25, 2026 at 10:59 am

    This seems closer to what you want to accomplish:

    <ul data-bind="template: {name: 'TopTemplate' , foreach: Sessions}"></ul> 
    <script type="text/html" id="TopTemplate">
        <li >    
            <p>${name}</p>
            <ul data-bind=" template: {name:  'NestedTemplate' , foreach: $data} " style="list-style-type:circle;margin-left:15px">
            </ul>
        </li> 
    
    </script>
    <script type="text/html" id="NestedTemplate">         
    {{each(prop, val) $data}}
        {{if $.isArray( val ) }}
            <li>
                <b>${prop}</b>
                <ul  style="list-style-type:square;margin-left:15px" >  
            {{each(index, arrayVal) val}}
                {{each(i, mVal) arrayVal }}
                    <li> 
                        <b>${i}</b>  ${mVal}
                    </li>
                {{/each}}
            {{/each}}
        {{else}}
        <li><b>${prop}</b> : ${val}</li>
        {{/if}}
    {{/each}}     
    </script>
    

    And code:

    var viewModel = {
        Sessions : ko.observableArray([
            {name:"foo",index: 0, messages:[{body:"Hello foo 1"},{body:"Hello foo 2"}]},
            {name:"bar",index: 1, messages:[{body:"Hello foo 3"},{body:"Hello foo 4"}]}
        ])
    };
    
    // ko magic...
    ko.applyBindings(viewModel);
    

    See also this fiddle

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

Sidebar

Related Questions

I have the following code: function convert($contents, $name){ echo($link); //prints nothing $pdf=new HTML2FPDF(); $pdf->AddPage();
I have following code in the form_Load function System.Windows.Forms.Timer newtimer = new Timer(); newtimer.Tick
I have the following code in my head jQuery(document).ready(function() { var pic = 0;
Say I have the following code: function One() {} One.prototype.x = undefined; function Two()
I have the following code making a GET request on a URL: $('#searchButton').click(function() {
Suppose I have the following code: class siteMS { ... function __CONSTRUCT() { require
I have the following code: <script type=text/javascript> function SubmitForm() { form1.submit(); } function ShowResponse()
I have the following code: <script type=text/javascript> $(document).ready(function() { $(#Save).click(function() { $.post(url, { data:
I have the following JavaScript code: Link In which the function makewindows does not
I have using the following code for developing tabs. $(document).ready(function() { $('#container-1').tabs(); } ....

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.