We are writing an application using EmberJS. However we are still new with this framework and we're having a hard time resolving some of what may seem to be straight forward.
The model is pretty simple, there are 3 models: Queue, Task, and Image. We are using dynamic URI segments for all routes and routes for these models are nested in the form: :queue_id/:task_id/:image_id.
The routes are configured this way:
App.Router.map(function() {
this.resource('queue', {path: ':queue_id'}, function() {
this.resource('task', {path: ':task_id'}, function() {
this.resource('image', {path: ':image_id'});
});
});
}
And somewhere in the HTML, we have this simple template to iterate through all images from a task:
{{#each task.images}}
<li>
{{#view App.ThumbnailView.contentBinding="this"}}
<img {{bindAttr src="thumbnail.url"}} />
{{/view}}
</li>
{{/each}}
And here is the code for the Thumbnail View:
App.ThumbnailView = Ember.View.extend({
tagName : 'a',
click : function(e) {
var task = //assume this value exists;
var queue = //assume this value exists;
var image = //assume this value exists;
this.get('controller.target.router').transitionTo('image', queue, task, image);
}
});
Finally, here's is our ImageRoute:
App.Image = Ember.Object.extend();
App.Image.reopenClass({
find : function(image_id) {
//This is where I set a breakpoint
console.log(image_id);
}
});
App.ImageRoute = Ember.Route.extend({
model : function(params) {
//image_id is the last uri segment in: #/1/1/1
return App.Image.find(params.image_id);
}
});
The Problem:
The call to this.get('controller.target.router').transitionTo()
seems to be working. I can see that when I click in one of the thumbnails view, the URL changes (e.g from /1/1/2 to something like /1/1/3). However, I'm not seeing any state change in the UI. Also, the line where I put a breakpoint doesn't seem to be triggered. But when I refresh the page, it works well.
Is there something wrong with my transition code?
Thanks.