I have the following:
class Button_Event {
add_click() {
this.button_jquery_object.on('click', function(e){
this.add_loading();
run_function_by_name(this.ajax_callback).done(function() {
this.remove_loading();
});
});
}
}
But when I run it, the following error occurs:
Uncaught TypeError: this.add_loading is not a function
...and rightfully so. I'm trying to call a class' method inside an anonymous function. I feel as if I shouldn't do this but I need to do this. How can this be done?
I believe I'm looking to somehow enforce the "this" scope on my anonymous' functions body too.