jQuery UI 警报对话框作为 alert() 的替代品 [英] jQuery UI Alert Dialog as a replacement for alert()

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

问题描述

我使用 alert() 将我的验证错误输出给用户,因为我的设计没有为其他任何东西做准备,但我更愿意使用 jQuery UI 对话框作为警报对话框对于我的消息.

由于错误不包含在 (html) div 中,我不确定如何执行此操作.通常你会将 dialog() 分配给一个 div 说 $("#divName").dialog() 但我更需要一个类似于 alert_dialog 的 js 函数(此处的自定义消息") 或类似的内容.

有什么想法吗?

解决方案

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

$("

测试消息

").dialog();

这是一个 JS 小提琴:

http://jsfiddle.net/TpTNL/98

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.

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.

Any ideas?

解决方案

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

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

Here's a JS fiddle:

http://jsfiddle.net/TpTNL/98

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

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