Sunday, November 6, 2011

jQuery UI Modal Dialog disables scrolling in Chrome

Is Chrome becoming the new IE?

As much as I love jQuery, I still cannot escape the fact that jQuery UI leaves a lot to be desired. Yesterday I ran across an issue where the jQuery UI modal dialog acted inconsistently in different browsers. Normally opening a modal leaves the background page functionality unaltered, but in Webkit browsers (I ran into this while using Chrome) it disables the page scroll bars.

The Fix

Yes, this bug has already been reported. Yes, it is priority major. No, it won't be fixed anytime soon. For a feature as widely used as the Modal Dialog, I find that kinda sad.

However, thanks to Jesse Beach, there is a tiny little patch to fix this! Here is a slightly updated version of the fix:

(function($) {
  if ($.ui && $.ui.dialog && $.browser.webkit) {
    $.ui.dialog.overlay.events = $.map(['focus', 'keydown', 'keypress'], function(event) { 
      return event + '.dialog-overlay';
    }).join(' ');
  }
}(jQuery));

Additional Resources

Hope that helps!
Tom

4 comments:

  1. This is great... thanks for the solution....

    ReplyDelete
  2. Perfect, thanks!!! That's what I was looking for!

    ReplyDelete
  3. Serunya main di IDNPLAY beda dari yang lain. Selalu ada momen seru yang bikin betah berlama-lama. Tiap kali buka dewa poker dan domino bet pasti ada aja hal seru yang bikin semangat. Gak heran kalau jadi favorit banyak orang.

    ReplyDelete
  4. Main di poker88 selalu bikin suasana jadi lebih hidup. Apalagi kalau bareng teman, makin rame dan makin seru. IDNPLAY bikin waktu luang terasa lebih menyenangkan. Keseruannya konsisten dan gak bikin bosan.

    ReplyDelete

Real Time Web Analytics