Basically, I wasn't using the "bind" function for my object references.
// Define the class.
var Construct = Construct || (function()
{
// Constructor.
var Construct = function(name) {};
// Additional functions.
Construct.prototype =
{
sayHello: function() { alert("Hello"); }
schedule_WRONG: function() { setTimeout(this.sayHello, 1500); },
schedule_RIGHT: function() { setTimeout(this.sayHello.bind(this), 1500); },
};
// Return the type.
return Construct;
})();
$(function()
{
// Construct the object.
var f = new Construct();
f.schedule();
});
No comments:
Post a Comment