this.setState = function (stateString) { /// <summary> /// Sets the application based on the given JSON string /// </summary> var i, viewModel, state = $.parseJSON(stateString); that.viewModelBackStack.removeAll(); for (i = 0; i < state.length; i++) { viewModel = util.hydrateObject(state[i]); that.viewModelBackStack.push(viewModel); } };
function setState(jsonState) { var state = $.parseJSON(jsonState); if (!state) return; if (state.favourites) { $.each(state.favourites, function () { propertySearchViewModel.favourites.push(util.hydrateObject(this)); }); } if (state.recentSearches) { $.each(state.recentSearches, function () { propertySearchViewModel.recentSearches.push(util.hydrateObject(this)); }); } // last / first item state are not persisted, so we have to update propertySearchViewModel.updateListStyling(propertySearchViewModel.recentSearches); }