1

I am trying to detect if a variable - play_status - has been set or not in javascript like this..

$lg.on('afterslide', function(event, prevIndex, index){

    if (play_status) {
        console.log('Play Defined')
    }

    iframe = $('.inner .item').eq(index).find('.vimeo').get(0);
    var player = $f(iframe);

    player.addEvent('ready', function(index) {

        player.addEvent('play', function() {
            var play_status = index;
        });

    });

});

But when I run it for the first time (when no variable is set) then I get the following error...

Uncaught ReferenceError: play_status is not defined

Where am I going wrong?

3
  • 1
    looks like you only declared play_status when you add event play to player, so its not defined outside that scope Commented Sep 9, 2018 at 14:48
  • Thanks Chris, it was indeed a scope issue. Want to make your comment into an answer and I can mark it correct? Commented Sep 9, 2018 at 14:50
  • 1
    thx, i posted it as answer Commented Sep 9, 2018 at 14:51

1 Answer 1

1

looks like you only declared play_status when you add event play to player, so its not defined outside that scope

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, exactly what I was looking for :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.