我在Angular中用update()函數提交表單,然後驗證它,返回一個承諾,如果成功則提交第二個表單。Angular在第一次表單驗證/承諾後提交第二個表單
問題是,第二種形式不會提交與document.getElementById(elementID).submit();方法。但是,它將使用document.getElementById(elementID).click();但只限於非觸控設備。
底線 - 爲什麼不提交()工作?
這裏是降低和簡化版本的jsfiddle:http://jsfiddle.net/jimcamut/xos805gk/
這裏是我的功能處理表單提交其完整版本。使用id =
$scope.update = function(user) {
if ($scope.earlyUser.$valid) {
$scope.master = angular.copy(user);
console.log("Form submitted on front end");
// This integrates ParseJS and submits the data to a database - all good here, except after the promise
var parseUser = new Parse.Object("LaunchUser");
parseUser.setACL(new Parse.ACL());
parseUser.save({
name: $scope.master.name,
email: $scope.master.email,
zipcode: $scope.master.zipcode
},{
error: function(model, error) {
console.log("error is...");
console.log(error);
}
// Returns a promise
}).then(function(object) {
// Problem area here when attempting to submit second form...
document.getElementById('mc-embedded-subscribe').submit();
$scope.reset();
});
} else {
alert("Please correct the red form fields.");
}
};
您是否可以儘可能簡化示例並製作小提琴。澄清會更好。 –
@Lautaro Cozzani,這裏是一個縮小版本:http://jsfiddle.net/jimcamut/xos805gk/ – user1791914