Install FitVids via Bower

Hi,

I’m currently trying to add FitVids.js via Bower and I’m not having any luck. I managed to get it working on another theme that I’m developing with ease but this time it doesn’t appear to be working.

I added FitVids via Terminal:

bower install --save fitvids

and it has been saved to my bower_components, I then ran gulp and everything appears to be in my main.js file with no errors.

I then added then added the init code to the init section of the main.js file:

var Sage = {
// All pages
'common': {
  init: function() {

   $(document).ready(function(){
    // Target your .container, .wrapper, .post, etc.
     $("body").fitVids();
   });
    
    // JavaScript to be fired on all pages
  },
  finalize: function() {
    // JavaScript to be fired on all pages, after page specific JS is fired
  }
},
// Home page
'home': {
  init: function() {
    // JavaScript to be fired on the home page
  },
  finalize: function() {
    // JavaScript to be fired on the home page, after the init JS
  }
},
// About us page, note the change from about-us to about_us.
'about_us': {
  init: function() {
    // JavaScript to be fired on the about us page
  }
}
  };

I’m sure that I’m just missing something stupid, any help would be greatly appreciated.

Thanks in advance!

Hey there, first of all - you don’t need document.ready, we already take care of that for you in the bottom of main.js: https://github.com/roots/sage/blob/master/assets/scripts/main.js#L75

Just change the init function to this:

init: function() {
  // FitVids
  $("body").fitVids();
},

And let me know how that goes…

4 Likes

Hi @JulienMelissas, that did the trick, thank you very much for your help!

1 Like