What's the correct way to save a model that was loaded via the ViewModel links feature? Here's my ViewModel:
This successfully loads the client with ID of 1 from the server, so after changing values, how do I get a reference to this model so that I can then save it? In my ViewController, I have this (so far, so that I can figure out the best way to go):
I can see in FireBug that there are these possibilities:
Correct way to save model loaded via the ViewModel links
Code:
Ext.define('App.view.ClientFormViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.clientform',
links: {
theClient: {
type: 'App.model.ClientInfo',
id: 1
}
}
});
This successfully loads the client with ID of 1 from the server, so after changing values, how do I get a reference to this model so that I can then save it? In my ViewController, I have this (so far, so that I can figure out the best way to go):
Code:
Ext.define('App.view.ClientFormViewController', {
extend: 'Ext.app.ViewController',
alias: 'controller.clientform',
onSaveClick: function(button, e, eOpts) {
console.log(this.getViewModel());
}
});
I can see in FireBug that there are these possibilities:
The .data object which has a "theClient" property (i.e., this.getViewModel().data.theClient), but there is also a .linkData property which has "theClient" also.
The docs for .data say this:
This object holds the arbitrary data that populates the ViewModel and is then available for binding.
Which has me wondering if I should be referring to this.getViewModel().data.theClient object (the "arbitrary" is sewing seeds of doubt). Strangely enough, this.getViewModel().getLinks() is null.
Correct way to save model loaded via the ViewModel links
Aucun commentaire:
Enregistrer un commentaire