Bootstrap modal: close current, open new

前端 未结 27 1689
离开以前
离开以前 2020-11-29 00:23

I have looked for a while, but I can\'t find a solution for this. I want the following:

  • Open an URL inside a Bootstrap modal. I have this working off course. S
27条回答
  •  温柔的废话
    2020-11-29 01:13

    I have exact same problem, and my solution is only if modal dialog have [role="dialog"] attribute :

    /*
    * Find and Close current "display:block" dialog,
    * if another data-toggle=modal is clicked
    */
    jQuery(document).on('click','[data-toggle*=modal]',function(){
      jQuery('[role*=dialog]').each(function(){
        switch(jQuery(this).css('display')){
          case('block'):{jQuery('#'+jQuery(this).attr('id')).modal('hide'); break;}
        }
      });
    });
    

提交回复
热议问题