I'm making a simple application where I am making the same ajax call over and over again (with setInterval), and it's triggered not by the user moving into a route, but rather by clicking a button that triggers setInterval to start. Therefore, I'm not fetching data with the model
hook that is triggered by moving into a route, since that hook is only called once, and then the template is rendered automatically. Rather, I have an jsonRequest
function in a controller that is called by the startInterval function over and over again. Therefore, there is no automatic rendering of the data in the template in the way that happens with the model
hook. So once my data is returned after each ajax request, I wish to append it to a list, or somehow add it to the index.html, but I can't find a way to do this with Ember's api
App.IndexController = Ember.Controller.extend({
jsonRequest: function(){
var datasource = 'http://localhost:8080';
return new Ember.$.ajax({url: App.Index.url, dataType: "json", type: 'GET'}).then(function(data){
console.log(data)
})
},
startInterval: function(){
console.log("startInterval");
App.Index.setIntervalId = setInterval( this.jsonRequest, (1000));
}
App.Index = Ember.Object.extend({
url: "",
setIntervalId: "",
});
Aucun commentaire:
Enregistrer un commentaire