1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XenForo.context vs function .bind

Discussion in 'XenForo Development Discussions' started by Uniphix, Aug 16, 2014.

  1. Uniphix

    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(this.elementClick.bind(this)); which is the same thing as $.context(this, 'elementClick');

    alert('Hello World');
    }, this));

    What is the purpose of the two functions?

Share This Page