self.activate = function () { self.view = 'settings'; self.settings.removeAll(); return ajax.get('settings').done(function (settings) { ko.utils.arrayForEach(settings, function (setting) { self.settings.push(new SettingViewModel(setting)); }); }).fail(function (message) { app.showMessage(message, "Settings"); }); };
self.activate = function () { self.view = 'countries'; self.user = globals.user; self.countries.removeAll(); self.regions.removeAll(); var c = ajax.get('countries'); var r = ajax.get('regions', { active: true }); return $.when(c, r).done(function (c, r) { ko.utils.arrayForEach(c[0], function (country) { self.countries.push(new CountryViewModel(country)); }); ko.utils.arrayForEach(r[0], function (region) { self.regions.push(region); }); }).fail(function (message) { app.showMessage(message, "Countries"); }); };