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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:08:31+00:00 2026-06-09T12:08:31+00:00

I have a Knockout.JS observable array that is the basis for a list: self.list_elements

  • 0

I have a Knockout.JS observable array that is the basis for a list:

  self.list_elements = ko.observableArray([
     new list_element("0001", "product 1", "3.99")
  ]);

Variables in this array are observables:

function list_element ( id, name, price ) {
   this.item_id = ko.observable(id);
   this.item_name = ko.observable(name);
   this.item_price = ko.observable(price);
}

There is also a details view, which I want to fill with the data of a list element that is clicked, e.g:

<span data-bind="text: an_item_id"></span>

The function to fill this gets the respective array item from the click handler.

self.fill_form = function ( array_item ) {
    // array_item is the array element corresponding to the selected list element
}

How can I connect the details view with the values in the array so that changing the value in the array shows up in the details view?

  • 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-09T12:08:33+00:00Added an answer on June 9, 2026 at 12:08 pm

    Normally, you would create a selected observable and populate it with the currently selected item. Then, you would use the with to render a section with a context specific to the selected item.

    Something like:

    var ViewModel = function() {
        var self = this;
        this.list_elements = ko.observableArray([...]);
    
        this.selected = ko.observable();
    
        this.fill_form = function(item) {
            self.selected(item);
        };
    };
    

    Then, you would bind a section like:

    <div data-bind="with: selected">
       ...
    </div>
    

    If you don’t need to perform any logic in your fill_form function, then you can even just bind a click directly against your selected observable, as the item will get passed as the first argument to the observable (which is a function) and to set its value.

    Here is a sample example: http://jsfiddle.net/rniemeyer/YPKk2/

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

Sidebar

Related Questions

I have a Knockout observable array that I wish to edit from within Javascript
I am new to Knockout.js, I have created an observable array and initialized with
Hi (another Knockout question :-( , sorry) I have an observable array with five
I have Knockout.js view model that has nested observable arrays. function ParentVM(data) { var
I have a an address array that is mapped using knockout mapping. Is there
i have a an observable array in my model that is bind to just
i work with knockout, i have an observablearray (mappedCompaignByInterest) in my viewmodel that contains
I have a knockout model that is feeding my page and on a save
I am using knockout and have an array Properties and each Property can have
I have created a form with knockout that will allow the ability to give

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.