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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:46:03+00:00 2026-06-15T21:46:03+00:00

here`see my fiddle http://jsfiddle.net/kirannandedkar/JUChh/2/ When i click on name it doesnt load up select

  • 0
here`see my fiddle

http://jsfiddle.net/kirannandedkar/JUChh/2/

When i click on name it doesnt load up select list and gives errror that function is expected.
Actually i want to load select and value should be selected . When i change something in select it should get reflected in the list. Currently ModuleId is not getting populated in list and when i click on list its not populating the select list.

ViewModel:

var Person = function(id, name, country,ModuleId) {
    var self = this;
    self.id = ko.observable(id);
    self.name = ko.observable(name);
    self.country = ko.observable(country); 
    self.ModuleId= ko.observable(ModuleId);
    return self;
};

var vm = (function() {
    var people = ko.observableArray(),
        selectedPerson = ko.observable();
        self.editModuleId = ko.observable();
        self.modules = ko.observableArray([{"Id": 1,"ModuleName": "M1"},{"Id":2,"ModuleName":"M2"}]);

        getPeople = function() {
            people.push(new Person(1, 'John', 'USA',1));
            people.push(new Person(2, 'Mike', 'UK',1));
            people.push(new Person(3, 'Dan', 'AUS',2));
        },
        selectPerson = function(p){
            selectedPerson(p);
             self.editModuleId(ko.utils.arrayFirst(self.modules(), function (data) {
                    console.log("item module id " + p.ModuleId());
                    return data.Id() === p.ModuleId();
                }));
        };



    getPeople();

    return {
        people: people,
        selectedPerson: selectedPerson,
        selectPerson : selectPerson 
    };
})();


ko.applyBindings(vm);

View:

<ul data-bind="foreach: people">
 <li data-bind="text:name, click:$parent.selectPerson"></li>
<li data-bind="text:$root.editModuleId,click:$parent.selectPerson"></li>

</ul>

<div data-bind="with:selectedPerson">
<span data-bind="text:id"></span>
<input data-bind="value:name"/>
    <input data-bind="value:country"/>
    <select data-bind = "options:$root.modules,value:$root.editModuleId,optionsText:'ModuleName'"/>
</div>
  • 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-15T21:46:05+00:00Added an answer on June 15, 2026 at 9:46 pm

    Modules observable array contains simple js objects without observables so when accessing its properties you don’t need to put (). Remove it from data.Id in selectPerson function:

    selectPerson = function(p){
        selectedPerson(p);
         editModuleId(ko.utils.arrayFirst(modules(), function (data) {
                console.log("item module id " + p.ModuleId());
                return data.Id === p.ModuleId();
            }));
    };
    

    Here is working fiddle: http://jsfiddle.net/JUChh/3/

    I look at your code closer and found that editModuleId is redundant. You have needed property inside selectedPerson object – ModuleId and should bind value of dropdown to it.

    Here is refactored fiddle: http://jsfiddle.net/JUChh/18/

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

Sidebar

Related Questions

See my fiddle here http://jsfiddle.net/WEZVX/2/ Notice when you mouse over the marker, you see
Here's a very simple fiddle: http://jsfiddle.net/mmSKj/ If you click the presets button in the
You can see the fiddle here: http://jsfiddle.net/easeS/4/ Here is the html/css I have: #main
Here's my fiddle : http://jsfiddle.net/34TM4/1/ As you can see, the red div has a
Here's my fiddle: http://jsfiddle.net/MtgbM/ Here's the rules: List-A is my list of items. I
My fiddle: http://jsfiddle.net/Yc9WY/42/ What you'll see here are two groups, each with 3 droppable
For code, please see my fiddle here: http://jsfiddle.net/6fwbS/5/ I can not get the global
See here: http://jsfiddle.net/zYcJm/ The jQuery should be validating each field to check if they
See here for my issue: http://jsfiddle.net/FvBqA/126/ My issue is that I want to be
See here for code: http://jsfiddle.net/ecFBK/10/ I'm having a hard time getting this to work

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.