I have one javascript file that houses all the functions for my website, stored it a large object, like this:
var Example = {
init : function(){
alert('init');
},
page_one : function(){
alert('this is page 1');
},
page_two : function(){
alert('this is page 2');
}
}
Now I like to open a simple script tag on the different pages, and on page1 do Example.page_one(); and on page2 do Example.page_two();
But this doesn’t work. When I call those in the same file as where die Example object is made, then it works, but not if I include that file in a page, and call it from there.
The Example object does show up in the window object
Can someone help me?
Well, I fixed it myself. Stupid fault.
My code was like this:
And the problem seemed to be with defer. The object did load, but after the script fired that called to it.
Thanks for the help!