How does ember-cli-build.js work?


This may seem like a stupid question, and I am familiar with how bundling works. Seems pretty straightforward but for some reason it’s not working for me. I have a simple JS file that does stuff to my nav bar (toggling mobile). I put the file in /vendor and added a line in ember-cli-build js


…and I see the code I wrote in vendor.js once I rebuild and restart the server. However, the code is not working. If I put the code in a script tag directly under my nav element, the JS works fine. I should add that my code is actually jQuery. I seem to be missing something fundamental about how including custom scripts is supposed to work. I’ve followed the documentation but it’s just not working. Any help? Thanks!


Normally app.import makes something like moment.js globally available as moment You than have to do something with it like in a helper. See also this example. Perhaps you can just put all your code in a helper?


What I think you are missing is the DOM is not yet built when your script loads. You probably want to make your script a function and call it in didInsertElement or didRender of your nav bar component.