Quantcast
Channel: Base Theme - jQuery
Viewing all articles
Browse latest Browse all 2

Updating jQuery in Drupal the Right Way

$
0
0
I recently made a blog post about how to upgrade Drupal's jQuery version from 1.4.4 to 1.8. The problem is, popular contrib modules (views being the main culprit here) and even some core jQuery require an outdated version of jQuery (be 1.4.4, to be exact.). There is a module called jQuery Update, and it works well, but if you need a self contained theme (with no module dependancies) this might be helpful to you. In the last post, I didn't include details on how to use jQuery in noConflict mode, so I'll explain how it's done. As always, this is included in Base Building Blocks. I decided to add it by default after a number of complaints. (makes sense.)

The Good Stuff

I included a copy of jQuery 1.8 at the top of my html.tpl.php file before I load the Drupal scripts. I was going to use a page process function and use drupal_add_js, but I had trouble adding a weight that was less than the default version of jQuery.
window.jq8 = jQuery.noConflict();
Then you can use the updated version of jQuery like so:
(function ($) {
    //Your Code
}(window.jq8));

What Sucks...

What really sucks is loading two copies of jQuery. If you have any other suggested method of doing this, please let me know! I'm always open to ideas. There is a jQuery update module that handles updating jQuery very well, I would suggest use of that. However when you are building a theme for someone that needs to work without dependancies, this is one way to go about it.

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images