我正在使用 AMP 表单,但无法弄清楚如何在表单提交后显示相同的 html 以及一些额外的元素。
一般来说,我的标记更复杂,但这里有一个简单的例子来说明我需要做什么:
<form method="post" action-xhr="https://example.com/subscribe" target="_top" id="form1">
<ul>
<li>
<h2>Title 1</h2>
<input type="radio" value="1" name="answer" id="1" on="change:form1.submit">
<!-- Show this only on submit-success and there are used
some variables from amp-mustache -->
<div>Some Html {{Votes}}</div>
</li>
<li>
<h2>Title 2</h2>
<input type="radio" value="2" name="answer" id="2" on="change:form1.submit">
<!-- Show this only on submit-success and there are used
some variables from amp-mustache -->
<div>Some Html {{Votes}}</div>
</li>
...
</ul>
</form>
我知道我可以使用这样的东西,但不想复制标记(正如我所提到的,它比提供的示例更复杂):
<form method="post" action-xhr="https://example.com/subscribe" target="_top" id="form1">
<ul>
<li>
<h2>Title 1</h2>
<input type="radio" value="1" name="answer" id="1" on="change:form1.submit">
</li>
<li>
<h2>Title 2</h2>
<input type="radio" value="2" name="answer" id="2" on="change:form1.submit">
</li>
...
</ul>
<div submit-success>
<template type="amp-mustache">
<ul>
<li>
<h2>Title 1</h2>
<input type="radio" value="1" name="answer" id="1" class="relative" on="change:form1.submit">
<div>Some Html {{Votes}}</div>
</li>
<li>
<h2>Title 2</h2>
<input type="radio" value="2" name="answer" id="2" class="relative" on="change:form1.submit">
<div>Some Html {{Votes}}</div>
</li>
...
</ul>
</template>
</div>
</form>