ko applyBindings optimization

This commit is contained in:
RainLoop Team 2014-05-22 20:08:38 +04:00
parent f3c0d0fbc7
commit c458ea8103
8 changed files with 198 additions and 183 deletions

View file

@ -63,9 +63,7 @@ AbstractSettings.prototype.onRoute = function (sSubName)
RoutedSettingsViewModel = /** @type {?Function} */ RoutedSettingsViewModel;
oSettingsScreen = new RoutedSettingsViewModel();
oViewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide().attr('data-bind',
'template: {name: "' + RoutedSettingsViewModel.__rlSettingsData.Template + '"}, i18nInit: true');
oViewModelDom = $('<div></div>').addClass('rl-settings-view-model').hide();
oViewModelDom.appendTo(oViewModelPlace);
oSettingsScreen.data = RL.data();
@ -77,7 +75,11 @@ AbstractSettings.prototype.onRoute = function (sSubName)
RoutedSettingsViewModel.__builded = true;
RoutedSettingsViewModel.__vm = oSettingsScreen;
ko.applyBindings(oSettingsScreen, oViewModelDom[0]);
ko.applyBindingAccessorsToNode(oViewModelDom[0], {
'i18nInit': true,
'template': function () { return {'name': RoutedSettingsViewModel.__rlSettingsData.Template}; }
}, oSettingsScreen);
Utils.delegateRun(oSettingsScreen, 'onBuild', [oViewModelDom]);
}
else