fixed submitting delay
This commit is contained in:
parent
f004b389cb
commit
f2211438ce
|
@ -138,30 +138,29 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.submitForm = function(){
|
$scope.submitForm = function() {
|
||||||
var _timeElapsed = TimeCounter.stopClock();
|
var _timeElapsed = TimeCounter.stopClock();
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
var form = _.cloneDeep($scope.myform);
|
var form = _.cloneDeep($scope.myform);
|
||||||
form.timeElapsed = _timeElapsed;
|
form.timeElapsed = _timeElapsed;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
$scope.submitPromise = $http.post('/forms/'+$scope.myform._id, form)
|
setTimeout(function () {
|
||||||
.success(function(data, status, headers){
|
$scope.submitPromise = $http.post('/forms/' + $scope.myform._id, form)
|
||||||
console.log('form submitted successfully');
|
.success(function (data, status, headers) {
|
||||||
setTimeout(function() {
|
console.log('form submitted successfully');
|
||||||
$scope.myform.submitted = true;
|
|
||||||
$scope.loading = false;
|
$scope.myform.submitted = true;
|
||||||
}, 20);
|
$scope.loading = false;
|
||||||
})
|
})
|
||||||
.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
|
||||||
|
|
Loading…
Reference in a new issue