I am struggling with the Modular Reveal Pattern. This small example illustrates the issue I am having. When the 'Add' button is clicked the 'counter' value increases by 1. When the 'Show' button is clicked Module_2 logs the change to Module_1's counter value. Unfortunately Module_2 doesn't detect the change.
Is there a way to get Module_2 to 'see' the change to the 'counter' in Module_1?
var Module_1 = (function() {
$("#test1").on("click", add);
var counter = 0;
function add() {counter += 1;}
return {counter : counter};
})();
var Module_2 = (function() {
$("#test2").on("click", Show);
function Show() {console.log(Module_1.counter);}
})();
Aucun commentaire:
Enregistrer un commentaire