I am using ember-cli v 0.2.1. My router.js
looks as follows:
Router.map(function() {
this.route('projects', function() {
this.route('project-id', { path:':id' });
});
My routes/projects.js
looks as follows:
export default Ember.Route.extend({
model: function(){
var clientID = 'FooBarFooBarFooBar';
var query = 'motorcycle';
var url = "https://api.behance.net/v2/projects?q="+ query +"&client_id="+ clientID;
return ajax({url:url,type:'GET', dataType: "jsonp"}).then(function(res){
return res.projects;
});
}
});
Part of my templates/projects.hbs
looks as follows:
{{#each item in content}}
<div class="row">
<h4>
{{#link-to 'projects.project-id' item}}
{{item.name}}
{{/link-to}}
</h4>
{{/each}}
{{outlet}}
My routes/projects/project-id.js
looks as follows:
export default Ember.Route.extend({
model: function(parmas){
var clientID = 'FooBarFooBar';
var url = "https://api.behance.net/v2/projects/"+ parmas.id +"?api_key="+ clientID;
debugger;
return ajax({url:url, type:'GET', dataType: "jsonp"}).then(function(res){
debugger;
return res.project;
});
},
});
When I click on a particular project, URL changes with appropriate project id but model hook in project-id.js
does not get called. It gets called when I refresh the page with URL /projects/:project_id already set in it.
Please, help me understand this behaviour. I want the model hook to be called when someone clicks on the particular project.