Uncaught TypeError: $(...).fitVids is not a function -SAGE 9

sage9

#1

Try to install the fitvids with the latest Sage 9, but it keep giving me an error.

import {fitvids} from 'fitvids';

$('body').fitVids();


Uncaught TypeError: $(...).fitVids is not a function
at Object.init (common.js:46)
at Router.fire (Router.js:30)
at Router.loadEvents (Router.js:45)
at HTMLDocument.<anonymous> (main.js:38)
at i (jquery-1.12.4.min.js:2)
at Object.fireWith [as resolveWith] (jquery-1.12.4.min.js:2)
at Function.ready (jquery-1.12.4.min.js:2)
at HTMLDocument.K (jquery-1.12.4.min.js:2)

Anyone?

Thanks!


#2

This should be sending up some red flags:

That means that JS is trying to execute a thing (who knows what it actually is) that it can’t execute. If you take a look at the source for fitVids, it looks like it doesn’t support being used as a JS module—specifically, it doesn’t export anything you can import. Instead, it just wants you to add it so it can hook in to jQuery.

My (untested) suggestion would be to do the following:

import 'jquery'
import 'fitvids'

$(`body`).fitVids();

#3

thanks, but not working!


#4

What else have you tried?


#5

switch it to fluidvids.js