Reputation: 7394
I wrote the following functions. At run time the browser complains about uncaught TypeError ...has no method 'init'. What's wrong of my code?
function build_results_grid (response) {
// build grid
grid_ui.init();
} // build the results grid
var grid_ui = function () {
return {
init: function () {
//build_grid();
}
}; // return
}
Upvotes: 0
Views: 7635
Reputation: 16788
since a call to grid_ui is necessary to return the function with init inside, you need
grid_ui().init();
Since grid_ui must be called. Or you can make grid_ui
be the return of the call, as SLaks did
EDIT - I misread your braces, if you noticed the question I had here before you can disregard it.
Upvotes: 3
Reputation: 888283
You assigned grid_ui
to a function, without calling it.
Change that to
var grid_ui = (function() { ... })();
Upvotes: 9