Friday, March 2, 2012

Bug when combining Twitter Bootstrap Modal and Modernizr using Opera 11.61

I suffer from a bug when using Twitter Bootstrap (TB) Modal and using Modernizr.mq (media queries) functionality, in my case is the animation is not firing using Opera 11.61. The code that I write is:
$(document).ready(function () {
  // firing up notice (modal) after loading
  $('#announcementModal').modal('show');
  
  // I have other purpose on this and just try to do 
  //  console logging to see if that work or not
  if (Modernizr.mq('(min-width: 980px)')) {
    console.log('screwed');
  }  
});
and BAM! The modal animation isn't firing at all. After googling and searching for the bug's solution and found out none, I have a thought on doing this: switching the code like this
$(document).ready(function () {
  // I have other purpose on this and just try to do 
  //  console logging to see if that work or not
  if (Modernizr.mq('(min-width: 980px)')) {
    console.log('screwed');
  }

  // firing up notice (modal) after loading
  $('#announcementModal').modal('show');    
});
And the result? Everything just worked! Can't believe this. I think there's a mechanism in Modernizr to stop all things to make detection more precise and (maybe) they forget to return all the things that they stop. Just my $0.02 though, I kind of busy to deep down the code yet. :(