javascript on events in mvc
I have a telerik window with multiple divs inside it whose visibility is set according to javascript function. Now I want to call a javascript function so that any visible div in that window is hidden onclose event of telerik window i.e. I have to pass the id of a div with visibility=visible in the window onclose event at runtime.
How do I do that?
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";
}
View
<% 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 开发者_Python百科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();
%>
<% }%>
Like this? Give the divs a class
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");
}
}
}
精彩评论