Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
8
rated 0 times [  13] [ 5]  / answers: 1 / hits: 61046  / 12 Years ago, fri, august 17, 2012, 12:00:00

I have a menu with multiple modals. When I open one over another it turns backgrount into black, which is ugly.
I understand that I need change filter: alpha(opacity=80); in .modal-backdrop.fade.in in bootstrap.css. But I need to change it not for all modals, only for some of them. Here's the html code for first modal



    <div class=modal hide id=mbusModal>
<div class=modal-header>
<button type=button class=close data-dismiss=modal>×</button>
<h3>MBUS</h3>
</div>
<div class=modal-body>
<form class=form-horizontal>
<form class=well form-inline>
<input type=button class=btn onclick=$('#dinMbusModal').modal('show'); $('#tabsMbusDin a:last').tab('show'); value=din>
</form>
</div>
<div class=modal-footer>
<a href=# class=btn data-dismiss=modal>Закрыть</a>
<a href=# class=btn btn-primary onclick=addPort('mbus',$('#mbusDev').val(),$('#mbusSpeed').val()); $('#mbusModal').modal('hide')>Применить</a>
</div>


This modal needs to change his backdrop:



    <div class=modal hide id=dinMbusModal style=width: 500px; margin: -250px 0 0 -250px;>
<div class=modal-header>
<button type=button class=close data-dismiss=modal>×</button>
<h3>DIN</h3>
</div>
<div class=modal-body>
</div>
<div class=modal-footer>
<a href=# class=btn data-dismiss=modal>Закрыть</a>
<a href=# class=btn btn-primary onclick=addPort('din_mbus',,); $('#dinMbusModal').modal('hide')>Применить</a>
</div>
</div>

More From » jquery

 Answers
11

Little bit complicated by the fact that the backdrop is generated by the Modal plugin on the fly. One possible way of doing it is adding a class to the body when you get a show event, then remove it on the hidden.



Something like:



CSS



.modal-color-red .modal-backdrop {
background-color: #f00;
}
.modal-color-green .modal-backdrop {
background-color: #0f0;
}
.modal-color-blue .modal-backdrop {
background-color: #00f;
}


JS



$('.modal[data-color]').on('show hidden', function () {
$('body').toggleClass('modal-color-'+ $(this).data('color'));
});


HTML



<div class=modal hide fade id=redModal data-color=red>...</div>
<div class=modal hide fade id=greenModal data-color=green>...</div>
<div class=modal hide fade id=blueModal data-color=blue>...</div>


JSFiddle


[#83587] Wednesday, August 15, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alejandro

Total Points: 231
Total Questions: 102
Total Answers: 107

Location: Jordan
Member since Wed, Jun 17, 2020
4 Years ago
alejandro questions
Mon, Jul 18, 22, 00:00, 2 Years ago
Fri, Sep 18, 20, 00:00, 4 Years ago
Thu, Sep 10, 20, 00:00, 4 Years ago
;