views:

34

answers:

2

I have been developing a web application on XP and FF (with occasional IE checks through IE 8), but today when I deployed it to a WS 2003 site, running IE 7, my jQuery code to dynamically size divs doesn't execute, and even stating explicit div sizes (e.g. "width: 95%") doesn't seem to work.

I'm doing this via VPN and Remote Desktop, and at this point have no contact with support on the remote site. This is a long shot, but does anyone have any suggestions for me to try? I know Javascript is enabled, as I get a test 'alert' box from outside my jquery code. My jQuery code is as follows, in the head tag:

<script src="/jQuery/jquery-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript">
    function resizeChildren() {
        var h = $(window).height() - 70;
        var w = $(window).width() - 210;
        $("#mainContent").css("width", w);
        $("#container").css("height", h);
        $("#leftMenu").css("height", h - 20);
        $("#mainContent").css("height", h - 20);
        $("#ctl00_mainContentPlaceHolder_grid_GridData").height(h - 80);
    }

    $(document).ready(function() {
        resizeChildren();
    });
    $(window).resize(function() {
        resizeChildren();
    });
</script>

EDIT: I should have included the jQuery link before. I'm sure someone more astute than me would have noticed the leading '/', which caused the browser to look in the site root, not in my application.

A: 

Is your jQuery loaded correctly? Is there a file where your jQuery include points to?

What does this code yield?

alert(typeof $);
David Hedlund
That gives me 'undefined', yet if I copy the href to the jQuery from the page source to the address bar, it tries to run a js file, and a visual inspection reveals the file to be in the correct place.
ProfK
well then at least we know that's the source of the error. now it's just a matter of figuring out why. could you post the include-part of the code? is there a url where we can see the site? otherwise, try running firefox + firebug addon, reload the page (ctrl+f5) while having firebug's "net" tab open, and check out the request for the jquery file. expand that record, and check what the response looks like. (i'm sure in your deployment environment, you have this error with FF as well...?)
David Hedlund
I took a phat liberty and installed FF and FB on their server, and found the URL for jQuery including a leading '/', so both browsers were looking for the script in the root of the site, not my application. Firebug FTW!
ProfK
indeed. consider accepting an answer if everything's working =)
David Hedlund
A: 

Is this not happening when you are resizing the window? You could try adding the the $(window).resize() binding inside the document.ready() function?

$(document).ready(function() {
    resizeChildren();

    $(window).resize(function() {
        resizeChildren();
    });
});
Fermin
`window` should definitely be available before `DOMReady` tho
David Hedlund