I'm using 7.x 2.0-alpha 2
When I attempt to pass a function though initCallback i get the javascript error
this.options.initCallback is not a function
[Break On This Error] (function(i){var q={vertical:false,rtl...rousel", new h(this,a))})}})(jQuery);
I believe this isn't just a user error...here is the method I'm using to call jcarousel:
<?php
$options = array(
'scroll' => 3,
'animation' => '8000',
'wrap' => 'circular',
'auto' => 10,
'initCallback' => 'carousel_init_callback'
);
jcarousel_add('work-carousel', $options);
?>Any idea if this is my method or a bug with jCarousel?
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | jcarousel_callbacks_convert.patch | 1.08 KB | quicksketch |
| #6 | jcarousel_patch.patch | 1.47 KB | taran2l |
| #5 | jcarousel_patch.patch | 1.61 KB | taran2l |
| #3 | jcarousel_callbacks_convert.patch | 915 bytes | quicksketch |
| #2 | jcarousel_1009142.patch | 598 bytes | hadsie |
Comments
Comment #1
hadsie commentedI'm having the same issue. What's the right way to use the initCallback parameter here?
Comment #2
hadsie commentedHere's a patch that did the trick for me. It just re-assigns the value of initCallback to a function as opposed to a string.
Comment #3
quicksketchThanks hadsie! This is a definite improvement but I think we should make this work for all callback functions, rather than just initCallback (see all the callbacks at http://sorgalla.com/projects/jcarousel/#Configuration). Could you try out this patch and see if it does the same job?
Comment #4
hadsie commentedGood point :). Testing out your updated patch now and it works perfectly for me so far.
Comment #5
taran2lHey guys,
Attached patch will not work with a namespaced function, like Drupal.object.initCallback();
I've attached a bit updated version to fix this issue.
Please review.
Comment #6
taran2lSorry previous patch can't be applied, attached updated patch.
Also, this issue exists in 6-x.2.2 branch too.
Comment #7
quicksketchTaran2I: Thanks, good point but the new patch now needs some work. We shouldn't claim such a broad namespace as "convertFunctionNameToFunction". Considering it's unnecessary to even have a function at all, I'd be happy just seeing this embeded directly in the currently location.
Comment #8
quicksketch@Taran2l: Could you try out this version?
Comment #9
quicksketchI've committed the above patch after testing that it works with callbacks like "carousel_init_callback" as well as "Drupal.mymodule.carouselCallback".
Comment #10
taran2l@quicksketch: thanks for committing this patch.
Comment #11
echoz commentedUsing 6.x-2.3, for which this patch has been also committed, but I didn't think I should change the version on this issue.
The code added in the #8 patch gives me the following error for jcarousel.js:
"TypeError: Result of expression 'options[optionKey].split' [undefined] is not a function."
while using another module on the page, when it uses thickbox. This only occurs when I have AJAX set to yes in my carousel view. I am not using jcarousel_add().
Commenting out the code added in this patch makes the error go away, and allows the thickbox implementation to work, which is broken with this code added.
Ooops, moving to duplicate #1058028: Add guard-class and prevent JS error when using certain jCarousel options
Comment #13
jonathanhuot commentedI'm currently using a few callbacks, but I need to use onBeforeAnimation and onAfterAnimation (see itemFirstInCallback for example).
It seems that patch #8 fixed simple callback, but not array of callbacks. I already patch this in my code but it is really ugly:
Before testing if it is a string, I'm testing if callback is an array and copy/paste the same JS block twice, one for onBeforeAnimation and one for onAfterAnimation.
Comment #14
MICKtheBIG commentedIf you want to fix it the jQuery way then just put this Javascript anywhere:
jQuery.extend(Drupal.settings.jcarousel.carousels["jcarousel-view--jcarousel--block-1"], {
"initCallback": jcarousel_initCallback
});
Then your callback function is "jcarousel_initCallback". You've just extended the jCarousel-Drupal-Configuration object.
Please be aware, that "jcarousel-view--jcarousel--block-1" depends on how many carousels you've got on your page and which you want to control.
@jonathanhuot: I'm pretty sure that this will work for your problem:
jQuery.extend(Drupal.settings.jcarousel.carousels["jcarousel-view--jcarousel--block-1"], {
itemVisibleInCallback: {
onBeforeAnimation: mycarousel_itemVisibleInCallbackBeforeAnimation,
onAfterAnimation: mycarousel_itemVisibleInCallbackAfterAnimation
},
itemVisibleOutCallback: {
onBeforeAnimation: mycarousel_itemVisibleOutCallbackBeforeAnimation,
onAfterAnimation: mycarousel_itemVisibleOutCallbackAfterAnimation
}
});
Comment #15
quicksketchPlease file a new issue for this problem (with a patch if you've already made some changes). It's really messy to have multiple patches in the same issue.