I'm using Kendo JQuery with MVVM.
I would like to automatically change the value of the a variable ("label") when another variable changes ("optionId").
This is my VieModel:
var vm = kendo.observable({
optionId: '',
label: ( this.optionId == 'Spaghetti' ? "Pasta selected" : "Animal selected" ),
setOption: function( event ) {
var value = event.currentTarget.value;
this.set("optionId", value );
//this.set("label", this.optionId == 'Spaghetti' ? "Pasta selected" : "Animal" );
}
});
If I remove the commented line, it works. But that's not what I want because I would have to add that line in every method.
I thought I could write:
label: ( this.get("optionId") == etc... )
but I can't. I believe this would work.
Here is an example on Kendo Dojo. Here:
https://dojo.telerik.com/agewIWAk
Any idea?
Many thanks.