简体   繁体   中英

How i can add a close button and resize the jQuery modal

I have the following jQuery modal code:-

<script>
        $(document).ready(function () {
            
            $(function () {
                $.ajaxSetup({ cache: false });
                //$("a[data-modal]").on("click", function (e) {
                $(document).on('click', 'a[data-modal]', function (e) {
                    $('#myModalContent').css({ "max-height": screen.height * .82, "overflow-y": "auto" }).load(this.href, function () {
                        $('#myModal').modal({
                            height: 1000,
                            width: 2200,
                            resizable: true,
                            keyboard: true,
                            backdrop: 'static',
                            draggable: true
                        }, 'show');
                       });
                    return false;
                });


            });

            $(function () {

                $(document).on('click', 'a[data-dismiss]', function (e) {

                    if ($(this).attr('data-reload') == 'no') {
                        $(this).parents('.modal').first().modal('hide');

                    }
                });


            });
            });
    </script>

and the following HTML to show the modal:-

 <div id='myModal' class='modal fade in'>
          <div class="modal-dialog">
               <div class="modal-content">
                    <div id='myModalContent'></div>
               </div>
          </div>
 </div>

 <a data-modal='' href="/home/bookappointment" title="Detail"> Book Appointment </a>

but currently the modal will only occupy a very small part of the screen + i can not close the modal popup. so can anyone advice how i can expand the modal height and width + add a close button to it?

You can use data-dismiss="modal" like this.

<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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