create dialog without id in jquery

感情迁移 提交于 2019-12-11 07:29:17

问题


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


回答1:


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*/});



回答2:


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.



来源:https://stackoverflow.com/questions/1377247/create-dialog-without-id-in-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!