If you want to know Why isn’t my ember.js route model being called? This explains why the model hook is just called on page refresh. But this confuses a lot of people. So, this is not the right hook in this case. I think you should use the setupController hook for this case.
Try the below example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | App.PlaceRoute = Ember.Route.extend({ setupController: function (controller, model) { console.log('place route called'); var place; $.getJSON('https://api.foursquare.com/v2/venues/' + model.get('place_id') + '?client_id=nnn&client_secret=nnn', function (data) { var v = data.response.venue; place = App.Place.create({ id: v.id, name: v.name, lat: v.location.lat, lng: v.location.lng }); }); controller.set("model", place); } }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.