ember.js - Load model like a refresh without ember-data -


i'm writing little ember app without using ember-data (using themoviedb api) , don't understand why model not load when click on {{#linkto}} link, when refresh page manually datas loaded correctly.

here app.js :

window.app = ember.application.create();  app.router.map(function() {   this.route('about');   this.resource('movie', {     path: '/movie/:movie_id'   }) });  app.indexroute = ember.route.extend({     setupcontroller: function (controller) {         var movies = [];             $.ajax({                 url: "http://api.themoviedb.org/3/movie/popular?api_key=5b088f4b0e39fa8bc5c9d015d9706547",                 type: "get",                 async: false,                 success: function (data) {                 var length = data.results.length;                  data.results.foreach(function (item) {                     if (item.backdrop_path != null) {                         var tmp = item.backdrop_path;                         item.backdrop_path = "http://cf2.imgobject.com/t/p/w500/"+tmp+"?api_key=5b088f4b0e39fa8bc5c9d015d9706547"                         movies.push(item);                     }                  })             }         });          controller.set('content', movies);     } });   app.movieroute = ember.route.extend({     model: function (param) {         var infos;         /* important !! */         var promise = ember.deferred.create();      $.ajax({         url: "http://api.themoviedb.org/3/movie/"+param.movie_id+"?api_key=5b088f4b0e39fa8bc5c9d015d9706547",         type: "get",         success: function (data) {             var tmp = data.backdrop_path;             data.backdrop_path = "http://cf2.imgobject.com/t/p/w500/"+tmp+"?api_key=5b088f4b0e39fa8bc5c9d015d9706547";             // infos = ember.object.create(data)             promise.resolve(data);          }     });     console.log("model");     return promise; },     setupcontroller: function (controller, model) {         controller.set('content', model);     } });  app.movie = ember.object.extend({}) 

thanks !

since have not specified model mean, i'm assuming mean movie model, , assumption i'm trying answer.

i think problem template expects model coming movieindexcontroller because specified resource in router map instead of simple route.

that said, solution might rename controller movieindexcontroller , respectively route movieindexroute.

here reference answer based on, under paragraph resources.

hope helps


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -