我在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