treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Syntax Error


  • Where have I gone wrong? I get a syntax error as noted below. I really know very little about js, but I'm using Chris et al's Anything slider. Everything was working fine until I tried to add some video configuration code, but some syntax error that I can't figure out is messing things up. I think I'm missing a closing } or something. Help?

    // Set up Sliders
    // **************
    $(function(){

    $('#slider1').anythingSlider({

    mode : 'f',
    resizeContents : false,
    navigationSize : 20,
    navigationFormatter : function(index, panel){
    return ['SFBG Intro', 'Cat Brain', 'Espresso Machine', 'Underwater Project', ][index - 4];
    },
    onSlideBegin: function(e,slider) {
    // keep the current navigation tab in view
    slider.navWindow( slider.targetPage );
    //video
    resumeOnVideoEnd : true,
    resumeOnVisible : true, //**ERROR ON THIS LINE**
    addWmodeToObject : "opaque",
    isVideoPlaying : function(base){ return false; }

    }

    });

  • Hey, try this

    $(function() {

    $('#slider1').anythingSlider({

    mode: 'f',
    resizeContents: false,
    navigationSize: 20,
    navigationFormatter: function(index, panel) {
    return ['SFBG Intro', 'Cat Brain', 'Espresso Machine', 'Underwater Project'][index - 4];
    },
    onSlideBegin: function(e, slider) {
    // keep the current navigation tab in view
    slider.navWindow(slider.targetPage);
    //video
    resumeOnVideoEnd = true;
    resumeOnVisible = true;
    //**ERROR ON THIS LINE**
    addWmodeToObject = "opaque";
    isVideoPlaying = function(base) {
    return false;
    };

    }

    });
    });​
  • Thanks, karl, but it had no effect.
  • Hmm, how about this

    $(function() {
    $('#slider1').anythingSlider({
    mode: 'f',
    resizeContents: false,
    navigationSize: 20,
    resumeOnVideoEnd: true,
    resumeOnVisible: true,
    addWmodeToObject: "opaque",
    navigationFormatter: function(index, panel) {
    return ['SFBG Intro', 'Cat Brain', 'Espresso Machine', 'Underwater Project'][index - 4];
    },
    onSlideBegin: function(e, slider) {
    slider.navWindow(slider.targetPage);
    },
    isVideoPlaying: function(base) {
    return false;
    }
    });
    });​
  • No dice :(
  • I tried to detect your error code with JSFiddle's JSLint:

    Extra comma:

    return ['SFBG Intro', 'Cat Brain', 'Espresso Machine', 'Underwater Project', ]


    And some unclosed function.
    How about this:

    // Set up Sliders
    // **************
    $(function() {
    $('#slider1').anythingSlider({
    mode: 'f',
    resizeContents: false,
    navigationSize: 20,
    navigationFormatter: function(index, panel) {
    return ['SFBG Intro', 'Cat Brain', 'Espresso Machine', 'Underwater Project'][index - 4];
    },
    onSlideBegin: function(e, slider) {
    // keep the current navigation tab in view
    slider.navWindow(slider.targetPage);
    },
    resumeOnVideoEnd: true,
    resumeOnVisible: true,
    addWmodeToObject: "opaque",
    isVideoPlaying: function(base) {
    return false;
    }
    });
    });
  • Try to put the closing parenthesis after the second to last curly brace. Also looks like you might have an extra comma with in the array that is being returned.

    I hope that helped!

    -Mike