diff --git a/demo/SurveyApp.Web/App/viewmodels/surveys.js b/demo/SurveyApp.Web/App/viewmodels/surveys.js index 6523973..0a26a76 100644 --- a/demo/SurveyApp.Web/App/viewmodels/surveys.js +++ b/demo/SurveyApp.Web/App/viewmodels/surveys.js @@ -1,43 +1,43 @@ define(['durandal/app', 'api/surveyApi', './surveys/deleteModal', './surveys/shared/locationInfo'], - function (app, surveyApi, deleteModal, locationInfo) { +function (app, surveyApi, deleteModal, locationInfo) { - return function () { - var self = this; + return function () { + var self = this; - self.surveySummaries = null; //loaded from ajax as ko.observableArray() - self.selectedSurvey = ko.observable(null); + self.surveySummaries = null; //loaded from ajax as ko.observableArray() + self.selectedSurvey = ko.observable(null); - //the router's activator calls this function and waits for the .complete jQuery Promise before - //transitioning the view in and eventually calling ko.applyBindings - self.activate = function () { - return surveyApi.getAll() - .then(function (surveys) { + //the router's activator calls this function and waits for the .complete jQuery Promise before + //transitioning the view in and eventually calling ko.applyBindings + self.activate = function () { + return surveyApi.getAll() + .then(function (surveys) { - //use ko.mapping library to convert the array to be observable for the summary view - self.surveySummaries = ko.mapping.fromJS(surveys); + //use ko.mapping library to convert the array to be observable for the summary view + self.surveySummaries = ko.mapping.fromJS(surveys); - if (self.surveySummaries().length > 0) - self.toggleSelected(self.surveySummaries()[0]); - }); - }; - - //show summary information about a survey when selected - self.toggleSelected = function (surveySummary) { - self.selectedSurvey(surveySummary); - return true; - }; + if (self.surveySummaries().length > 0) + self.toggleSelected(self.surveySummaries()[0]); + }); + }; - //open a modal requesting confirmation to delete the indicated modal - self.deleteSurvey = function (surveySummary) { - app.showModal(new deleteModal(surveySummary)) - .then(function (deletedSurvey) { - //promise returns the deleted survey if user clicks 'delete' in modal - if (deletedSurvey) - self.surveySummaries.remove(deletedSurvey); - }); - }; + //show summary information about a survey when selected + self.toggleSelected = function (surveySummary) { + self.selectedSurvey(surveySummary); + return true; + }; - //for locationInfo compose - self.locationInfo = locationInfo; + //open a modal requesting confirmation to delete the indicated modal + self.deleteSurvey = function (surveySummary) { + app.showModal(new deleteModal(surveySummary)) + .then(function (deletedSurvey) { + //promise returns the deleted survey if user clicks 'delete' in modal + if (deletedSurvey) + self.surveySummaries.remove(deletedSurvey); + }); }; - }); \ No newline at end of file + + //for locationInfo compose + self.locationInfo = locationInfo; + }; +}); \ No newline at end of file