I try to load Foundation in my new "player" theme. It is a theme I make from scratch. For now I am trying to load foundation.min.js in a preprocess :
function player_preprocess_page(&$variables, $hook) {
$options = array('scope' => 'footer', 'weight' => 1000 );
drupal_add_js(drupal_get_path('theme', 'player') . '/js/foundation.min.js', $options);
$foundation='jQuery(document).foundation();';
$options['type']='inline';
drupal_add_js($foundation, $options);
}
When I load my site, I have two Uncaught ReferenceError: jQuery is not defined errors (once for the foundation.min.js, once for jQuery(document).foundation(); )
First I thought that is because jQuery is loaded after jQuery(document).foundation(); but it seems default files, including jQuery, are loaded in the header (I did a var_dump to check.) And my script are laoded in the footer
'misc/drupal.js'
'misc/jquery.js'
'misc/jquery.once.js'
'sites/all/themes/player/js/theme.js'
'sites/all/themes/player/js/uikit.js'
'misc/jquery.cookie.js'
'misc/jquery.form.js'
'misc/progress.js'
'misc/ajax.js'
'misc/ui/jquery.ui.core.min.js'
'misc/ui/jquery.ui.widget.min.js'
'misc/ui/jquery.ui.mouse.min.js'
'misc/ui/jquery.ui.draggable.min.js'
'misc/ui/jquery.ui.resizable.min.js'
'sites/all/modules/devel_themer/devel_themer.js'
'sites/all/modules/devel/devel_krumo_path.js'
'sites/all/modules/devel/krumo/krumo.js'
'misc/jquery.ba-bbq.js'
'modules/overlay/overlay-parent.js'
'modules/toolbar/toolbar.js'
So I don't understand. It surely a common case but I don't find any help resource on the net.
Aucun commentaire:
Enregistrer un commentaire