this reference in callback function

edited November 2012 in Newbie Questions
Hi ,

Scope of this lost in the callback function. I think this can be achieved with bind function in enyo but I am not aware how to use it exactly in my example.

Please suggest how to implement this in below example.
enyo.kind({

Comments

  • edited November 2012
    is it the correct way?
    navigator.geolocation.getCurrentPosition(
        enyo.bind(this,this.getPositionSuccess),
        enyo.bind(this,this.getPositionError));
  • That should do it. enyo.bind requires the first argument to be the scope, so this in your example, and the second to be the function, which is fulfilled by this.getPositionSuccess.
  • Please remember to use pre/code tags around code you post. I've fixed the entries above.
Sign In or Register to comment.