dimanche 26 avril 2015

Ember : Two route for one template

I'm new with Ember and i try to make a simple CRUD. I want a single template for adding and editing of an object.

This is my code :

this.route('foos', {path: '/foos_path'}, function() {
            this.route('edit',{path: '/edit/:foo_id'});
            this.route('add',{path: '/add'});
            this.route('index');
        });

The add function work great but i can't make working the edit function. This is my edit route.

import Ember from 'ember';

export default Ember.Route.extend({
    title : '',
    model: function(params) {
        this.store.find('foo', params.foo_id).then(function(foo) {
            console.log(this, this.get('title'));
            this.set('title', foo.title);
        });
    },


    renderTemplate: function() {
        this.render('foos.add', {
           into: 'foos',
           controller: 'foos.add'
        });
        this.render('foos/add');
    }
});

Any help would be great :)




Aucun commentaire:

Enregistrer un commentaire