1

I have a button and upon clicking that button I am showing a form in bootstrap model. What I want to achieve is to show confirmation box on form submit. Everything is fine but confirmation is appear at the background of bootstrap model.

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 -->

Here is the javascript for alertyfy.

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>

I have tried following two as recommended in stack overflow and medium.

First

By removing tabindex="-1" from model.

Recommended here: alertify upon a bootstrap modal not working

Second

By placing following css:

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

None of these work in my case. What would be the problem. I am using laravel framework.

Watercayman
  • 7,970
  • 10
  • 31
  • 49
Sagar Gautam
  • 9,049
  • 6
  • 53
  • 84

3 Answers3

1

Finally a following css trick for me and nothing problem with javascript,

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

Main div class for alertyfy pop up was .alertyfy and adding z-index on that div worked for me.

Sagar Gautam
  • 9,049
  • 6
  • 53
  • 84
0

In case of people searching, latest alertify 1.12.0 uses:

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

instead of:

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

This trick works for me. I am using 1.13.1 version alertify.

I can see into HTML

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

So, add Z-index for .alertify-notifier class.

.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>
Jatin Mandanka
  • 411
  • 11
  • 16