- I will read into how to use the browser console to look for JS errors right now…
- for errors you can check your browser console, or just use alert() for debugging.
There are <%= @user.length %> users in here
- If you are using rails 5 with Turbolink 5 you should use this event to make sure that the element is there.
@ng_real_ninja: Unable to get JS document.getElementById to work in my rails view #angularjs #reactjs
you should use this event to make sure that the element is there.
I just added the above to my stuff.js file, still get no changes. Should I be putting it in a different file? Or if the element is not there, should I check somewhere for an error alert? – MLZ 5 hours ago
What is the version of Rails and Turbolinks are you using? No you should put it in your stuff.js file. for errors you can check your browser console, or just use
for debugging. – Hossam Khamis 5 hours ago
My Rails version is 22.214.171.124, Turbolinks is ‘~> 5’. I will read into how to use the browser console to look for JS errors right now… – MLZ 5 hours ago
This is the server logs not the console log. You can open the browser console by pressing F12 in your browser (Chrom or Firefox), then press
, If there is an error you will find it there. – Hossam Khamis 5 hours ago
The console doesn’t show any errors when I reload it. I’m think it must be due to JS firing too soon to detect the element though. – MLZ 2 hours ago
Looks like you’re running your script before the DOM load. If that’s the case, try putting the call to your code at the end of your body tag.