@@ -448,10 +450,14 @@ function updateViewModel_main(app, viewModel, key, doc, vm_config) {
addComputed(snapshot);
debug && console.log('updating main viewModel', snapshot, viewModel, vm_config);
ko.mapping.fromJS(snapshot, vm_config.mapping, viewModel);
- debug && console.log('updated main viewModel', viewModel);
viewModel._newAttribute("");
+ debug && console.log('updated main viewModel', viewModel);
}
+function post_updateViewModel_main(app, viewModel, key, doc, vm_config) {
+ debug && console.log('post_update main viewModel', viewModel);
+ app.fn.main.updateSelectedMode();
+}
/* crazy expensive caching tree traverse */
function traverse(current, field, property, depth, pos) {
@@ -622,6 +628,20 @@ function updateViewModel(app, viewModels, key, doc, vm_config) {
app.state.vm.updating[key] = false;
}
+function defaultPostUpdateViewModel(app, viewModel, key, doc, vm_config) {
+ debug && console.log('post_updating', key, 'viewModel', viewModel, vm_config);
+}
+
+
+function post_updateViewModel(app, viewModels, key, doc, vm_config) {
+ var viewModelMethod = defaultPostUpdateViewModel;
+ var methodName = 'post_updateViewModel_' + key;
+ if (this.hasOwnProperty(methodName)) {
+ viewModelMethod = this[methodName];
+ }
+ viewModelMethod(app, viewModels[key], key, doc, vm_config);
+}
+
function onDocChange(app, viewModels, key, doc, vm_config) {
return function onChange() {
@@ -630,6 +650,7 @@ function onDocChange(app, viewModels, key, doc, vm_config) {
debug && console.log(key, ' viewModel changed!! updating', vm_config);
if (viewModels[key]) {
updateViewModel(app, viewModels, key, doc, vm_config);
+ post_updateViewModel(app, viewModels, key, doc, vm_config);
} else {
console.error('HUH!!');
initViewModel(app, viewModels, key, doc, vm_config);