10

I have the following problem in Knockout.JS:

Let's suppose that I have an observable array of objects, rendered with the help of a template. Each one of them has two observable properties A and B. Both of these properties take their values from dropdowns (select/options binding).

My problem is that when the selected value of A changes for one object I also want to change the available (and selected) values of B for that specific object. I can't seem to find how this is done using knockout.

I could solve the problem using Javascript or Jquery to assign handlers to the onchange event of dropdown A and change the dropdown options of B manually - however I really don't want to pollute my design with that :(

So please answer me using only knockout's tools...

Thanks !

1 Answer 1

16

Take a look at the "Cart editor example" over at the Knockoutjs website. It includes an example of populating one combo box based on a parent combo box.

http://knockoutjs.com/examples/cartEditor.html

Maybe this helps?

Sign up to request clarification or add additional context in comments.

1 Comment

Great demo, explains everything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.