This is a migrated thread and some comments may be shown as answers.

Changing kendo.data.Model After It's been Defined

1 Answer 71 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Long
Top achievements
Rank 1
Long asked on 23 Oct 2013, 06:58 PM
Is there a way to add methods to a Model's definition after it's already been defined?

I have a Product Model that is reused throughout my application. There a form when which I bind to this Product model in my app that needs a few extra methods on it so for the "Save" button using MVVM. However I don't want to add this to the Product Model definition because this particular form is the only one that needs the "Save" method.

Here is the jsfiddle working, without adding the Save function to the Model
http://jsfiddle.net/lelong37/RvsCg/1/

Here is the jsfiddle not working when I try to add the Save method to the Model
http://jsfiddle.net/lelong37/t8Bq2/3/

Your help is greatly appreciated.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Oct 2013, 06:36 PM
Hello,

You should pass a plain object to the extend method and use the extended model to initialize the instance. Check this updated jsFiddle.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MVVM
Asked by
Long
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or