jQuery UI Alert对话框替代alert() [英] jQuery UI Alert Dialog as a replacement for alert()

查看:274
本文介绍了jQuery UI Alert对话框替代alert()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用alert()将验证错误输出回用户,因为我的设计没有提供其他任何准备,但是我宁愿使用jQuery UI对话框作为消息的警报对话框.

I'm using alert() to output my validation errors back to the user as my design does not make provision for anything else, but I would rather use jQuery UI dialog as the alert dialog box for my message.

由于(html)div中不包含错误,因此我不确定如何执行此操作.通常,您会将dialog()分配给一个说$("#divName").dialog()的div,但我更需要js函数,例如alert_dialog("Custom message here")或类似的东西.

Since errors are not contained in a (html) div, I am not sure how to go about doing this. Normally you would assign the dialog() to a div say $("#divName").dialog() but I more need a js function something like alert_dialog("Custom message here") or something similiar.

有什么想法吗?

推荐答案

我认为您甚至不需要将其附加到DOM,这似乎对我有用:

I don't think you even need to attach it to the DOM, this seems to work for me:

$("<div>Test message</div>").dialog();

这是一个JS小提琴:

http://jsfiddle.net/TpTNL/98

这篇关于jQuery UI Alert对话框替代alert()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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