I have a javascript code written following the module pattern:
var controller = function () {
return {
init: function() {
// settings and initialization
}
makeUIactions: function() {
//set UI actions, for example callback function of a button:
document.getElementById("ShuffleButton").addEventListener("click", Shuffle);
function Shuffle(){};
}
}
}
How do I pass by document object to makeUIactions?
P/S: I got the following error:
Cannot read property 'addEventListener' of null
Is it because I can't access document from makeUIactions?
HTML:
<script>
controller.init();
controller.makeUIactions();
</script>
<div>
<input type="button" id="ShuffleButton" style="margin-top:20px" value="Shuffle" data-inline="true">
<input type="button" id="SubmitButton" style="margin-top:20px" value="Submit" data-inline="true">
</div>