How to open two modal dialogs in Twitter Bootstrap at the same time

前端 未结 4 618
被撕碎了的回忆
被撕碎了的回忆 2020-12-29 07:47

I have implemented bootstrap dialog in my project. I have some delete functionality in that dialog, and the delete confirmation message opens another bootstrap dialog. But

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 08:12

    My humble solution: Generate a new ID for each new modal. Then just manage everything through one variable. It's working for my purposes, btw.

    var _MODAL_LAST;
    $( document ).on( 'show.bs.modal' , '.modal' , function(){
        _MODAL_LAST = $(this);
    });
    $( document ).on( 'hide.bs.modal' , '.modal' , function(){
        if( _MODAL_LAST.attr('id') !== $(this).attr('id') ){
            return false;
        }else{
            _MODAL_LAST = $(this).prevAll('.modal:first');
        }
    });
    

提交回复
热议问题