This seems like it would happen automatically but I'm not seeing it.
I send a viewmodel with my attributes to my controller. It makes the necessary update and returns a value or the model.
If I send back the model, will the datasource make the correct updates to the attributes that are now updated?
[EDIT]
After extensive debugging and a lot of searching on the forum for jewels of information I came across one that gave me an idea.
In order to make a change to your ViewModel: Model you have to go to your DataSource.change method. In here, you then create a function to get the data from the JSON result passed back from your controller. In my case, I am submitting my whole model and returning it with an updated value called YTM.
Here is a snippet of code that will help you:
The ViewModel data attributes are stored in data. You can inspect this using the inspector in Chrome. What happens is that this will get the viewmodel. In my example, my viewmodel has a model called "order". I get a handle to this and then set it from the return JSON in viewModel.data. If someone has a better "best practice" let me know. This took me several days to figure out because of the lack of good documentation.
I send a viewmodel with my attributes to my controller. It makes the necessary update and returns a value or the model.
If I send back the model, will the datasource make the correct updates to the attributes that are now updated?
[EDIT]
After extensive debugging and a lot of searching on the forum for jewels of information I came across one that gave me an idea.
In order to make a change to your ViewModel: Model you have to go to your DataSource.change method. In here, you then create a function to get the data from the JSON result passed back from your controller. In my case, I am submitting my whole model and returning it with an updated value called YTM.
Here is a snippet of code that will help you:
change:
function
() {
// subscribe to the CHANGE event of the data source
viewModel.data =
this
.view()[0];
viewModel.order.set(
"ResidualYield"
, viewModel.data.ResidualYield);
}
The ViewModel data attributes are stored in data. You can inspect this using the inspector in Chrome. What happens is that this will get the viewmodel. In my example, my viewmodel has a model called "order". I get a handle to this and then set it from the return JSON in viewModel.data. If someone has a better "best practice" let me know. This took me several days to figure out because of the lack of good documentation.