1

I write lots of BugMonkey scripts, but FogBugz doesn't include the version of jQuery I'd like to use.

How can I include the latest version of jQuery with my BugMonkey script without changing the version of jQuery that FogBugz itself uses (i.e., without potentially breaking FogBugz)?

flag

1 Answer

1

FogBugz includes a copy of jQuery on every page, but the version of jQuery shipped with FogBugz (which varies between versions of FogBugz) might not be the one you need.

First, you can always check what version of jQuery is bundled with FogBugz by opening your browser's JavaScript console and evaluating: jQuery.fn.jquery

If the version of jQuery included with FogBugz isn't the version you need, you can work around this using the following code:

$.getScript('//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js', function() {
    // do stuff that requires latest jQuery 1.X via jQuery or $

    // alias latest jQuery 1.X as window.jQueryLatest and return
    // jQuery and $ to the version of jQuery included with FogBugz
    window.jQueryLatest = jQuery.noConflict(true);
});

That script will download the latest version of jQuery 1.X from Google's CDN and inject it into the page. You can then use the latest version of jQuery from within the getScript callback function. At the end of the callback, we use jQuery's noConflict() method to return control of jQuery and $ to the version of jQuery that ships with FogBugz.

After this script (and it's callback) have executed, window.jQueryLatest will store a reference to the latest version of jQuery 1.X.

If there is a specific version of jQuery that you'd like to use, check out Google's CDN documentation page.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.