fix to editing profile: "TypeError: Cannot call method 'toString' of undefined"

This commit is contained in:
Tyler Renelle 2013-10-23 10:24:24 -07:00
parent fe52731393
commit b23ce8426b

View file

@ -18,7 +18,9 @@ habitrpg.controller("UserCtrl", ['$rootScope', '$scope', '$location', 'User', '$
var values = {};
_.each($scope.editingProfile, function(value, key){
// Using toString because we need to compare two arrays (websites)
if($scope.editingProfile[key].toString() !== $scope.profile.profile[key].toString()) values['profile.' + key] = value;
var curVal = $scope.profile.profile[key];
if(!curVal || $scope.editingProfile[key].toString() !== curVal.toString())
values['profile.' + key] = value;
});
User.setMultiple(values);
$scope._editing.profile = false;