2016-06-02 1 views
0

jQuery impromptu 라이브러리를 사용 중이며 비동기 성격을 이해하지 못합니다. 프롬프트가 실행 된 후 리디렉션하려는 코드가 있습니다. 내 data.redirectPage 문이 true이면 다음 코드 행을 실행하지 않으려합니다. 내가 빠른를 읽은 내용에서제출이 완료되고 종료 될 때까지 즉석을 지속 할 수 없습니다.

   success: function (data) { 
        if (data.redirectPage == "hackathonregistration") { 
         $.prompt("Your code has been accepted and you will now be redirected to the hackathon registration page", 
         { 
          submit: function() { 
           window.location.href = "/Register/hackathon"; 
          } 
         }); 
        } 

답변

0

Impromptu, 코드 확인을 보인다. 누락 된 }를 제외하고
... 당신의 success 기능을 닫습니다)

아무 버튼을 사용하면 트리거하려고 제출에.
중요한 것은 AND입니다.

이 시도 :

success: function (data) { 
    console.log(data.redirectPage); 
    if (data.redirectPage == "hackathonregistration") { 
     $.prompt("Your code has been accepted and you will now be redirected to the hackathon registration page", 
     { 
      buttons: { "Yes": true, "No": false }, 
      submit: function(e,v,m,f) { 
       // use e.preventDefault() to prevent closing when needed or return false. 
       // e.preventDefault(); 
       console.log("Value clicked was: "+ v); 
       if(v){ 
        window.location.href = "/Register/hackathon"; 
       } 
      } 
     }); 
    } 
} 

내가v가 false는 true bolean/가정하자 .
마찬가지로, 나는 Impromtu에
실제 빠른 을 읽었다.

Personnaly, 나는 SweetAlert을 사용합니다. 대안으로 찾아보십시오 ... 더 쉬울 수도 있습니다.

관련 문제