GeekedOut
GeekedOut

Reputation: 17185

How to put jQuery Dialog popup div into the jQuery code?

I have a very simple message to display in one jQuery popup and I just want to generate it without adding extra divs into my HTML.

What I'd like to do is just open a dialog box with a message and thats it.

Here is something like that I want:

$("<div>Hello sir</div>").dialog("open");

But that doesn't work. Should it? It seems like that should just open a simple dialog box, shouldn't it?

Thanks!!

Upvotes: 2

Views: 1605

Answers (3)

Manse
Manse

Reputation: 38147

$("<div>This is a test</div>").dialog();

works fine for me http://jsfiddle.net/fyMct/

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1039090

You don't need to call open, simply:

$('<div />').html('Hello sir').dialog();

And here's a live demo.

Upvotes: 3

DhruvPathak
DhruvPathak

Reputation: 43245

Have you made sure you have included jQuery.UI library in addition to core jQuery ?

see example here : http://jqueryui.com/demos/dialog/

Upvotes: 1

Related Questions