lundi 29 décembre 2014

Javascript prototype declaration over multiple files


I have this big "class".



function MyFunc(){
this.prop = true;
}

MyFunc.prototype.method1 = function(){
// code here
}


etc, lots of methods in one file. and then, the instance is created and run on document.ready


And then, I have one particularly large method, that I would like to move to a separate file. However, when I move it and include them one after another, main file first, the second one says MyFunc is not defined. I cannot add that prototype.method declaration on document.ready, also, since it has to be ready before instance is initialized. What pattern should I use here to properly organize my code? Thanks.





Aucun commentaire:

Enregistrer un commentaire