2017-12-27 19 views
0

나는 AMP를 사용하고있다. 나는 사용자의 모바일 번호를 물어보고 다음 hit api(let's X). 응답이 성공한 경우 결과를 사용자에게 표시하고 응답은 error then I asked otp입니다. otp에 들어가서 확인을 클릭하면 I hit api(let's Y)을 확인합니다. API Y의 응답은 다음과 같습니다. API 및 Y if code=1 then only I want to hit api Xsuccess의 응답에일부 조건이 다른 양식과 일치하는 경우에만 양식을 제출 하시겠습니까?

Response code=200 
code=1 or 2 or 3 
Response code=400 
Message:"some error" 

. 나는 이것을 어떻게하는지 모른다. 다음은 내가 한 일이다.

<form method="post" 
     id="form1" 
     action-xhr="url of X api" 
     on="submit-error:otpScreen.show"> 
. 
. 
. 
</form> 
<form method="get" 
     action-xhr="url of Y api" 
     on="submit-success:event.response.code==1?form1.submit:otpScreen.hide" //here i getting syntax error 
> 
<div id='otpScreen'>.......</div> 
</form> 

첫 번째 양식의 일부 조건에서 두 번째 양식을 제출할 수 있습니까?

답변

2

두 번째 양식의 제출 단추를 비활성화하려면 첫 번째 항목이 제출 될 때까지 amp-bind를 사용합니다.

<form id=form1 on="submit-success:AMP.setState({form1Success: true})">...</form> 
<form id=form2> 
    ... 
    <input type=submit disabled [disabled]="!form1Success"> 
</form> 

...하거나 hidden 속성을 사용하여 두 번째 양식을 숨길 수 있습니다 : 예를 들어

<form id=form1 on="submit-success:AMP.setState({form1Success: true})">...</form> 
<form id=form2 hidden [hidden]="!form1Success"> 
    ... 
</form> 
+0

을하지만,이 자동으로 제출되지 않습니다 형태 2, I는 사용자 상호 작용 경우없이 양식이 제출하려면 특정 조건 일치 (문제의 조건 언급) – yajiv

+0

그게 없어 - 그게 훨씬 간단합니다. 답변을 업데이트했습니다. –