2015-01-14 27 views
0

我在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."); 
     } 
    }; 
+0

您是否可以儘可能簡化示例並製作小提琴。澄清會更好。 –

+0

@Lautaro Cozzani,這裏是一個縮小版本:http://jsfiddle.net/jimcamut/xos805gk/ – user1791914

回答

0

元件 'MC-嵌入訂閱' 是輸入,但你需要 「提交()」 的形式。 此行

document.getElementById('mc-embedded-subscribe').submit(); 

應該

document.getElementById('mc-embedded-subscribe-form').submit(); 

這裏被改變,你有這個新的小提琴變化,和它的作品! http://jsfiddle.net/kx8dn8wc/

+0

我忽視了一個重要的細節引起了幾個小時的挫折感。感謝您耐心看待這個和敏銳的眼光! – user1791914

+0

太棒了,4隻眼睛看起來比2更好 –

相關問題