Click here to Skip to main content
12,695,694 members (32,007 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked

Fixing the jQueryUI Dialog Height in IE, the Quirks Way

, 7 Jun 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
How to fix the jQueryUI dialog height in IE, the quirks way

Today, I had some fun trying to figure out how to fix the height of the jQueryUI dialog. The client wanted it to be exactly 500px. Or something that resembled 500px. Anyway, it definitely shouldn't have been from the top to the bottom of the screen. Although I sure set it to 500.

The fun part is that it had to work in IE7-9, but in *quirks* mode. The client won't switch to the standards mode, since the site (made in early 2000s, tables inside tables all the way down) would break apart.

After some debugging, I figured that one line in a certain method would save me. Namely, a fix would require adding a line at the beginning of the "_size" method. So, I could just leave it like that..

Except That I Couldn't.

Doing so wouldn't just violate the Open/Closed principle, it would offend the shadows of the Fathers of SOLIDity and the Alt.Net deities.

After all, JavaScript is a dynamic language, right? So, we can do whatever dirty trick we can think of, including messing with "private" methods.

Extending a jQueryUI Widget by Rewriting a Widget's Private Method? Nothing Could Be Easier!

var proto = $.ui.dialog.prototype;
var _size = proto._size;
proto._size = function(){ 

While I could easily put there something like alert('OHMYGOSH!!!') (and have fun imagining my coworkers trying to figure out what's going on), what I'm actually doing here is just add something to the beginning. So, first I'm saving a reference to the existing function, then I redefine it, adding the line I need and then invoking the function itself.

So, why do I feel like I've just committed a sin?


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Artem Smirnov
Software Developer GeekSoft
Lithuania Lithuania
No Biography provided

You may also be interested in...


Comments and Discussions

General[My vote of 1] Outdated or not functional at all Pin
Member 1035688712-Feb-14 2:10
memberMember 1035688712-Feb-14 2:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170118.1 | Last Updated 7 Jun 2012
Article Copyright 2012 by Artem Smirnov
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid