Fancybox v2.1.3 Ajax加载表单 [英] Fancybox v2.1.3 ajax load form

查看:87
本文介绍了Fancybox v2.1.3 Ajax加载表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再次向所有花式盒子爱好者致敬.我陷入了ajax的困境,将外部html表单加载到当前查看的html文件中.我在将class ="fancybox.ajax"用作HTML的标记中使用了隐藏的触发器:

Hi again to all fancybox lovers. I got stuck with ajax load an external html form into current viewed html file. I use a hidden trigger with class="fancybox.ajax" in a tag that is brought into html that way:

$('body').prepend('<a class="fancybox fancybox.ajax" href="form.html" style="display: none;"></a>');

因此可以将该表单接下来带入html:

so that form can be brought next with following into html:

$(".fancybox.ajax").trigger('click'); 

但是这失败了.也许我需要上"或直播".我不知道是否有更好的方法来实现这一目标.然后,我想对表单提交进行一些js检查,但是它将如何运行?也许可以很好地使用上"

But this fails. Maybe i need "on" or "live". I do not know if there is a better way to achieve this. Then i want to make some js checks over form submission but how this will run? Maybe some good use of "on"

 $('#submit').on(click, function({ .... }));  

任何帮助将不胜感激.

推荐答案

宁可尝试

$(".fancybox").trigger('click'); 

...类fancybox用于将此类选择器绑定到fancybox,而fancybox.ajax类用于定义内容的类型(由于fancybox v2.x已经存在,因此无需使用live使用该方法)

... the class fancybox is used to bind such selector to fancybox while the fancybox.ajax class is used to define the type of content (you don't need to use live since fancybox v2.x already uses that method)

另一方面,如果要对表单提交执行某些操作,请尝试将.on()方法绑定到form选择器(而不是submit按钮),例如

On the other hand, if you want to perform some actions on form submit, try binding the .on() method to the form selector (not the submit button) like

$('#formSelector').on("submit", function({ //do somthing })); 

这篇关于Fancybox v2.1.3 Ajax加载表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆