Bind: having data before change

1 Answer 23 Views
MVVM
Marco
Top achievements
Rank 2
Iron
Iron
Marco asked on 07 Mar 2024, 10:32 PM

You use it to bind to a viewModel:

viewModel.bind("change", function( event ){
    console.log("BIND:", event.field, "=", this.get(event.field));
});

this.get(event.field)
has the data just modified.

Is there a way to get the old data, before change?

Many thanks

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 12 Mar 2024, 09:43 AM

Hi Marco,

The change event is fired after blurring the element whose value has changed. Thus, when the event is fired the old value is not available. In the event handler, you can not get the previous value of the element, but only the new one. What you could try is to add an additional field and save the initial value there. Then if needed you can update the value once a change is performed. 

Let me know in case you have additional questions on the matter.

Regards,
Neli
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
MVVM
Asked by
Marco
Top achievements
Rank 2
Iron
Iron
Answers by
Neli
Telerik team
Share this question
or