javascript - Ember.js - Can't use this.transitionTo -


i've combined ember.js phonegap, here see confirm api. problem can't execute this.transitionto('index') event driven function onconfirm..

any ideas ?

  app.mainroute = ember.route.extend({         actions:{             abort: function(){                 navigator.notification.confirm(                     'sind sie sicher ? ',                       onconfirm,                                 'abbrechen',                               ['nein','ja']                      );                 function onconfirm(buttonindex) {                     if (buttonindex == 2){                         this.transitionto('index');                     }                                 }                 //this.transitionto('index');             }         }     }) 

variable scope. this scoped onconfirm function, need scoped outer context:

function onconfirm(buttonindex) {   if (buttonindex == 2){     this.transitionto('index');   }                 }.bind(this) // <-- scope "this" can transition 

you can this, if need legacy browser support:

var _self = this; function onconfirm(buttonindex) {   if (buttonindex == 2){     _self.transitionto('index');   }                 } 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -