Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onComplete never gets called #36

Open
brianjessup opened this issue Oct 26, 2013 · 3 comments
Open

onComplete never gets called #36

brianjessup opened this issue Oct 26, 2013 · 3 comments

Comments

@brianjessup
Copy link

I'm not sure if this is a bug or I'm wrong about the intended functionality of the onComplete function.

But when bootstro.next is called, the activeIndex is always 2 less than the count. activeIndex being incremented from 0, and count being the total count. E.g. when I am on step 7 of 8 on your demo page, and click next, the activeIndex = 6 and the count is = 8.

Therefore the onComplete call in the below code is never called.

bootstro.next = function()
{
if (activeIndex + 1 == count)
{
if (typeof settings.onComplete == 'function')
settings.onComplete.call(this, {idx : activeIndex});//
}
else
{
bootstro.go_to(activeIndex + 1);
if (typeof settings.onStep == 'function')
settings.onStep.call(this, {idx : activeIndex, direction : 'next'});//
}
};

What confuses me is the "else" statement. Are you intending for the onComplete here to be accesses with a next button located on the last step of the tour? Shouldn't that be an onExit?

What we are trying to use the onComplete for is to flag in our db that the tour has been taken. In that case, the code should read like:

bootstro.next = function()
{
if (activeIndex + 2 == count)
{
//call onComplete callback function if needed
if (this.onCompleteFunc != undefined) {
this.onCompleteFunc.call(this, { idx : activeIndex });
}
}
bootstro.go_to(activeIndex + 1);
if (typeof settings.onStep == 'function')
settings.onStep.call(this, {idx : activeIndex, direction : 'next'});//
};

@ericpeters0n
Copy link

Also seeing onComplete be completely ignored.

@ericpeters0n
Copy link

@brianjessup For my purposes, I simply transposed the call to onComplete to the event handler for .bootstro-finish-btn...
ln390:


            //end of show
            $("html").on('click.bootstro', ".bootstro-finish-btn", function(e){
                e.preventDefault();

                //
                if (typeof settings.onComplete == 'function')
                    settings.onComplete.call(this, {idx : activeIndex});//
                //

                bootstro.stop();
            });        

@brianjessup
Copy link
Author

@ericpeters0n nice! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants