I'm overlooking something here with scope resolution in this jQuery plugin. Here is a simplified example of what I'm trying to achieve:
(function($) {
$.fn.dashboard = function(options) {
this.onClick = function(e) {
alert("do something");
return false;
};
var createButton(parent) {
//This should call the onClick method defined above when the link is clicked.
var button = $('<a href="#">Reply</a>').click(this.onClick);
parent.append(button);
};
return this.each(function() {
var doc = $('body');
createButton(doc);
});
};
})(jQuery);
The issue is that onClick never gets called. Definitely seems to be some manner of scope issue.