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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:37:29+00:00 2026-06-14T23:37:29+00:00

Here is a jsFiddle demonstrating the following problem: Given a foreach binding over a

  • 0

Here is a jsFiddle demonstrating the following problem:

Given a foreach binding over a list of (observable) strings, the observables do not seem to update from changes to input tags bound inside the foreach. One would expect them to. Here’s the example from the jsFiddle:

HTML

<ul data-bind='foreach: list'>
    <li><input data-bind='value: $data'/></li>
</ul>

<ul data-bind='foreach: list'>
    <li><span data-bind='text: $data'></span></li>
</ul>

Javascript

​var vm = { list: [ko.observable('123'), ko.observable('456')] };
ko.applyBindings(vm);​

In the above example, one would expect that updating the input tags in the first list would cause the observables to update. Unfortunately they do not update as expected, as can be seen by the failure of the second list to reflect any changes to made to the first.

I verified that the list was not in fact being updated when the input elements are changed.
Interestingly, changes made to the observables are reflected in both lists (as one would expect). Namely, vm.list[1]("444") will update the second element of both lists.

My recollection is that Knockout 2.0.0 did not have this issue, though I stand to be corrected. I did not find any documentation, Google or comments in the Knockout code that yielded any indication as to why this does not work or how to achieve the outcome expected.

Why does this not work as expected, and are there any workarounds that do not require changing the data structure?

  • 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-14T23:37:31+00:00Added an answer on June 14, 2026 at 11:37 pm

    I worked around this by using value: $parent.list[$index()], as seen in this jsFiddle. The new bindings looks like this:

    <ul data-bind='foreach: list'>
        <li>
            <input data-bind='value: $parent.list[$index()]' />
        </li>
    </ul>
    

    One could perhaps improve on this with a custom binding.

    See also this related GitHub issue #708 for Knockout.js.

    Update for Knockout 3.0:

    Knockout now provides $rawData:

    <ul data-bind='foreach: list'>
        <li><input data-bind='value: $rawData'/></li>
    </ul>
    

    creates a two-way binding as expected.

    From the Binding Context documentation:

    $rawData

    This is the raw view model value in the current context. Usually this
    will be the same as $data, but if the view model provided to Knockout
    is wrapped in an observable, $data will be the unwrapped view model,
    and $rawData will be the observable itself.

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

Sidebar

Related Questions

I have here a JSfiddle demonstrating my problem. http://jsfiddle.net/J6uM5/4/ <div id=list-A style=height:50px; overflow-y:scroll; border:1px
Hovering over option in a select list (window ) in IEs does not generate
I have the code live here(JSFiddle) : Jquery does not hide the label on
here is jsfiddle - red div will have given height in px . yellow
I have a script over here: JsFiddle If you scroll down in the javascript
Here is a small demonstration of what my problem is: http://jsfiddle.net/k2Pqw/4/ After sizing the
My script is here : jsfiddle i have two attributes in my form that
What solution can I find to prevent unnecessarily clicks activate function mouseup. here jsfiddle
here is jsfiddle sample - http://jsfiddle.net/6bKHc/120/ and code - var move, inter; inter =
Here is jsfiddle ! I am trying to make user page where he can

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.