sheriffderek sheriffderek - 1 month ago 5
jQuery Question

Ember dependencies "Uncaught TypeError: $(...).fitText is not a function"

I'm attempting to use a jQuery plugin (in this case 'fitText') in an Ember project.

In the

(that replaced the Brocofile recently...) - I import the dependency (which I have already installed with bower).

/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function(defaults) {
var app = new EmberApp(defaults, {
// Add options here


return app.toTree();

In my console, I can type in 'fitText' and I DO get the object back. So, it's global now, and I should be able to use it anywhere. BUT
"Uncaught TypeError: $(...).fitText is not a function"

@Tom Netzband pointed out that the bower version of fitText was the one that @adacio maintains and is vanilla JS. I've since switched it out for a
(the JS is really only 20 lines or so)

Previously I needed to import it in the controller or route where I want to use it - but the docs don't reference that anymore. In the docs with
as the example, it seems to become a global.

I've put it in the ready hook in app.js - next to similar jQuery things that work fine... but no luck. In this case I only want to affect a few words on the index.hbs / route


This has really just become another question now. I thought it was still the same problem but it's not. So awarding answer and asking a new one. Thanks.


It looks like bower install fittext doesn't install the jQuery plugin version of fitText, it only installs the plain js version of it.

If you look at your bower_components/fittext/fittext.js file, you'll see jQuery isn't passed in or used, and the example from the example.html file shows usage as being:

fitText(document.getElementById('fittext'), 1.2)

So if you want the jQuery version you might have to download it straight from github and throw it in your vendor folder and include it outside of bower.


Looks like the version registered with bower is a forked version from the jQuery version where jQuery has been removed: