简体   繁体   English

显示警报后布尔模态保持关闭

[英]Bulma modal keeping closing after showing alert

Currently my modal and alert works fine. 目前,我的模态和警报工作正常。

This is my modal right now. 这是我现在的模态。

在此处输入图片说明

and it works fine 而且效果很好

currently if you click the continue button 当前,如果您单击continue按钮

it will show an alert like this 它会显示这样的警报

在此处输入图片说明

But when you click the ok button of this alert the modal keeps closing after that 但是,当您单击此警报的“ ok按钮时,此后模态将继续​​关闭

I'm trying to keep it showing even if the user clicks the ok button of the alert 即使用户单击警报的“ ok按钮,我也试图使其保持显示状态

here's my modal code 这是我的模态代码

 <a class="modal-button button is-info" data-target="myModal">
 <em>Click here to manage balance..</em>
 </a>




 <div class="modal animated fadeIn" id="myModal">
    <div class="modal-background"></div>
        <div class="modal-card">
            <header class="modal-card-head">
            <p class="modal-card-title"><span class="file-icon is-inline"><i class="fas fa-credit-card"></i></span>....content</p> 
                <button class="delete" aria-label="close"></button>
            </header>
            <section class="modal-card-body">
            .......content
            </section>
        <footer class="modal-card-foot">
            <button class="button is-info has-text-weight-bold" id="proceedBal">Continue</button>
            <button class="button">Cancel</button>
        </footer>
        </div>
    </div>

Here's my JS code 这是我的JS代码

$('#proceedBal').click(function(){ 
    alert("Hello World!");

});

It's quite hard to troubleshoot without full code, my guess is the button is submitting the form, which is the default behavior of button tag. 没有完整的代码很难进行故障排除,我猜是按钮正在提交表单,这是button标记的默认行为。

Try either: 尝试以下任一方法:

A. set button type to button A.将按钮类型设置为按钮

<button type="button" class="button is-info has-text-weight-bold" id="proceedBal">Continue</button>

OR 要么

B. prevent the default behavior B.防止默认行为

$('#proceedBal').click(function(e){
    e.preventDefault();
    alert("Hello World!");
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM