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

Cannot read property 'beforeStep' / 'afterStep' of undefined #19

Open
edarioq opened this issue Jun 22, 2018 · 4 comments
Open

Cannot read property 'beforeStep' / 'afterStep' of undefined #19

edarioq opened this issue Jun 22, 2018 · 4 comments

Comments

@edarioq
Copy link

edarioq commented Jun 22, 2018

When the joyride is finished, and I click the button that starts it again, I get Cannot read property 'beforeStep' of undefined and Cannot read property 'afterStep' of undefined. Example code:

$scope.startJoyRide = function() {
    joyride.start = true;
    if ($scope.step1) {
        joyride.config = {
            steps: [
                {
                    type: 'element',
                    selector: '#div-1',
                    content: 'Some text.',
                    placement: 'left'
                },
                {
                    type: 'element',
                    selector: '#div-2',
                    content: 'Some text.',
                    placement: 'left'
                },
                {
                    type: 'element',
                    selector: '#div-3',
                    content: 'Some text.',
                    placement: 'left'
                    },
                {
                    type: 'element',
                    selector: '#div-4',
                    content: 'Some text.',
                    placement: 'left'
                }
            ]
        };

        if ($scope.step2) {
        joyride.config = {
            steps: [
                {
                    type: 'element',
                    selector: '#div-1',
                    content: 'Some text.',
                    placement: 'left'
                },
                {
                    type: 'element',
                    selector: '#div-2',
                    content: 'Some text.',
                    placement: 'left'
                },
                {
                    type: 'element',
                    selector: '#div-3',
                    content: 'Some text.',
                    placement: 'left'
                },
                {
                    type: 'element',
                    selector: '#div-4',
                    content: 'Some text.',
                    placement: 'left'
                }
            ]
        };
    joyride.config.template = './views/modules/admin/joyride.html';
}
@edarioq
Copy link
Author

edarioq commented Jun 22, 2018

Perhaps the issue is with current: -1 in the joyride object. Not sure why there is a -1 as current. It only happens after clicking next slide too. If I launch the joyride and click "Done" instead, it never goes a step, therefore current is still 0.

@edarioq
Copy link
Author

edarioq commented Jun 22, 2018

I fixed by opening the source file joyride.js and changing the function afterTransition to the following:

            if (scope.joyride.transitionStep == 'next') {
              scope.joyride.current++;
            }
            else {
              if (scope.joyride.current > 0) {
                scope.joyride.current--;
              }
            }

This way scope.joyride.current-- won't ever be a negative number, hope this helps someone, or should I open a PR?

@edarioq
Copy link
Author

edarioq commented Jun 27, 2018

PR: #21

@ahmed-wagdi
Copy link
Owner

Hey @edarioq sorry for the late reply.

I'm having trouble recreating this, based on the code you posted above:
https://next.plnkr.co/edit/lbnsbshEC46w7aWr

I had to make some changes because i dont know what your template contains or how $scope.step1 is set. It would be helpful if you could change the plnkr i posted above to better reflect the problem you were having.

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