Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4837

Modelling a tennismatch. Can I nest child routes under an unsaved parent?

$
0
0

@davegoulash wrote:

Hi,

I'm trying to model a tennismatch in Ember. I have the datamodel, it looks right, but what about these routes?

Router.map(function() {
  this.route('matches', function() {
    this.route('new', function () {
      this.route('set', { path: 'sets/:set_nr' }, function () {
        this.route('game', { path: 'games/:game_nr' }, function () {
          this.route('point', { path: 'points/:point_nr' })
        });
      });
    });
  });
});

This seems right to me. As I drill down the URLs I see the correct screens. But what should I do when a button takes the user from /matches/new to /matches/new/sets/1/games/1/points/1

Am I hugely overengineering here? It sure smells that way.. Should I even try to nest all these routes under an unsaved Match instance? In other words, is /new only ever supposed te be the last part of a URL?

Perhaps I should just have a big fat component at /match/new and never leave that URL until the match is saved.

I think I can get away with this route structure though but I will need to be able to fetch the new Match (let's assume there can be only new Match instance at a time). But how would I get that instance from the child routes?

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4837

Trending Articles