create dialog without id in jquery

2019-08-03 09:33发布

I have a query regarding jquery that i want to create a dialog open and then fill some values in it. As i have tried to create a dialog using jquery it uses old values because that div already exists on that page. So i want to create an object of the dialog using jquery and then fill fields in it. I am using jsmarty and jquery together. Thanks

2条回答
疯言疯语
2楼-- · 2019-08-03 10:15

You can just do something like this...

var jDialogContainer = $(document.createElement("div"));
// add anything to jDialogContainer you want
jDialogContainer.html("hello");
jDialogContainer.dialog({/*options go here*/});
查看更多
淡お忘
3楼-- · 2019-08-03 10:19

The quickest way is to create the dialog on the fly then just call dialog on it:

$('<div>').html('Hello ' + someVar).dialog()

I like to use jQuery template http://api.jquery.com/jQuery.template/ to create HTML, then call something like dialog on it.

查看更多
登录 后发表回答