Newbie: Custom jQuery in main.js not working


#1

It’s my understanding that custom JavaScript should be included in assets/scripts/main.js

So I added this line to the file below line 21: $( ".menu ul li" ).attr( "class", "col" ); But it’s not working.

Can anyone help me understand what I’m missing?

Thank you.


#2

Custom javascript should be added to the relevant route more than the main.js. Your main.js is your router, it’s purpose is to call the appropriate javascript depending on which page you’re viewing.

I’d say it’s not working cause your file is wrong (you’re not passing your routes object to the router). Check the source here:
https://github.com/roots/sage/blob/master/assets/scripts/main.js


#3

@Nicolo_Sacchi he’s using Sage 8, not Sage 9 (which is the main JS you linked)

@s3w47m88 Did you compile your scripts / run gulp?


#4

@benword yes, I’m running gulp watch.


#5

My mistake, pardon, I misread the gist :slight_smile: