[英]HTML inside of a jQuery UI Dialog is displayed as literal text
I have the following code on my front-end: 我的前端有以下代码:
<script type="text/javascript">
function bringUpAuthorization() {
var control = jQuery("#AuthorizationForMasterSchedule");
control.css("visibility", "visible");
control.dialog(
{
title: "Authorization",
close: function () {
control.css("visibility", "collapse");
}
})
}
</script>
<div id="AuthorizationForMasterSchedule" style="visibility: collapse"><%: authorizeHTML %></div>
The HTML code I'm adding is as follows: 我要添加的HTML代码如下:
<table>
<tr id='EmptyAuthDetails'>
<td style='text-align:center;' colspan='5'>No Authorization Details found</td>
</tr>
</table><br/>
Unfortunately, it doesn't actually render the HTML: 不幸的是,它实际上并未呈现HTML:
I tried adding this as HTML using jQuery, as suggested by the answers to this question : 我尝试使用jQuery将其添加为HTML, 这是该问题的答案所建议的:
jQuery(document).ready(function () {
jQuery("#AuthorizationForMasterSchedule").html("<%: authorizeHTML %>")
})
but it didn't make any difference. 但这没什么区别。 (By the way, for the record, I'm perfectly aware of the $
syntax - there's a long story behind why I'm not using it here). (顺便说一下,为了便于记录,我非常清楚$
语法-为什么我在这里不使用它还有很长的历史)。
Not sure why you are making so many css changes for viewing. 不确定为什么要进行如此多的CSS更改以供查看。 I created this sample after removing the css changes: https://jsfiddle.net/pcjm1q9d/ . 我在删除CSS更改后创建了此样本: https : //jsfiddle.net/pcjm1q9d/ 。
HTML: HTML:
<div id="AuthorizationForMasterSchedule" ></div>
Javascript: Javascript:
$( function() {
jQuery("#AuthorizationForMasterSchedule").html("<table> <tr id='EmptyAuthDetails'> <td style='text-align:center;' colspan='5'>No Authorization Details found</td> </tr></table><br/>");
//show dialog box
$( "#AuthorizationForMasterSchedule" ).dialog();
} );
You can control the dialog behavior using jquery directly. 您可以直接使用jquery控制对话框的行为。 check the documentation for dialog. 查看对话框文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.