Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MyObject = function ()
- {
- MyObject.initializeBase(this);
- this._someProperty = null;
- };
- MyObject.prototype = {
- initialize: function()
- {
- // Init
- },
- get_someProperty: function()
- {
- return this._someProperty;
- },
- set_someProperty: function(value)
- {
- this._someProperty = value;
- },
- doSomething: function ()
- {
- $('.some-class').each(function ()
- {
- $(this).click(this.doClick); // this.doClick is wrong
- });
- },
- doClick: function ()
- {
- alert('Hello World');
- }
- };
- var that = this;
- doSomething: function ()
- {
- var instance = this;
- $('.some-class').each(function ()
- {
- $(this).click(instance.doClick);
- });
- },
- doSomething: function ()
- {
- $('.some-class').each(function(_, node)
- {
- $(node).click(this.doClick); // this.doClick is right
- }.bind(this));
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement