Utilizing Mootools 1.3.2
Here is the code snippet:
var DNReportAbuse = new Class({
Extends: DNUserDialog,
comment_id: null,
container: null,
initialize: function(classname)
{
var bindclass = $(document.body).getElements(classname);
bindclass.each(function(el) {
el.addEvents({
click: function() {
this.reportComment();
}.bind(this)
});
});
},
reportComment: function() {
this.preventDefault();
alert('hello');
return false;
}
});
The event successfully binds, and if "this.reportComment();" is replaced with "alert('hello world');", it works perfectly...
...however, using "this.reportComment()" throws an error stating "function this.reportComment() is not a function" according to Firebug.
It seems like I may be having issues with referencing a class function outside of its correct scope, but I am unsure why or how to address the problem. The ultimate aim is to bind the reportComment() function on-click to all elements of a CSS class (up to 20 per page). The challenge arises when attempting to reference the reportComment() function with "this.reportComment()", resulting in an error claiming the function does not exist even though it clearly does.
After looking through similar queries on Stack Overflow without finding a solution, I am reaching out in hopes that someone can guide me in the right direction.