0

With jquery update module I can use newer JQUERY version in my pages and also in admin pages I use another version, 1.9 for pages and 1.5 for admin pages,my question is DRUPAL know user edit page ( user/uid/edit) as admin page, how can I use updated version of JQUERY in user edit page?

I did something like

function mymodule_js_alter(&$js) {
  //$javascript['misc/jquery.js']['data'] = drupal_get_path('module', 'jquery_update') . '/jquery.js';

  if(preg_match('/user\/\d*\/edit/', current_path())){
    //ym($js);
    //there is exist 1.9.1 jquery file
     $path = libraries_get_path('jquery').'/jquery-1.9.1.min.js';
  // Copy the current jQuery file settings and change
  $js[$path] = $js['misc/jquery.js'];

  // Update necessary settings
  $js[$path]['version'] = 1.9;
  $js[$path]['data'] = $path;
  // Finally remove the original jQuery
  unset($js['misc/jquery.js']);
  }
}

also

function mymodule_js_alter(&$js) {


  if(preg_match('/user\/\d*\/edit/', current_path())){
     $path = libraries_get_path('jquery').'/jquery-1.9.1.min.js';
  // Copy the current jQuery file settings and change
  $js['sites/all/modules/jquery_update/replace/jquery/1.5/jquery.min.js'] = $path;
  }
}

but not worked

0

I found a solution: First check the path, and then replace the JavaScript file.

function mymodule_js_alter(&$js) {
  if (preg_match('/user\/\d*\/edit/', current_path())) {
    $js['sites/all/modules/jquery_update/replace/jquery/1.5/jquery.min.js']['data'] = 'sites/all/modules/jquery_update/replace/jquery/1.7/jquery.min.js';
  }
}

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.