I am getting a page() is not defined error message from Firebug with the following Javascript. Why?
( function() {
var page = function() {
var min_central_width = 10;
function minimumCentralWidth(val) {
min_central_width = val;
}
}
$(document).ready(function() {
page().minimumCentralWidth(400);
});
})();
I am still new to Javascript. How can I avoid this?
The problem is that
pageisn’t returning a value, sopage()isundefined. You would have to write something like this:. . . but the above doesn’t really do anything. It creates a new object, and sets the object’s
min_central_widthto400. . . but it doesn’t use the object for anything, so the above doesn’t have any meaningful effect. (Is this just because you removed code that wasn’t relevant to the question? If so, then never mind. 🙂