Bombo
unread,Apr 20, 2011, 10:57:39 AM4/20/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to KnockoutJS, bros...@sitrion.com
Hello everybody,
is there any way to use javascript pseudo-associative array
functionality with observable arrays?
I would like to change the selected value of one dropdown list in
dependence of the selection of another one. Both dropdowns are filled
with KOs options binding. I would like to avoid using the optionsValue
binding, so I have access to the actual selected object in both cases.
The view model elements associated with the specific dropdowns are:
var value1 = function(key, text, value2) {
this.key = key;
this.text = text;
this.value2 = val2;
};
var value2 = function(key, text) {
this.key = key;
this.text = text;
};
The val2 property of each value1 should correspond to the key property
of some value2 object. The second dropdown's selected value is binded
to viewModel.selectedValue2, which should be changed by manual
subscription:
viewModel.selectedValue1.subscribe(function(newValue) {
this.selectedValue2(this.values2()[newValue.val2]);
}, viewModel);
The values2 array would be of form:
{
"key1" : { "key" : "key1", "text" : "text1" },
"key2" : { "key" : "key2", "text" : "text2" },
"key3" : { "key" : "key3", "text" : "text3" },
...
}
I hope, you get, what I mean.
Thanks in advance!
Boris