11

Is anybody successfully running jQuery 1.7? I'm using a jQuery component on my pages which requires jQuery 1.7 or later. This version causes some unwanted side effects in the admin UI, such as checked checkboxes that don't reveal additional controls when available, or field widget not being active.

I was wondering if there's a solution that could let me easily work with jQuery 1.7.

I saw this answer before asking. As far as I understand, there are 2 separate issues: updating src of the jQuery to 1.7.x, and updating the javascript used by admin. I tried to use the latest jquery_update development snapshot, and apply a patch, but it does not solve the above-mentioned problems with UI.

  • The policy pretty much dictates that upgrading Drupal versions shouldn't break anything that relies on jQuery, so the version stays consistent. – mpdonadio May 4 '12 at 16:54
  • Technically this issue is a dupe of drupal.stackexchange.com/a/41394/809 Also I'm a bit bias but the other question has a better answer. – ericduran Aug 31 '12 at 22:16
11

I would look at Clive's advice on doing it manually here:

How do I update jQuery to the latest version I can download?

and add some more intelligence into the script to not do it on admin pages, eg:

if (arg(0)=='admin') {
  return;
}

You would also have to do that on node/#/add and node/#/edit pages etc so as to not disrupt anything "core" there, or, if you want, dive into drupal core and bring everything else up to 1.7 as well.

Depending on what version of Drupal you are running, this might also work:

function YOURTHEME_preprocess_page(&$vars) {
  if (YOUR CONDITION HERE) {
    $scripts = drupal_add_js('PATH TO YOUR JQUERY FILE');
    unset($scripts['core']['PATH TO DRUPAL JQUERY FILE']);
    $variables['scripts'] = drupal_get_js('header', $scripts);
  }
}

where you could set "YOUR CONDITION HERE" to be whatever pages you want the new jquery on, eg, arg(0)!='admin' etc.

  • Thanks Jimajamma, I did not use your code, but your answer put me on the right track. I found a nice patch that adds UI to the jquery_update config screen, that allows you to use different versions of jQuery for admin. drupal.org/node/1524944. Working good so far. – Artur May 4 '12 at 16:48
  • 2
    Keep in mind that ctools has had a history of breaking, too, with jquery updates. You may need to adjust the patch to account for this. – mpdonadio May 4 '12 at 16:55
  • Thanks for pointing this out. Do you have an idea what would be the best way to test against that? – Artur May 4 '12 at 17:05
  • 3
    +1 A nice simple way to get a list of all admin pages that don't have 'admin' in the url is: $pages = module_invoke_all('admin_paths'); – Clive May 4 '12 at 17:20
  • 1
    @Clive, does this catch ctools AJAX URLs? Like when you use a ctools widget on a "normal" page? – mpdonadio May 4 '12 at 17:35
2

jQuery Update now has the ability to enable different jQuery versions for the front-end and the back-end. Download the latest dev version and you're good to go: 1.5 in the backend, so it works with the Views UI, and 1.7 or 1.8 in the frontend, for extra jQuery goodness.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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