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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:32:08+00:00 2026-06-16T00:32:08+00:00

Consider the following HTML: <select data-bind=options: assemblies, optionsText: ‘Name’, value: selectedAssembly> </select> Name <input

  • 0

Consider the following HTML:

<select data-bind="options: assemblies, optionsText: 'Name', value: selectedAssembly">
</select>

Name <input type="text" data-bind="value: selectedAssembly().Name" />

I’m retrieving assemblies array via jQuery AJAX:

[{"Id":1,"Name":"Foo"},
{"Id":2,"Name":"Bar"}]

selectedAssembly is an observable and ().Name throws an exception.
I need to change Name property reflecting changes at runtime in the select options.
I’ve tried:

<p data-bind="with: selectedAssembly">
    Name <input type="text" data-bind="value: $data.Name" />
 </p>

This way i succeed in retrieving Name property, but its value changes are updated only when user select another option from the box and not in real time.

  • 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-16T00:32:09+00:00Added an answer on June 16, 2026 at 12:32 am

    You need to make the Name property observable on the items inside in the assemblies array to able to edit the items in the select.

    You can do the JSON to object with observable properties conversion by hand or you can use the Knockout Mapping plugin which is written to solve this exact problem:

    The usage is very simple:

    function viewModel() {
        var self = this;    
        self.selectedAssembly = ko.observable();
    
        // you need to have a default item in assemblies
        // otherwise ko will set undefinied to selectedAssembly because it the 
        // assemblies collection is empty at the begining
        // which brakes the selectedAssembly().Name binding
        self.assemblies = ko.observableArray([{Name: ""}]);    
    
        $.getJSON('http://localhost:9000/api/assemblies', function(data){
            ko.mapping.fromJSON(data, {}, self.assemblies)
        });
    }
    

    A simplified JSFiddle with hardcoded data.

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

Sidebar

Related Questions

Please consider the following HTML: <input type='text' id='name'/> <option id='option'> <select value='1'>hi</select> <select value='2'>bye</select>
Consider the following HTML snipped: <input type=submit value=Delete selected><input type=submit value=Print selected> <div class=table>
Consider an HTML form built in the following way: <select name=schoolType> @foreach (SchoolType schoolType
Consider the following code : HTML: <div> <label for='name'>Name:</label> <input type='text' id='name' /> </div>
Consider the following HTML: <select> <option value=hasAttr>Has a value attr</option> <option>Does not have a
I have the following HTML <form id=create_form name=create_form action= method=post> <input name=type id=type value=individuel
Consider the following HTML table: <table id=myTable1> <tr id=TR1> <td><input type=text id=quantity1 name=quantity1 /></td>
Consider the following HTML : <div class=list> <select> <option value=one>1</option> <option value=two>2</option> </select> And
Consider the following HTML tables: <table id=myTable1> <tr><td><input type=text id=quantity1 name=quantity1 /></td></tr> <tr><td><input type=text
Consider the following piece of code : <select> <option value=0>foo</option> <option value=1 selected=selected>bar</option> </select>

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.