2011-11-30 6 views
3

나는 모듈이 있고 그 안에 내가드루팔 7 add_js 무게

if($_GET['q'] == 'workpage') { 
drupal_add_js(drupal_get_path('module', 'sb_carousel').'/js/slide.js'); 
} 

문제는 .INFO 파일에 정의되어 jqueru 위에 추가합니다입니다 함께 JS를 추가합니다. 나는 'js'파일의 맨 아래에 js를 어떻게 얻을 수 있습니까? weight를 사용

$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); 

scope 당신은 당신의 JS 파일을 HTML로 출력 맨 마지막 있는지 확인 할 수 있어야한다 :

답변

5

당신은 drupal_add_js() 내로 $options 배열을 전달하여 무게를 설정할 수 있습니다.

UPDATE

그냥 생각, 당신은 jQuery를 이미 기본적으로 드루팔에 추가, 그렇게 할 필요가 없습니다 ... 당신의 jQuery 파일이 .info 파일에로드 언급. jQuery Update module으로 jQuery 1.5로 업그레이드 할 수 있지만 현재 최신 버전에는 공식 지원이 없습니다.

두 번째 jQuery 파일을로드하는 경우 jQuery.noConflict()을 제대로 사용하지 않으면 문제가있을 수 있지만 그다지 문제가되지 않을 수 있습니다.