fixed submitting delay

This commit is contained in:
David Baldwynn 2016-04-28 20:13:37 -07:00
parent f004b389cb
commit f2211438ce

View file

@ -147,21 +147,20 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
form.percentageComplete = $filter('formValidity')($scope.myform) / $scope.myform.visible_form_fields.length * 100; form.percentageComplete = $filter('formValidity')($scope.myform) / $scope.myform.visible_form_fields.length * 100;
delete form.visible_form_fields; delete form.visible_form_fields;
setTimeout(function () {
$scope.submitPromise = $http.post('/forms/' + $scope.myform._id, form) $scope.submitPromise = $http.post('/forms/' + $scope.myform._id, form)
.success(function (data, status, headers) { .success(function (data, status, headers) {
console.log('form submitted successfully'); console.log('form submitted successfully');
setTimeout(function() {
$scope.myform.submitted = true; $scope.myform.submitted = true;
$scope.loading = false; $scope.loading = false;
}, 20);
}) })
.error(function (error) { .error(function (error) {
setTimeout(function(){
$scope.loading = false; $scope.loading = false;
console.log(error); console.log(error);
$scope.error = error.message; $scope.error = error.message;
}, 20);
}); });
}, 500);
}; };
//Load our form when the page is ready //Load our form when the page is ready