简体   繁体   English

如何从另一个视图中的另一个页面捕获按钮单击事件并在源页面中进行DOM操作?

[英]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.

相关问题 如何使按钮单击其他页面上的按钮 - How to make a button click a button on a different page 如何为不同的页面制作按钮? - How to make button for a different page? 如何在 React Native 中单击不同页面上的按钮? - How to click a button on a different page in React Native? 在页面加载之前捕获点击事件,并在DOM准备就绪后触发 - Capture click event before page load and trigger after DOM ready 如何为iFrame按钮单击调用window onunload事件,父页面和iFrame位于不同的域中 - how to call window onunload event for iFrame button click where parent page and iFrame resides in different domain 如何使用 JQuery 从另一个页面上的文本字段值单击按钮时填充不同页面的文本字段? - How to populate a text field of a different page on button click from a text field value on another page using JQuery? 如何从同一页面的不同部分单击基于按钮的同一页面中的动态组件? - How to render dynamic component in the same page based button click from different section of same page? 从event.Click,event.Resize和eventDrop返回时,NaN会在移动到其他视图或日历页面时随处出现 - Returning from event.Click, event.Resize and eventDrop causes NaN appearing everywhere when moving to a different view or calendar page 按钮点击事件后PhantomJS捕获下一页内容 - PhantomJS to capture next page content after button click event 重定向到浏览器刷新按钮上的其他页面,请单击 - Redirect to different page on Browser Refresh Button Click
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM