What should be the proper value for "this" in a UI widget callback?
I have a widget that someone else wrote.
They decided to use an option instead of an event. something like
- { onSuccess: function() { .... } );
As I am using this widget - I see that when I implement the "onSuccess", the value for "this" is the plugin instead of its element. for example :
- (onSuccess: function(){ console.log(this); });
this will print
- a.widget.a.(anonymous function).(anonymous function)
I think the value for "this" should always be the element, and not the widget. Am I wrong?
Is there a guideline or maybe a best practice with reasons as to why?
Am I right saying that if we decide to switch to event triggering we will have to change the value for "this" because a widget cannot trigger an event, only its element?