I'm making a simple web chat system with Ember.
I have a route /chatrooms
that lists a few chatrooms, and then I also have /chatrooms/:chatroom_id
that should show the actual chatroom with messages.
The second route is within the first one, like this:
this.resource('chatrooms', function() {
this.route('show', {
path: ':chatroom_id'
});
});
When I access /chatrooms
, a call is made to the server (/api/chatrooms
) is a list of rooms is returned and displayed, like expected.
When I click a room, the application transitions to /chatrooms/id
, but no call is made to retrieve the messages (available at /api/chatrooms/id
), even when I try to define a model.
I have a similar scenario with the users. A list of users is retrieved, then displayed. When a name is clicked, the profile is shown. No second call is made, but that's okay since Ember knows everything about the user already.
In my current case, when a list is first returned, it includes all the information except the messages. I believe that would be too much otherwise (10 chatrooms * 100 last messages = 1000 elements in my JSON for each request). So I want to call the server for messages only when a chatroom is selected.
Do you know how to do it, or maybe there's something wrong I'm doing in the first place?
Aucun commentaire:
Enregistrer un commentaire