我正在使用magnific JS (http://dimsemenov.com/plugins/magnific-popup/)为我的Drupal站点上的youtube视频生成一个弹出式窗口。实现工作正常,但前提是我登录到了Drupal。如果我没有登录,弹出链接将直接进入youtube页面(例如jQuery未初始化)。
我怀疑当我登录时,Drupal加载一个不同版本的jQuery时可能发生了一些事情。似乎我可以在我的模板文件中添加一些东西来修复这个问题。还没有弄清楚(https://www.drupal.org/node/2165555)
我没有权限添加jQuery更新模块。
发布于 2015-08-13 14:15:40
已修复。将以下代码片段添加到template.php中,以强制加载更高版本的jQuery。
function theme_name_js_alter(&$javascript) {
$node_admin_paths = array(
'node/*/edit',
'node/add',
'node/add/*',
'node/*/extend_review_date',
);
$replace_jquery = TRUE;
if (path_is_admin(current_path())) {
$replace_jquery = FALSE;
} else {
foreach ($node_admin_paths as $node_admin_path) {
if (drupal_match_path(current_path(), $node_admin_path)) {
$replace_jquery = FALSE;
}
}
}
// Swap out jQuery to use an updated version of the library.
if ($replace_jquery) {
$javascript['misc/jquery.js']['data'] = '//code.jquery.com/jquery-1.7.0.min.js';
}
}https://stackoverflow.com/questions/31963514
复制相似问题