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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:00:55+00:00 2026-06-06T08:00:55+00:00

I have a form that generates an array of attribute objects. The attribute objects

  • 0

I have a form that generates an array of attribute objects. The attribute objects have an array property that is an array of attribute values. The form allows you to add an attribute name and an array of attribute values and maps to an attribute object:

function Attribute(data) {
      var self = this;
      self.Name = ko.observable([data.attributeName]);
      self.Values = ko.observable([data.attributeValues]);
  }

And the Values array is an attribute of AttributeValues:

  function AttributeValue(data) {
      this.Value = data.value;
  };

With the ViewModel having an array of AttributeValues as you create them, and will pass it with the name of the Attribute to its local array of Attributes

   function newProductViewModel() {
      var self = this;
      self.attributeName = ko.observable();
      self.attributes = ko.observableArray([]);
      self.attributeValues = ko.observableArray([]);

When you are creating an attribute in the form, knockout has no problem listing the attribute values you have added to the array of AttributeValues:

   <select multiple="multiple" height="5" data-bind="options: attributeValues, optionsText: 'Value', selectedOptions: selectedItems, optionsCaption: 'Added Values...'">

where attributeValues is the ViewModel’s array of attributeValues.

Once an attribute name and a list of attribute values has been added, and you add the Attribute, I foreach over the observableArray attributes property on the ViewModel to show a list of the added Attributes as you create them.

The Problem

The problem is I am showing a drop down (select) for each attribute’s array of attribute Values Values:

<ul data-bind="foreach: attributes">
   <li>
    <div>
       <span data-bind="text: Name"></span>
       <select multiple="multiple" height="5" data-bind="options: Values, optionsText: 'Value', selectedOptions: selectedItems, optionsCaption: 'Added Values...'">

     .....remove for sake of brevity

But it won’t list the Value for each AttributeValue in the Values array for each Attribute

I have stepped through and can see that the Values property does get set with the proper values.

What am I doing wrong?

  • 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-06T08:00:56+00:00Added an answer on June 6, 2026 at 8:00 am

    I figured out the problem. I was passing in an array “attributeValues” to the Attribute object and putting it in array

    self.Values = ko.observable([data.attributeValues]);
    

    So I assume it would be an array of one element with the array of attributeValues in that index. When stepping through and I seen the correct number of elements because I was only adding one value, but actually looking at the array within the first index.

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

Sidebar

Related Questions

currently i have a form, that generates a Drop-Down-Select from my category-entity: $builder ->add('category',
I have a form that when submitted successfully generates new elements on the page
I have a create action for a form that potentially generates errors (i.e. first
I have a factory method that generates django form classes like so: def get_indicator_form(indicator,
I have an app that generates invoices in the form of PDF files stored
I have a form that sends money value e.g <input type=text name=amount value=N50,000.00 NGN
I have a form that includes the first name and last name of a
I have a script that generates some numbers (specifically times in epoch form). Everytime
I have a class that generates some html (form elements and table elements), but
I have a CMS with a form-module, which generates an awful markup, that makes

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.