|
/*global $, ViewModel, ko, propertyDataSource */
ViewModel.SearchResultsViewModel = function () {
var that = this;
// framework fields
this.template = "searchResultsView";
this.factoryName = "SearchResultsViewModel";
// ----- public properties
this.isLoading = ko.observable(false);
this.totalResults = undefined;
this.pageNumber = ko.observable(1);
this.searchLocation = undefined;
this.properties = ko.observableArray();
// ----- public functions
this.initialize = function (searchLocation, results) {
$.each(results.data, function () {
var viewModel = new ViewModel.PropertyViewModel();
viewModel.initialize(this);
that.properties.push(viewModel);
});
that.searchLocation = searchLocation;
that.totalResults = results.totalResults;
};
this.loadMore = function() {
this.pageNumber(this.pageNumber()+1);
this.isLoading(true);
this.searchLocation.executeSearch(this.pageNumber(), function (results) {
that.isLoading(false);
$.each(results.data, function () {
var viewModel = new ViewModel.PropertyViewModel();
viewModel.initialize(this);
that.properties.push(viewModel);
});
that.pageNumber(that.pageNumber() + 1);
});
};
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.