I have a custom module that uses the jCarousel jquery plugin (not the Drupal module). The module code up to this point works correctly, and looks like this (only the main function included for brevity.)
function speaker_carousel_block_view($delta = '') {
switch($delta){
case 'speaker_carousel':
drupal_add_js('sites/all/libraries/jcarousel/lib/jquery.jcarousel.min.js');
drupal_add_css('sites/all/libraries/jcarousel/skins/speakers/jcarousel-speakers.css');
drupal_add_js(
'jQuery.noConflict();
(function($) {
$(document).ready(function() {
jQuery("#mycarousel").jcarousel({wrap: "circular"});
});
})(jQuery);',
'inline'
);
$block_content = "";
//Use our custom function to retrieve data.
$result = speaker_carousel_get_data();
//parse into html
$block_content .= '<ul id="mycarousel" class="jcarousel-skin-speakers">';
$block_content .= speaker_carousel_create_html($result);
$block_content .= '</ul>';
$block['content'] = $block_content;
}
return $block;
}
I'm now trying to incorporate a second plugin ([jquery tools tooltip])2 to handle a mouseover popup of some text. This is what the function looks like after additions:
function speaker_carousel_block_view($delta = '') {
switch($delta){
case 'speaker_carousel':
drupal_add_js('sites/all/libraries/jcarousel/lib/jquery.jcarousel.min.js');
drupal_add_css('sites/all/libraries/jcarousel/skins/speakers/jcarousel-speakers.css');
drupal_add_js('http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js', 'external');
drupal_add_js(
'jQuery.noConflict();
(function($) {
$(document).ready(function() {
jQuery("#mycarousel").jcarousel({wrap: "circular"});
jQuery("#mycarousel img").tooltip();
});
})(jQuery);',
'inline'
);
$block_content = "";
//Use our custom function to retrieve data.
$result = speaker_carousel_get_data();
//parse into html
$block_content .= '<ul id="mycarousel" class="jcarousel-skin-speakers">';
$block_content .= speaker_carousel_create_html($result);
$block_content .= '</ul>';
$block['content'] = $block_content;
}
return $block;
}
As soon as I add the second drupal_add_js()
call in (to the cdn.jquerytools.org site), everything blows up. The carousel no longer displays correctly; it just shows a single item instead of the horizontally scrolling strip of images that was there before. Any idea how I can get the two to play nicely together?
I found the JQuery Multi module, which I really thought would help. I installed and configured, and now the carousel no longer blows up, but I get an error in Firebug console:
jQuery("#mycarousel a.speaker_trigger").tooltip is not a function
jQuery("#mycarousel a.speaker_trigger").tooltip();
I know it's not an issue with the two plugins working together, because I copied the rendered source into a static HTML file and put it here. It works fine, but it's only using a single version of jquery.
Do you have any idea?