Knockout Computed with Parameter not updated

Paul

In a MVC application im generating multiple dropdowns from the database:

<select data-bind="options: findGroup(1).items(),
                        optionsText: 'country',
                        optionsValue: 'id',
                        value: selectedItem(1),
                        event: { change: selectionChange }"></select>

I need the current selected in my code, but for Debugging puroses im using a span:

<span data-bind="text: 'Computed Selected Country: ' + selectedItem(1).country"></span><br />

the findgroup(x) and the selectedItem(x) are global functions in my ViewModel while those are for all the dropdowns the same.

the selectedItem(x) should return the currently selected Option of the dropdown. selectedItem(x) is a function to return a computed knockout observable. the selectedItem(x) always Returns "undefined", cant figure out why...

full example: http://jsfiddle.net/LGveR/17/

TIA, Paul

Anders

Your function returns a computed so it needs to be executed like,

http://jsfiddle.net/LGveR/18/

this.selectedItem(1)().country

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Knockout writable computed observables

From Dev

Knockout Computed Observable with parameters

From Dev

Knockout computed property not binding

From Dev

knockout foreach computed value

From Dev

knockout observable array computed

From Dev

knockout foreach computed value

From Dev

Knockout writable computed observables

From Dev

Knockout computed property not binding

From Dev

observable and computed are not working properly Knockout

From Dev

Knockout custom binding to a computed column

From Dev

Knockout Js computed not working in a model

From Dev

Knockout js Computed not being fired

From Dev

Knockout computed observable with access to observableArray

From Dev

Knockout Modifying ObservableArray inside Computed

From Dev

Inheritance and overriding Knockout computed observable

From Dev

Knockout ViewModel computed garbage collection

From Dev

Subscribe arrayChange on knockout computed accessor

From Dev

Knockout ViewModel computed garbage collection

From Dev

Knockout js Computed not being fired

From Dev

Knockout Modifying ObservableArray inside Computed

From Dev

Knockout Computed - write a new value

From Dev

Inheritance and overriding Knockout computed observable

From Dev

Knockout not sending updated value

From Dev

Ember computed property not being updated

From Dev

Ember computed properties not getting updated

From Dev

Ember computed properties not getting updated

From Dev

Knockout: edited input fields are not updated

From Dev

Knockout: model not updated in internet explorer

From Dev

Knockout js observableArray is not getting updated