knockout.js - Knockout JS : Setting value to Dropdown? -
I have integrated knockout JS in your project and now I'm experiencing some problems in setting the user selected values from the dropdown am,
JS file:
RDOBY: Ko Ossebel Array ([{Name: "1986"}, {Name: "1992"}, {name: "name": "1 99 1", {name: "1 99}", {name: "1991"}, {name: "1992"}, {name: "1993"}, {name: "1994", {Name: "1995"}, {name: "{Name:" 1997 "}, {name:" 1998 "}, {name:" 1999 "}, {name:" 2000 "}, {name:" 2001 "}]); I am able to be able to drop these figures down and selected values,
selRDOBY (). name But my problem is that I want to set this value to drop down.
Example: With the backend system I'm receiving 2010 as the selected year, Must be set to this dropdown. / P>
How to do this. Any help is appreciated. The problem here is that selRDOBY is a regular array or
viewable instead of the code> observant ARRA (Which you are using to set the selected value), the document of knockoutJesets shows: This should be an array (or an observable array). KO sets the selected options of elements to match the contents of the array.
If your parameter is an observational array, the binding element will update whenever the array changes. (e.g., push, pop or other observation method methods) . If the parameter does not look, it will only set the selection of the element once and not update it later.
Whether the parameter is an observable array or not, KO will find out that when the user chooses or unselects an item in the multi-select list, and updates the array to match. In this way you can read which option is selected.
For this reason, you should assign your selRDOBY to a aspectableArray . selRDOBY: Co. Osborne ([]);
You will need to modify your existing code to ensure that this change is pending. Therefore, any example of selRDOBY (value) may have to be changed to selRDOBY ([value]) or selRDOBY.push (value) .
Comments
Post a Comment