My.Awesome.Obj = function() {
return {
// PUBLIC PROPERTIES
legendObj: null,
// PUBLIC METHODS
init: function() {
this.assignLegendClick();
},
assignLegendClick: function() {
console.log('*** drawLegend()');
var checkboxes = this.legendObj.find("input");
checkboxes.each(function() {
$(this).click(function() {
this.handleLegendClick();
});
})
},
handleLegendClick: function() {
console.log('*** handleLegendClick()');
},
EOF: null
};
}();
So I’m getting an error saying
handleLegendClick is not defined
I’m assuming this is a scope issue, but I’m not sure how to refer back to the parent object within the loop…
The problem is that
thisis thewindowwhen the click event handler is called.You might do this :