如何使用 jQuery 验证引擎插件淡出错误提示?
我正在使用它 https://github.com/posabsolute/jQuery-Validation-Engine
我想知道如何让提示在不单击提示关闭的情况下自行关闭 4 秒代码行是 jquery.validationEngine.js 中的 26,它看起来像:
$(".formError").live("click", function() {
$(this).fadeOut(150, function() {
// remove prompt once invisible
$(this).remove();
});
});
我尝试删除 live 中的“click”,但是它没有工作,因为验证没有出现,任何人都可以帮助我吗?提前致谢!
I'm using from it https://github.com/posabsolute/jQuery-Validation-Engine
I wonder how to make the prompts should to close themselves by 4 seconds without clicking the prompts to closethe code line is 26 from jquery.validationEngine.js, it looks like:
$(".formError").live("click", function() {
$(this).fadeOut(150, function() {
// remove prompt once invisible
$(this).remove();
});
});
I tried to remove "click" inside of live, but it didn't work because the validations don't appear, anyone can help me? Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用自动隐藏选项。
检查validationEngine或validationEngine.js的文档 - 在.js文件的底部您将看到:
Use the autohide option.
Check the documentation of validationEngine or the validationEngine.js - at the bottom of the .js file you'll see:
我猜你是想确保“点击”事件只发生一次?如果是这样,请使用
unbind()
撤消所有事件侦听器。如果您想具体指定哪个事件侦听器,请使用参数:unbind("click")
,如下所示:});
当调用
unbind("click")
时,特定的.formError
元素将不再具有 click 事件侦听器,但所有其他元素仍然具有。编辑:
取消绑定与使用
live()
初始化的事件侦听器关联的所有事件时,必须使用die()
。抱歉,我已经有一段时间没有live()
了,所以我忘记了你必须die()
。I'm guessing you're trying to make sure the "click" event only happens once? If so, use
unbind()
to undo all event listeners. If you want to be specific about which event listener, use a parameter:unbind("click")
like this:});
When the
unbind("click")
is called, that particular.formError
element will no longer have the click event listener, but all the others still will.EDIT:
When unbinding all events tied to event listeners initialized with
live()
, you must usedie()
. Sorry, I hadn'tlive()
'd in a while, so I forgot you had todie()
.