this might be an issue of, I don't even know what to look for, thereby repeating a question. If so please link correct page and I will scurry to the corner in shame! Thanks in advance!
BEFORE: I was just running a game with an index.html
and two file_name.js
files, and pulling them in the head along with jQuery.
In my old HTML file:(This worked) I had a game.js
file (doing doc ready, on click and keyup commands) and a gamelogic.js
file (managing all the game logic)
My code from my OLD index.html
file
<script src="https://code.jquery.com/jquery........."></script>
<script src="js/gamelogic.js"></script>
<script src="js/game.js"></script>
Now:
(Transferring a game over to rails) I'm in a Rails 4 app, scaffolded a game Model.
Created two new .js files with similar names in the app/assets/javascripts
file
The problem: I know both files are being loaded, as I can console.log("foo")
from both. And I know all my functions work, as when all code is combined to one file, all feature function.
I would like to keep them as two different files as the doc ready section is already kinda long and so is the logic section.
Below is the goal, call a logic function inside of the main game file.
File game.js
$(document).ready(function() {logicFunction();};
File gamelogic.js
function logicFunction(){console.log("BAR")}
Just a note: this is not for production or best practices, this is to learn the ins and outs of rails, and what things can and can't do. I doubt my code "should" be split, however I am curious if it's even possible. I will also we converting to coffee once I get functionality.