var Page = {
data: null,
Load: function () {
this.Populate;
},
Populate: function () {
}
};
$(document).ready(Page.Load);
- Why can’t I reference
Page.Loadas a function inready()eg.ready(Page.Load()) - Why can’t I call
this.Populate()from the Load function, I just getthis.Populate()is not a function.
There are two problems in your code.
First, as Rob says, you’re not actually calling the
Populate()method inLoad(). You need to add parenthesis to do that.Second, the
thiskeyword inPopulate()does not refer to thePageobject. You can use $.proxy() to set thePageobject as the context of the method call: