Jquery drupal 7增加重量
我有一个模块,在其中我添加了带有Jquery drupal 7增加重量,jquery,drupal,drupal-7,Jquery,Drupal,Drupal 7,我有一个模块,在其中我添加了带有 if($_GET['q'] == 'workpage') { drupal_add_js(drupal_get_path('module', 'sb_carousel').'/js/slide.js'); } 问题是它将它添加到.info文件中定义的jqueru之上。我看到有一个“权重”属性,如何在js文件的底部获取js???您可以通过将$options数组传递到以下位置来设置权重: 使用weight和scope应该能够确保JS文件是HTML中最后输出的文件
if($_GET['q'] == 'workpage') {
drupal_add_js(drupal_get_path('module', 'sb_carousel').'/js/slide.js');
}
问题是它将它添加到.info文件中定义的jqueru之上。我看到有一个“权重”属性,如何在js文件的底部获取js???您可以通过将
$options
数组传递到以下位置来设置权重:
使用weight
和scope
应该能够确保JS文件是HTML中最后输出的文件
更新
只是想一想,您提到jQuery文件是从.info
文件加载的……没有必要这样做,默认情况下jQuery已经添加到Drupal中了。您可以使用升级到jQuery1.5,但目前没有任何更高版本的(官方)支持
如果您正在加载第二个jQuery文件,那么首先可能是导致问题的原因,除非您正确使用,否则即使这样,您也可能仍然存在问题
$file = drupal_get_path('module', 'sb_carousel').'/js/slide.js';
$options = array(
'weight' => 1000, // High number to push this file to the bottom of the list
'scope' => 'footer' // This will output the JS file in the footer scope, so at the end of the document
);
drupal_add_js($file, $options);