Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

html - Jquery-UI Dialog - on the fly without DIV

I have what I suspect to be a simple question and after search I suspect the answer to my question to be no, but to double check...

Is it possible to use the Jquery ui dialog with out setting up a DIV?

ie rather than..

$(function() { $( "#dialog" ).dialog();});...

<div id="dialog" title="Do I really need this?">This is a lot of typing just to pass on a simple message</div>

Is it possible just to have something like...

$(function(quickly) { $( "#dialog" ).dialog('this would be much easier');});...

and call it with a quickly() type thing when needed.

You may note that I muddle may way through Javascript and do my best through trial and error to hit on a solution that works for me.

I suppose, I'm asking if I can somehow use dialog in a similar fashion to...

alert("this is simple")

...so I can call an alert to the user whenever I need to, rather than on url click or button press.

Hopefully the above make sense and I'll suspect I'll have to stick with the ugly standard alert but do let me know if there is a simple solution.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I hope this helps somebody, you can pass html to dialog directly, like this:

$("<p>Hello World!</p>").dialog(); 

so this way you don't have to have a pre-builded div, you could use:

$("<div>My div content</div>").dialog();

EDIT: changed end tag to </div> instead of </p>


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...