davatron5000 / FitText.js

A jQuery plugin for inflating web type
http://fittextjs.com
6.75k stars 1.39k forks source link

Uncaught TypeError: undefined is not a function - Help #121

Closed florian-oefner closed 10 years ago

florian-oefner commented 10 years ago

Hi,

Chrome is throwing Uncaught TypeError: undefined is not a function all the time. I initialized just like described and used jquery v.2.1.1. I even tried the vanilla js plugin, but I got the same error.

I´m using it together with Foundation & Modernizer if that matters.

Here´s the code:

<script src="js/vendor/jquery.js"></script>
<script src="js/vendor/fittext.js"></script>
<script>
        $('#headline_main').fitText(1.2);
        $('#headline_second').fitText(1.2); 
</script>
arthurvr commented 10 years ago

A testcase on jsfiddle would be nice, I can't reproduce this.

dcondrey commented 10 years ago
<script>
    jQuery('#headline_main').fitText(1.2);
    jQuery('#headline_second').fitText(1.2); 
</script>

Make sure jQuery is loaded

florian-oefner commented 10 years ago

Hi, thanks for your tips. I´m sorry I totally forgot to include a jsfiddle.

Here is it now: http://jsfiddle.net/9Lvte2nb/ And the fullscreen mode for better showcase of the problem: http://jsfiddle.net/9Lvte2nb/embedded/result/

@dcondrey I tried what you suggested (as you can see in the fiddle), but didn´t help either. JSFiddle isn´t throwing an Uncaught TypeError, but it still doesn´t work. At least in Chrome on my machine.

Has anyone a clue whats going on?

Thanks a lot

arthurvr commented 10 years ago

The issue is really easy. It's just a problem you did this in the css:

header h1 {
    font-size: 5.2rem !important;

Since it's tagged as !important, It doesn't get changed. Issue closed, I think?

Related issue: https://github.com/davatron5000/FitText.js/issues/88

florian-oefner commented 10 years ago

Thanks for your help! I don´t know why I have missed this mistake.

It works fine now. The uncaught type error I mentioned occured because fittext.js wasn´t loaded when I called the function.

Thank you very much to all of you that helped!