I'm trying to emulate the module pattern found here: https://css-tricks.com/how-do-you-structure-javascript-the-module-pattern-edition/
Here is my code:
var RPSLS_UI = {
settings: {
playerSelections: $(".card")
},
init: function() {
this.bindUIActions();
},
bindUIActions: function() {
this.settings.playerSelections.on("click", function() {
console.log($(this));
});
}
};
I have included the dependencies in my HTML in this order:
<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="assets/js/rpsls-ui-1.0.js"></script>
<script type="text/javascript" src="assets/js/index.js"></script>
When I load my HTML, I type in console:
RPSLS_UI.init();
Results in:
undefined
Then I type in:
RPSLS_UI.init;
Results in:
function () {
this.bindUIActions();
}
What is happening here? Why is the init() function undefined?