Skip to content
This repository

buttonNextCallback is not called if buttonNextHTML is null #39

Closed
jerkan opened this Issue September 06, 2010 · 8 comments

2 participants

jerkan Jan Sorgalla
jerkan

Title says it all. The question is: ¿Is it the right behaviour?

I am configuring jcarousel like this:

$('#carousel').jcarousel({
    visible: 1,
    scroll: 1,
    initCallback: carouselInitCallback,
    buttonNextCallback: carouselNextCallback,
    buttonPrevCallback: carouselPrevCallback,
    buttonNextHTML: null,
    buttonPrevHTML: null
});

If I remove last two lines (buttonNextHTML and buttonPrevHTML) callbacks are called.

I'd like buttonNextCallback and buttonPrevCallback to be called with my custom buttons. Is that possible?

Jan Sorgalla
Owner

See this example for how to use custom controls: http://sorgalla.com/projects/jcarousel/examples/static_controls.html

jerkan

I modified that example like this:
[...]

function mycarousel_nextCallback(carousel, button, enabled){
console.info('next should be enabled? ' + enabled);
};

function mycarousel_prevCallback(carousel, button, enabled){
console.info('previous should be enabled? ' + enabled);
};

jQuery(document).ready(function() {
jQuery("#mycarousel").jcarousel({
scroll: 1,
initCallback: mycarousel_initCallback,
// This tells jCarousel NOT to autobuild prev/next buttons
buttonNextHTML: null,
buttonPrevHTML: null,
buttonNextCallback: mycarousel_nextCallback,
buttonPrevCallback: mycarousel_prevCallback
});
});
[...]
Check that out and see that neither mycarousel_nextCallback nor mycarousel_prevCallback are called. Then, comment 'buttonNextHTML: null', and 'buttonPrevHTML: null' and see that callbacks are called.

Jan Sorgalla
Owner

Ah, sorry. I misunderstood your question. Callbacks are only called on buttons created by jCarousel. External buttons are not notified. I'll put that on my todo list...

jerkan

Thanks! :-)

jerkan

Can you give me a clue about what should I change?

I've tried changing lines 766 and 770 like this:
if (this.options.buttonNextCallback != null) {
and
if (this.options.buttonPrevCallback != null) {
with no luck.

I really need this. Thanks in advance

Jan Sorgalla
Owner

Fire button callbacks also if no buttons are specified (Closed by f10693d)

Jan Sorgalla
Owner

Could you please try the latest development version: http://github.com/jsor/jcarousel/blob/0.2/lib/jquery.jcarousel.min.js

Callbacks should now be called also if no buttons are specified.

jerkan

Thank you very much!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.