Hi i am trying to do a double data-bind on a option text. Now i want to include 2 things within the select drop-down.
I have tried this and it only brings back the last data-bind of the description. is there a way to do 1 data-bind and include both values using knockout?
<option value="" data-bind="text: Name, text: Description"></option>
You can do:
<option value="" data-bind="text: Name() + ' ' + Description()"></option>
Or better create a computed observable:
this.ComputedName = ko.computed(function (){
return this.Name() + ' ' + this.Description();
});
and use it like this:
<option value="" data-bind="text: ComputedName"></option>
You might also consider options binding instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.