[英]Keep div shown after submitting form using jQuery in MODx Evo
I have a form that is hidden when first loading thispage我有一个在第一次加载此页面时隐藏的表单
Once user clicks the chevron down below "CONTACT US AND TELL US ABOUT YOUR CASE" the form appears.一旦用户单击“联系我们并告诉我们您的案例”下方的 V 形符号,就会出现表单。
Once eform submits, the form becomes hidden again提交 eform 后,表单将再次隐藏
<div class="describe" style="display: none;">
and validation messages are not viewable unless the chevron is clicked again as seen here:除非再次单击 V 形标志,否则无法查看验证消息,如下所示:
https://share.getcloudapp.com/RBuXmEvE https://share.getcloudapp.com/RBuXmEvE
I'm using我正在使用
<button type="button" value="Submit" onclick="this.form.submit();">Submit</button>
to submit the form.提交表格。
Should I call another javascript function that runs onclick as well as the code to display the form?我应该调用另一个运行 onclick 的 javascript 函数以及显示表单的代码吗?
I believe that the javascript code currently being used to show and hide the form is here:我相信当前用于显示和隐藏表单的 javascript 代码在这里:
<script>
$(document).ready(function(){
$('.case > a').click(function(){
$('.describe').slideToggle();
$(this).toggleClass('active');
});
});
</script>
Or should I attempt to show the form in a MODx snippet (which is just PHP code)?或者我应该尝试在 MODx 片段(这只是 PHP 代码)中显示表单?
You can use a snippet to determine if the form is submitted and use that result to display (or not) your element.您可以使用片段来确定表单是否已提交并使用该结果来显示(或不显示)您的元素。 I suggest using an Extra named FormIt for creating forms on your website ( FormIt documentation ).
我建议使用名为 FormIt的Extra在您的网站上创建表单( FormIt 文档)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.