2017-03-16 50 views
0

我已经在我的前端下面的代码:HTML显示为文字文本

<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> 

的HTML代码,我添加如下:

<table> 
    <tr id='EmptyAuthDetails'> 
     <td style='text-align:center;' colspan='5'>No Authorization Details found</td> 
    </tr> 
</table><br/> 

不幸的是,它实际上并没有呈现HTML:

enter image description here

我尝试添加该如使用jQuery HTML,如所建议的答案this question

jQuery(document).ready(function() { 
    jQuery("#AuthorizationForMasterSchedule").html("<%: authorizeHTML %>") 
}) 

但它并没有任何区别。 (顺便说一下,为了记录,我完全知道$语法 - 为什么我不在这里使用它背后有一个很长的故事)。

回答

1

不知道为什么你做这么多的CSS更改查看。我在删除css更改后创建了此示例:https://jsfiddle.net/pcjm1q9d/

HTML:

<div id="AuthorizationForMasterSchedule" ></div> 

的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(); 
     }); 

您可以直接控制使用jQuery的对话框行为。检查文档的对话框。