[英]How to capture a button click event from a different page in a different View and make DOM manipulation in the source page?
I have the following html construct in the source Page View: 我在源页面视图中具有以下html构造:
<i id="asterisk" class="fa fa-asterisk show asterisk" ></i>
<a id="tos" data-toggle="modal" data-target="#divTermsAndConditions" href="@Url.Action("TermsOfServiceFromRegistration", "Account", new { lk = ViewBag.LicenseKey })" target="_blank">
<div>
<div class="modal fade" id="divTAndC" role="dialog" data-backdrop="static" data-keyboard="false" aria-describedby="termsandconditions" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
@if (ViewData.ModelState.IsValid && fetchTOSAction) {
{ Html.RenderAction("TermsOfServiceFromRegistration", "Account", new { lk = ViewBag.LicenseKey }); }
}
</div>
</div>
</div>
</div>
And the new View which it opens, has a button: 打开的新视图具有一个按钮:
<button class="btn btn-primary" id="btnClose" data-dismiss="modal">Close</button>
As you can see, it is a bootstrap button and on clicking of it, it closes the current window:"TermsofService.cshtml". 如您所见,这是一个引导程序按钮,单击它会关闭当前窗口:“ TermsofService.cshtml”。 Now, my requirement is like this: 1.Capture this button click event 2.And on that event make some DOM manipulation in the source View, like : 现在,我的要求是这样的:1.捕获此按钮的单击事件2.然后对该事件在源视图中进行一些DOM操作,例如:
$("#asterisk").removeClass("show").addClass("hide");
Is it possible? 可能吗? Any help will be highly appretiated. 任何帮助将不胜感激。 Thanks in advance. 提前致谢。
Solved it myself!Bingo! 自己解决!宾果! Here it is: 这里是:
$("#divTAndC").on("hidden.bs.modal", function () {
$("#check").removeClass("hide").addClass("show");
});
Basically, in the source view itself,bind the function on modal close. 基本上,在源视图本身中,将函数绑定到模式关闭。 Thats it! 而已!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.