【问题标题】:Alertyfy pop up appearing at background of bootstrap model提示出现在引导模式背景的弹出窗口
【发布时间】:2019-12-24 07:09:06
【问题描述】:

我有一个按钮,单击该按钮后,我将在引导模型中显示一个表单。我想要实现的是在表单提交时显示确认框。一切都很好,但确认出现在引导模型的背景。

HTML

<div class="text-right">
    <button type="button" class="btn btn-primary waves-effect waves-light" data-toggle="modal" data-target=".bs-example-modal-lg">Notify Customer</button>
</div>

<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class  ="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title mt-0" id="myLargeModalLabel">Notification Message</h5>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            </div>
            <div class="modal-body">
                <form class="form-horizontal submit-notify" method="POST" action="{{route('backend.customers.notify', $customer->id)}}">
                    {{csrf_field()}}

                    <div class="form-group">
                        <label for="title" class="col-form-label">Title</label>
                        <div>
                            <input  type="text" name="title" class="form-control" required placeholder="Enter Notification Title"  value="@if(old('title')){{old('title')}}@endif" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="message" class="col-form-label">Message</label>
                        <div>
                            <textarea  type="text" name="message" class="form-control" rows="5" placeholder="Enter Notification Message">@if(old('message')){{old('message')}}@endif</textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>Options</label>
                        <div>
                            <label  class="custom-control custom-checkbox" style="display: inline-block !important;">
                                <input type="checkbox" class="checkbox m-r-10" name="options[]" value="mail" data-parsley-required="true" data-parsley-multiple="groups"
                                       data-parsley-mincheck="1">
                                <span class="custom-control-indicator"></span>
                                <span class="custom-control-indicator">Mail</span>
                            </label>

                            <label class="custom-control custom-checkbox" style="display: inline-block !important;">
                                <input type="checkbox" class="checkbox m-r-10" name="options[]" value="push" data-parsley-multiple="groups"
                                       data-parsley-mincheck="1">
                                <span class="custom-control-indicator"></span>
                                <span class="custom-control-indicator">Push</span>
                            </label>
                            <span id="error-box"></span>
                        </div>
                    </div>

                    <div class="form-group">
                        <div>
                            <button type="submit" class="btn btn-pink waves-effect waves-light confirm-submit">
                                Send
                            </button>
                        </div>
                    </div>

                </form>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

这是 alertyfy 的 javascript。

Javascript

<script type="text/javascript">
        $(document).ready(function () {
            $(".confirm-submit").on('click',function(event){
                event.preventDefault();
                var form = $(this).closest('form');
                var confirm = alertify.confirm("Are you sure you want to submit details ?",function (e) {
                    if(e){
                        form.submit();
                    }
                    else{
                        return false;
                    }
                });
            });
        });
    </script>

我已经按照堆栈溢出和介质中的建议尝试了以下两个。

第一

通过从模型中删除 tabindex="-1"

在这里推荐:alertify upon a bootstrap modal not working

第二

通过放置以下css:

.alertify-logs{
     z-index:999999 !important;
}

在我的情况下,这些都不起作用。会有什么问题。我正在使用 laravel 框架。

【问题讨论】:

  • 嗨@SagarGautam,your code 似乎可以工作,提交前确认确实显示在模式上方
  • @shrys 我刚刚查看了您提供的链接,但在我的本地环境中它不起作用。可能是其他javascript对此负责吗?
  • 你可能想试试.alertify.alertify-confirm {z-index:999999 !important;}而不是上面的css
  • @shrys 让我试试
  • @shrys 还是不行

标签: javascript php css laravel


【解决方案1】:

最后对我来说是以下 css 技巧,javascript 没有问题,

.alertify{
    z-index:999999 !important;
    margin-top: -50px;
}

alertyfy 弹出的主 div 类是 .alertyfy,在该 div 上添加 z-index 对我有用。

【讨论】:

    【解决方案2】:

    如果有人搜索,最新的 alertify 1.12.0 使用:

    .alertify-notifier { z-index:999999 !important; }
    

    代替:

    .alertify { z-index:999999 !important; }
    

    【讨论】:

      【解决方案3】:

      这个技巧对我有用。我使用的是 1.13.1 版本的 alertify。

      我可以看到 HTML

      <div class="alertify-notifier ajs-bottom ajs-right"></div>
      

      所以,为.alertify-notifier 类添加 Z-index。

      .alertify-notifier { z-index:999999 !important; }
      

      CSS:

      <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/alertify.min.css"/>
      <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/default.min.css"/>
      

      JS:

      <script src="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/alertify.min.js"></script>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-02-16
        • 1970-01-01
        • 2014-12-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-16
        • 2015-08-08
        相关资源
        最近更新 更多