I am working with JQueryUI and Asp.net and encounter a dynamic 开发者_JS百科content problem:
<div id="content" title="" style="color: #F7A356">
<%=ContentLabel.Text%>
</div>
function OpenDialog() {
// alert(document.getElementById("content").innerHTML);
var $dialog = $('<div style="color: #F7A356"></div>')
.html($("#content").text())
.dialog({
autoOpen: false,
modal: true,
height: 150,
});
$dialog.dialog('open');
}
I would like to open a dialog when I click on a control and show the content.. but it failed with the above method....
it doesn't work even I just some a simple javascript alert function with the innerHTML.....It return nothing as well
this is how it should look like..
$(document).ready(function() {
.dialog({
autoOpen: false,
modal: true,
height: 150,
});
$('a .opendialog').click(function(){
$('#content').dialog('open');
}
});
if this does not help please provide more html
You should add the newly created element to the document before opening the dialog. Try something like:
$('<div style="color: #F7A356"></div>')
.html($("#content").html())
.appendTo("body")
.dialog({
modal: true,
height: 150
});
精彩评论