Updating jQuery in Drupal the Right Way
Submitted by Patrick Coffey on Fri, 08/17/2012 - 21:55
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));
Comments
http://drupal.org/project
http://drupal.org/project/jqmulti was build for this exact use case. I didn't make it, but I use it
Keepin' it in the theme layer
That module does the job, but I like to keep the theming stuff in the theming layer. :)
The problem
The problem with your way is that you have to modify each bootstrap which is bad because Bootstrap is Apache licensed and Drupal's repository is GPLv2 which are not compatible with each other.
Hmmmm..
The license is a bit irrelevant in the case of updating jQuery, as the Apache License allows the user of the software the freedom to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software. :) But there are problems putting that code up on drupal.org, which explains why BBB is in a git repo and not on drupal.org. :)
Yes as long it's not on
Yes as long it's not on Drupal.org but but afaics you do have it on d.o, http://drupal.org/node/1713614. No worries, I don't care, but the folks on d.o do. Personally I think it should be open to all kind off open source licenses, but thats not the case. And the positive thing about this, it's indirectly forces modules/themes to use Libraries API to include 3rd party libraries like Bootstrap which is good.
So if you could have implemented Bootstrap with Libraries API (http://drupal.org/project/libraries) that would have been awesome.
I have considered it
Yeah, I submitted it to d.o just to see what happened. I've considered adding Bootstrap as a library and making a branch of my theme for d.o that uses the bs library for drupal, but it's kind of bad design if you think about it... Drupal's themes need to be self contained. And how would you use the variables and mixins that Bootstrap has? I've been meaning to build a branch of BBB that uses the Bootstrap library, but I'm running short on time these days. If you would prefer it, feel free to fork, code, and contribute! I'll merge your stuff in gladly. :)
the hell, how is this "the
the hell, how is this "the right way"? ...
What way do you suggest?
I'm quite open to suggestions and critique, but please explain yourself.
coast dresses uk
coast maxi dresses are really popular trend in the fashion world that would never be outdated. From the lovely stunning short Blues NIKITA RUCHED Coast Shift Dresses to the exquisitely designed graceful long Coast Beiges Browns HORTENESE Embellished Dresses, all are designed with the aim that they would be perfect for any occasions you are wearing for.It would be a really exciting experience to choosing coast black dresses from our online store at anytime that is convenient for you.
http://www.coastdressesukonsales.com/
Add new comment