根据 Fancybox API,我在 iframe 中使用以下代码:
<form>
... // form fields here
<button onclick="parent.$.fancybox.close();">
<span>Save</span>
</button>
</form>
单击“保存”时,表单实际上会关闭 - 但不会提交表单内容。就像close
事件在表单实际提交其内容之前触发。
如果没有onclick
,内容已提交,但后续页面在 iframe 内打开 - 这不是我想要的。
有没有解决的办法?
谢谢你的帮助。
您可以使用event.preventDefault() http://api.jquery.com/event.preventDefault/像这样的方法:
<form>
... // form fields here
<button onclick="event.preventDefault(); parent.$.fancybox.close();">
<span>Save</span>
</button>
</form>
Then 使用jquery提交页面 http://api.jquery.com/submit/
所以最好将其放在这样的函数中:
function closeME()
{
event.preventDefault();
parent.$.fancybox.close();
$('#myForm').submit();
}
... // form fields here
<button onclick="closeME();">
<span>Save</span>
</button>
</form>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)