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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:24:17+00:00 2026-05-27T23:24:17+00:00

I want to convert a solution of <select /> box chaining I’ve already built

  • 0

I want to convert a solution of <select /> box chaining I’ve already built to use KnockoutJS. Here’s how it works now:

I have a database that is full of products that have attributes and those have values which in turn have a dependency on another selected value.

product > attributes > values > dependency

bench > length > 42" > (height == 16")

In my database we also store what values are dependent on other values. e.g. length can only be 42" if the height is 16" or something like that.

This comes from the server to a JSON object on the client that contains all of the attributes, values and dependencies for the product in a tree like form.

var product = 
{
    attributes: 
    [
        values: 
        [
            value:
            {
                dependencies: [{dependencyOp}]
            }
        ]

    ]
};

I’ll loop through each value and its dependency for the entire object and build an expression like "16 == 14 && 4 == 4" which would evaluate to false of course (14 being the selected value from another attribute). in that expression the && would be the dependencyOp in the dependencies array.

Now in my attempt I used KnockoutJS mapping plugin to get the object to be my view model but my problem is when I make a dependentObservable that needs to know what its dependant on. So now I would have to loop through every single array/object in my product variable?

  • 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-05-27T23:24:18+00:00Added an answer on May 27, 2026 at 11:24 pm

    If I understood your question, you’re trying to get data from your server, and use it determine if the user’s input is valid. If that’s the case, put your data structure into a field in your viewModel, and make your dependentObservable dependent on that field.

    function ViewModel() {
        this.data = ko.observable();
        this.input = ko.observable();
        this.isValid = ko.dependentObservable(function() {
            // evaluate input() against data() to determine it is valid; return a boolean
            return ...;
        }, this);
    
        this.loadData = function() {
            $.ajax('/data/get', {
                 success: function(dataFromServer) {
                     this.data(dataFromServer);
                 });
        }
    }
    
    var vm = new ViewModel();
    ko.applyBindings(vm);
    vm.loadData();
    

    now you can refer to this dependentObservable in a data-bind attribute like this

      <input type="text" data-bind="value: input, valueupdate='afterkeydown'" />
      <div data-bind="visible: isValid">shown only when data is valid...</div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a VS2005 solution and I want to convert it to VS2010. I
I want to convert a C-style string into a byte-vector. A working solution would
I want solution to this problem,In Asp.Net convert enterkey to tabkey for all browsers(IE,Firefox,Opera,Google
I want to convert date of birth from a text file.Let's say, I have
UPDATE I tried Crazy's solution but now I have problem showing data in a
for example, i want to convert this; $this->db->get('table'); to this; 'SELECT * FROM table'
I want to convert a primitive to a string, and I tried: myInt.toString(); This
I want to convert an instance of generic IDictionary<,> to non generic IDictionary .
I want to convert a string into a double and after doing some math
I want to convert a number that is in PRTime format (a 64-bit integer

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.