2011-07-12 25 views
-1

我有一個telerik窗口裏面有多個div,它的可見性是根據javascript函數設置的。 現在我想調用一個javascript函數,以便窗口中的任何可見div都隱藏在telerik窗口的close事件上,即我必須在運行時的窗口onclose事件中傳遞可見性=可見性的div的id。javascript在mvc事件

我該怎麼做?

function opendivinwindow(thediv) { 
      var div = document.getElementById(thediv); 
       div.style.visibility = "visible"; 
       var window = $("#Window").data("tWindow"); 
       window.center().open(); 
      } 

    function Onclose() {   
       var div = document.getElementById('resumetitle'); 
       div.style.visibility = "hidden"; 
      } 

查看

<% using (Html.BeginForm("Resumename", "resumewizard", FormMethod.Post, new { name = "Resumetitle",OnLoad="Error();"})) 
      {%> 
      <%=Html.Label("Step 1.Resume Name")%><br /> 
      <%=Html.Label("Please Enter Resume Name,Job Title and Objective")%><br /> 
     <%=Html.Label("Resume Name")%><br /> 
     <%=Html.TextBox("ResTitle")%><a href="javascript:opendivinwindow('resumetitle');"> 
     <img src= "../../Content/img/module/QuestionMark.gif" /></a><br /> 
     <%-- <div id="resumetitle" style="visibility:hidden">Resume title</div>--%> 
     <%=Html.Label("Desired Job Title/Position")%><br /> 
     <%=Html.TextBox("DesPos")%><a href="javascript:opendivinwindow('desiredposition');"> 
     <img src= "../../Content/img/module/QuestionMark.gif" /></a><br /> 

     <%=Html.Label("Objective")%><br /> 
     <%=Html.TextArea("ResObjective")%> 
     <a href="javascript:opendivinwindow('desiredobjective');"> 
     <img src= "../../Content/img/module/QuestionMark.gif" /></a> 
     <br /> 
     <% string str = ViewData["Errormsg"].ToString(); 
     %> 
     <div id="msgblock"> 
     <%=Html.Label(str)%> 
     <%=Html.Hidden("error", ViewData["Errormsg"])%> 
     <%=Html.Hidden("resumeid",ViewData["resumeid"])%> 
     </div> 
     <input id="SaveForwardButton1" type="image" src="../../Content/img/buttons/SaveForwardButton.gif" onclick="return validation();" /> 


     <% Html.Telerik().Window() 
     .Name("Window") 
.Title("Telerik Window for ASP.NET MVC") 
.Resizable(resizing => resizing 
.MinHeight(250) 
.MinWidth(250) 
.MaxHeight(500) 
.MaxWidth(500) 
) 
.Buttons(b => b.Maximize().Close()) 
.Content(() => 
{%> 

<div id="resumetitle" style="visibility:hidden">Resume Name: (will NOT display to employers - max. 50 characters) 

- The Resume Name will NOT display to employers. It is for your personal use, to help you identify each unique resume. You can store up to 5 resumes.</div> 
<div id="desiredposition" style="visibility:hidden">The Desired Job Title will appear at the top of your resume directly under the contact information heading and will be the first item potential employers see. 

Use this field to state your desired Job Title or describe the type of position you are seeking.</div> 
<div id="desiredobjective" style="visibility:hidden">Enter the objective of your career move. This is a good opportunity to tell would-be employers what you are all about. Entering specific information regarding your specific history increases the visibility potential of your resume.</div> 
<%}) 
.Width(300) 
.Height(300) 
.Visible(false) 
.ClientEvents(events => events.OnClose("Onclose")) 
.Render(); 
%> 
<% }%> 
+2

最新的問題是什麼? –

+0

我必須通過該窗口的可見性是真實的窗口的div id onclose事件我該如何做到這一點 – iProgrammer

+0

似乎你也使用jQuery呢?我看到一個$(「#Window」)。如果是這樣,爲什麼不一致地使用它?像[你如何測試是否隱藏在jQuery中?](http://stackoverflow.com/questions/178325/how-do-you-test-if-something-is-hidden-in-jquery) – mplungjan

回答

0

喜歡這個?給div一個類

function opendivinwindow(thediv) { 
    $("#"+thediv).css("visibility","visible"); 
    var window = $("#Window").data("tWindow"); 
    window.center().open(); 
} 
function Onclose() { 
    $(".myDivs").each(function() { 
    if ($(this).css("visibility") == "visible") { 
     $(this).css("visibility","hidden"); 
    } 
    } 
}