0

I have a modal link inside a modal. The idea is to close that modal when it's fired and open another modal. The problem is, the modal-open class gets dropped when doing this which then causes scrolling issues inside the modal. Is there any way around this?

The link inside the Modal 1 is

<a href="javascript:;" class="edit_item" data-row="1">Open Modal 2</a>

And the code:

$( document ).on( "click", ".edit_item", function() {

        var id=$(this).attr("rel");
        var row=$(this).data("row");
        var params="action=viewItem&item_id="+id+"&tbl=viewRow&row="+row;

        $('.modal').modal('hide');

        // Needed to wipe the content due to the different IDs ..
        $('body').on('hidden.bs.modal', '.modal', function () {
        $(this).find('.modal-body').empty();
        });         

        // Opening Modal 2 here ..
        open_box_edit(params,row);
});

And the modal firing:

function open_box_edit(params,row_id)
  {                 
      var URL=ajax_url+"/?"+params;
      console.log(params);
      console.log(row_id);


        var modal = $('#modal_edit');
        modal
            .find('.modal-body')
            .load(URL, function (responseText, textStatus) {
                if ( textStatus === 'success' || 
                     textStatus === 'notmodified') 
                {
                    modal.modal("show");
                }
        });  


}

How can I make sure that modal-open stays even after firing $('.modal').modal('hide');?

user1996496
  • 972
  • 2
  • 10
  • 24

0 Answers0