I want to reset a variable in the application controller to the value returned from an AJAX call. The code shown below does not work because 'this' does not have the correct context. The server returns a value other than 15, but the second console.log still prints 15. I also tried App.ApplicationController.set ('x', data) and controllers.application.set ('x', data) and several others of opportunities. No one worked. What is the right way to do this?
App.ApplicationController = Ember.Controller.extend({ x: 15, init: function() { console.log(this.get('x')); $.getJSON ("strats/limits.json") .done (function (data){this.set('x', data);}); console.log(this.get('x')} });
ptmoy2
source share