arakibi
arakibi

Reputation: 447

$ not working in an external js file included in Typo3

I included a javascript file in typoscript (typo3 6.2) , but I can't select anything using the $ selector , the console tells me that $ is not defined . I'm quite sure that the javascript file is successfully included because when I use the document.getelement... selectors they work fine .

I have no idea why this is happening ? any idea ??

thanks

Upvotes: 0

Views: 601

Answers (2)

Dropout
Dropout

Reputation: 13866

The main jQuery library is missing or isn't inialized properly (i.e. you're trying to access functions from it before you include it to your page).

Make sure that it is loaded before any other parts of your page try to use the $ selector.

In layman terms put

<script src="js/lib/jquery-1.10.2-CUSTOM.js"></script>

before other scripts..

Upvotes: 0

biesior
biesior

Reputation: 55798

You didn't include jQuery file and/or your jQuery is included too late (i.e. after including your JS file)

Use browser's dev tools to check the order of inclusions.

Upvotes: 2

Related Questions