jQuery.validate 可能破坏了 Facebox 弹出窗口
我的 Facebox 弹出窗口包含一个带有提交按钮的表单。我还有第二个按钮来打开一个不相关的 Facebox 弹出窗口,该弹出窗口在我将 jQuery.validate 添加到项目之前正在运行。我需要在提交之前验证电子邮件和密码字段。
我应该补充一点,这些弹出窗口是通过外部 .html 文件加载的。这通过 AJAX 请求加载它们。
在 index.html 上,设置弹出窗口($k 等于 jQuery.noConflict());
$k('a[rel*=example_2]').facebox_1({
loading_image : '/images/loading.gif',
close_image : '/images/closelabel.gif'
});
点击链接打开上面的 Facebox:
<a href="login.html" title="Log In" rel="example_2" id='login'>Log In </a>
下面的所有内容都在 login.html 中
验证:
$(function () {
$('form[name="login"]').validate({
rules: {
email: { required: true, email: true },
password: "required"
},
messages: {
email: "",
password: ""
}
});
});
以及表单:
<form name="login" method="post" action="login.aspx">
以及不起作用的按钮
<a href="#" title="Register" onclick="showRegister()" ><img src="images/register.jpg" /></a>
Nick 帮助我在 这篇文章,但它似乎破坏了另一个按钮。我在调试脚本时遇到问题,因为我不知道 Firebug 是否可以在外部请求(通过 XHR)页面中设置断点。
我尝试向刚刚调用 showRegister() 的损坏按钮添加一个单击处理程序,但这也不起作用。 showRegister()
简单调用 $('#linkFromIndexDotHtml').click();
,它实际上是来自 index.html 的链接。我认为这可能是问题所在,但它之前就有效。
My Facebox pop-up contains a form with a submit button. I also have a second button to open an unrelated Facebox pop-up that was working before I added jQuery.validate to the project. I need to validate the email and password fields prior to being submitted.
I should add that these pop-ups are loaded via external .html files. This loaded them via AJAX request.
On index.html, the pop-ups are setup ($k is equal to jQuery.noConflict());
$k('a[rel*=example_2]').facebox_1({
loading_image : '/images/loading.gif',
close_image : '/images/closelabel.gif'
});
And the link clicked to open the above Facebox:
<a href="login.html" title="Log In" rel="example_2" id='login'>Log In </a>
And everything below is in login.html
The validation:
$(function () {
$('form[name="login"]').validate({
rules: {
email: { required: true, email: true },
password: "required"
},
messages: {
email: "",
password: ""
}
});
});
And the form:
<form name="login" method="post" action="login.aspx">
And the button that doesn't work
<a href="#" title="Register" onclick="showRegister()" ><img src="images/register.jpg" /></a>
Nick helped me get the form posting in this post, but it seems to have broken the other button. I'm having problems debugging the script, because I don't know if Firebug can set breakpoints in externally requested (via XHR) pages.
I tried adding a click handler to the broken button that just called showRegister(), and that didn't work either. showRegister()
simple calls $('#linkFromIndexDotHtml').click();
which is, in fact, a link from index.html. I thought that may be the problem, but it worked prior.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了同样的问题,并使用 http://old.nabble 的信息解决了它。 com/Validation-and-Facebox-td22187264s27240.html
...
*在主声明中添加变量 dom 和 dom_data
脸盒
...
*这
最后在 fillFaceboxFromHref 中,
...
* 这是在文件的末尾
I had the same problem and solved it with info from http://old.nabble.com/Validation-and-Facebox-td22187264s27240.html
...
*add in the variables dom and dom_data in the main declaration of
facebox
...
*this is in fillFaceboxFromHref
finally,
...
* this is at the end of the file