在关闭Bootstrap Alert之前点击以下链接 [英] Following link before closing Bootstrap Alert

查看:83
本文介绍了在关闭Bootstrap Alert之前点击以下链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试关闭警报,之后,我单击了警报中的链接,然后单击该链接.发生的情况是警报正在关闭,而没有点击链接:

I am trying to close an alert after I click the link in it and we follow the link. What is happening is the alert is closing without following the link:

<div role="alert" class="alert alert-warning alert-dismissible">
    <button aria-label="Close" data-dismiss="alert" class="close" type="button"><span aria-hidden="true">×</span></button>
    A response has been updated. <a data-dismiss="alert" href="#main">Click here to view the update.</a>
</div>

我正在寻找一种解决方案,如果可能的话,该解决方案不需要大量的关联Javascript事件.

I'm looking for a solution that doesn't require a lot of wired-up Javascript events if possible.

推荐答案

您应该可以加入bootstrap事件,它并不那么复杂.来自文档:引导警报.它将需要一个ID或相应的警报选择器.

You should be able to hook into the bootstrap event and it isn't that complicated. From documentation: bootstrap alerts. It will require an id or appropriate selector for the alert.

html

<div role="alert" class="alert alert-warning alert-dismissible" id="myAlert">
    <button aria-label="Close" data-dismiss="alert" class="close" type="button">
    <span aria-hidden="true">×</span></button>
    A response has been updated. <a data-dismiss="alert" href="#main">Click here to view the update.</a>
</div>

js

<script>
    $('#myAlert').on('closed.bs.alert', function () {
        window.location.href = "http://www.google.com";
    })
</script>

这篇关于在关闭Bootstrap Alert之前点击以下链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆