0
votes

My Routes

NoteApp.Router.reopen
    location: 'history'
    rootURL: '/'

NoteApp.Router.map ->
   @resource 'notes', path: "/", ->
       @route 'new', path: "/new"

NoteApp.NotesRoute = Ember.Route.extend
    model: ()->
        return @store.find('note')

NoteApp.NotesNewRoute = Ember.Route.extend
    renderTemplate: (controller, model) ->
        @render 'notes/new', into: "application"

My NotesNewController is:

NoteApp.NotesNewController = Ember.ObjectController.extend
    actions:
        createNote: ->
            title = @get('newTitle')
            note = @store.createRecord('note',
                title: title
            )

            note.save()
            @set('newTitle', '')
            @transitionToRoute('notes')

First problem: I can't use browser back button after navigate to /new route

Second problem: @transitionToRoute('notes') not working. Simply render blank page.

1

1 Answers

1
votes

You're overwriting the notes template when you manually render into the application outlet. This is where all of your problems are coming from.

If you want the url /notes to show something, then not be visible when you are on /notes/new you should add that to your notes/index template.

So in a nutshell, I'm suggesting these things.

Comment this out

NoteApp.NotesNewRoute = Ember.Route.extend
    //renderTemplate: (controller, model) ->
        //@render 'notes/new', into: "application"

Move notes template to notes/index

Make sure your notes template has {{outlet}} in it