如何使用Twitter Bootstrap弹出窗口进行jQuery验证通知? [英] How to use Twitter Bootstrap popovers for jQuery validation notifications?

查看:87
本文介绍了如何使用Twitter Bootstrap弹出窗口进行jQuery验证通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 bootstrap 轻松显示弹出窗口,也可以使用标准的<一个href ="http://docs.jquery.com/Plugins/Validation" rel ="noreferrer"> jQuery验证插件或

I can make popovers appear using bootstrap easily enough, and I can also do validations using the standard jQuery validation plugin or the jQuery validation engine, but I can't figure out how to feed one into the other.

我认为我需要一个钩子,当想要显示通知时,验证器会调用该钩子,并给它提供一个闭包,将消息和目标元素传递给弹出框.这似乎是一种依赖注入.

I think what I need is some hook which is called by the validator when it wants to display a notification, give it a closure that passes the message and the target element to a popover. This seems like a kind of dependency injection.

从理论上讲,一切都很好,但我只是无法弄清楚该钩子在哪里,或者即使在任一验证引擎中存在钩子也是如此.当我只想知道错误类型(我甚至不需要消息文本)和与之相关的元素时,他们似乎都打算负责显示带有各种精心设计的布局,包装,样式的通知的责任.到.我找到了整个表单的钩子,而不是各个通知的钩子.

All nice in theory, but I just can't figure out where that hook is, or even if one exists in either validation engine. They both seem intent on taking responsibility for displaying notifications with all kinds of elaborate options for placement, wrappers, styles when all I'm after is the error type(s) (I don't necessarily even need message text) and element it relates to. I've found hooks for the entire form, not the individual notifications.

我更喜欢使用类定义规则的验证系统,因为它们在动态创建的表单中可以很好地发挥作用.

I much prefer validation systems that use classes to define rules, as they play nicely with dynamically created forms.

有人有解决方案或更好的主意吗?

Anyone have a solution or a better idea?

推荐答案

看看highlightshowErrors

Take a look at the highlight and showErrors jQuery Validator options, these will let you hook in your own custom error highlights that trigger Bootstrap popovers.

这篇关于如何使用Twitter Bootstrap弹出窗口进行jQuery验证通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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