XenForo.context vs function .bind

Uniphix

Active member
What is the difference the $.context (extended from jQuery via XenForo) function works like the function bind?

for example...


$('#element').click($.context(this, 'elementClick'));

I can see that it would work best this above if your trying to reference a function.

$('#element').click(function(e){
this.elementClick(e);
}.bind(this));

or

$('#element').click(this.elementClick.bind(this)); which is the same thing as $.context(this, 'elementClick');

$('#element').click($.context(function(){
alert('Hello World');
}, this));

What is the purpose of the two functions?
 
Top Bottom