2013-03-20 242 views
2

当用户点击'评论'按钮。hide按钮点击

<input id="SubmitCommentsToInvoice" type="button" value="Comments" onclick="ShowCommentBox('<%: item.DBId %>', '<%: item.LabourOrPlant %>', '<%: item.ActivityDescription %>')" /> 

使用提交按钮加载文本区域。当用户完成输入数据和他们点击“提交”我想框消失。(返回到正常屏幕观看)

<div id="dialog" title="Comments" style="display:none;"> 
    <textarea id="BlankBox" type="text" runat="server" rows="7" 
    maxlength="2000" />  
    <input id="SubmitComment" type="button" value="Submit" 
        onclick="SubmitButton()" /> 
    </div> 

    function SubmitButton() { 
       var commentBoxData = $('#<%=BlankBox.ClientID%>').val(); 
       WorkItemMgr.CommentBoxForInvoiceUpdates(id, LabouringOrPlanting, commentBoxData, testForSuccess); 
      } 

      function testForSuccess(CommentSuccessfullyUpdated) 
      { 
       if (CommentSuccessfullyUpdated == "TRUE") 
       { 
        //$('#' + IdCommentBox).hide(); 
        // $('#<%=BlankBox.ClientID%>').hide(); just hides comment box need to hide entire thing 
        $("#dialog").dialog({ modal: true }).hide(); 
    //IN HERE I WOULD LIKE TO HIDE THE DIV (MY ATTEMPTS SEEN ABOVE) 
       } 
       else if (CommentSuccessfullyUpdated == "False") 
       { 
        showLoadingImage.src = "../Images/X.png"; 
       } 
      } 

我尝试隐藏textarea的,但我想再次隐藏整个DIV并返回到屏幕(摆脱模态:真)的正常观看

回答

0

使用jQuery:

$("#div_id").hide(); 
0

在jQuery中

$('#BlankBox').hide(); 

在javascript中

document.getElementById("BlankBox").style.display='none'; 
1

我不认为这条线是做什么的,你觉得它在做什么:

$("#dialog").dialog({ modal: true }).hide(); 

这告诉对话框插件初始化#dialog作为一个新的对话框(模式),然后告诉jQuery隐藏整个事情。如果#dialog已经一个模式对话框,在这一点上,你只是想隐藏它,试试这个:

$("#dialog").dialog("close"); 

这告诉对话框插件隐藏(或接近)的现有对话。

一般而言,如果可能,您希望使用插件的本地功能,而不是尝试对其应用其他功能。在这种情况下,最好告诉jQuery UI对话框隐藏自己,而不是尝试使用jQuery(它不知道对话框插件)来隐藏div,因为它不知道是否有任何“特殊”该div(其中,另一个插件正在使用它... jQuery UI对话框)。

1

,如果你使用jQuery UI的对话框如果您使用jQuery UI的对话框,那么你应该使用close method

$("#dialog").dialog('close'); 
0

,尝试用:$("#dialog").dialog({ hide: 1 });

0

试试这个:

<div id="dialog" title="Comments" style="display:none;"> 
    <textarea id="BlankBox" type="text" runat="server" rows="7" maxlength="2000" />  
    <input id="SubmitComment" type="button" value="Submit"/> 
</div> 

的jQuery将是:

$(function(){ 
    $('#SubmitComment').click(function(){ 
     $(this).closest('#dialog').hide(); 
    }); 
});