javascript - bootstrap modal trigger event in incorrect order when jquery mobile CSS is included -


i ran case backdrop being display , modal displayed after backdrop removed. first time ever ran issue after couple years of using bootstrap , i'm not able figure out why. when debugging, callback never triggered on first pass. it's triggered after click on backdrop.

anyone else ran issue before? css conflict potentially? removing jquery-mobile-1.4.2.css seems help, kinda need both of them work together. version of bootstrap i'm using 2.3.2.

this.backdrop(function() {     var transition = $.support.transition && that.$element.hasclass('fade')      if (!that.$element.parent().length) {         that.$element.appendto(document.body) //don't move modals dom position     }      that.$element.show()      if (transition) {         that.$element[0].offsetwidth // force reflow     }      that.$element.addclass('in').attr('aria-hidden', false)      that.enforcefocus()      transition ?          that.$element.one($.support.transition.end, function() {             that.$element.focus().trigger('shown')         }) :          that.$element.focus().trigger('shown')     }) } 

jquery mobile , twitter bootstrap use class "fade" , "in" causing conflict. here how got around it.

  1. create override style sheet following classes (these copied bootstrap.css file , modified reference "fade" or "in" becomes "bootstrap-fade" , "bootstrap-in" respectively:

    .modal-backdrop.bootstrap-fade {   opacity: 0; }  .modal-backdrop, .modal-backdrop.bootstrap-fade.bootstrap-in {   opacity: 0.8;   filter: alpha(opacity=80); }  .modal.bootstrap-fade {   -webkit-transition: opacity .3s linear, top .3s ease-out;   -moz-transition: opacity .3s linear, top .3s ease-out;   -o-transition: opacity .3s linear, top .3s ease-out;   transition: opacity .3s linear, top .3s ease-out;   top: -25%; }  .modal.bootstrap-fade.bootstrap-in {   top: 10%; }  .bootstrap-fade {   opacity: 0;   -webkit-transition: opacity 0.15s linear;   -moz-transition: opacity 0.15s linear;   -o-transition: opacity 0.15s linear;   transition: opacity 0.15s linear; }  .bootstrap-fade.bootstrap-in {   opacity: 1; }  @media (max-width: 767px) {     .modal.bootstrap-fade {         top: -100px;     }     .modal.bootstrap-fade.bootstrap-in {         top: 20px;     } } 
  2. next need edit bootstrap.js file. can either copy entire modal section, (line 61 - 310), or can edit directly in file find , replace. replace references "fade" , "in" new classes "bootstrap-fade" , "bootstrap-in". there 5 instances of "fade" , 4 instances of "in" in modal section of js file.

  3. once have done that, create modal , use class "bootstrap-fade" instead of "fade".

    <div id="mymodal" class="modal hide bootstrap-fade" tabindex="-1" role="dialog" aria-labelledby=mymodallabel" aria-hidden="true">     <div class="modal-header">         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>         <h2 id="assignmodallabel">modal</h2>     </div>     <div class="modal-body">     </div>     <div class="modal-footer">     </div> </div> 

hope helps!


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -