Hi all;
I'm working on a project that has a model with dependent fields. As an example, consider a model with fields for both metric and imperial length (for my purpose, they both need to be writable fields). So when one value changes, I need to change the other as well -- I'm using MVVM to bind both of these to a Kendo view. My first attempt was to bind a function to the set event of each in the Kendo observable object, but I have a hunch that's going to lead to an infinite loop (changing metric, leading to changing imperial, leading to changing metric, etc.) Am I going about this the wrong way?
Thanks,
Jason
var oc = kendo.observable({
MetricLength: 1,
ImpLength: 3.28
});
oc.bind("set", function(e) {
if (e.field == "MetricLength") {
oc.set("ImpLength",e.value * 3.28);
}
if (e.field == "ImpLength") {
oc.set("MetricLength",e.value*3.28);
}
})
I'm working on a project that has a model with dependent fields. As an example, consider a model with fields for both metric and imperial length (for my purpose, they both need to be writable fields). So when one value changes, I need to change the other as well -- I'm using MVVM to bind both of these to a Kendo view. My first attempt was to bind a function to the set event of each in the Kendo observable object, but I have a hunch that's going to lead to an infinite loop (changing metric, leading to changing imperial, leading to changing metric, etc.) Am I going about this the wrong way?
Thanks,
Jason
var oc = kendo.observable({
MetricLength: 1,
ImpLength: 3.28
});
oc.bind("set", function(e) {
if (e.field == "MetricLength") {
oc.set("ImpLength",e.value * 3.28);
}
if (e.field == "ImpLength") {
oc.set("MetricLength",e.value*3.28);
}
})