JeremyC
JeremyC

Reputation: 341

Trouble rendering view associated with nested route in ember

I am having trouble with ember.js. Using the following routing setup I can not get the entries/new route to work. The index works fine but the entries/new template just refuses to render. I think it is where I am trying to render the view inside renderTemplate but I'm not sure what I'm doing incorrect. Your help would be much appreciated.

Journal.Router.map ->
    @resource 'entries', {path: '/' }, ->
        @route 'new'
        return
    return

Journal.EntriesNewRoute = Ember.Route.extend
    renderTempalte: ->
        @render 'entriesNew', {
            into: 'application'
        }
    setupController: (controller) ->
        controller.set 'heading', 'new entry'
        return

Journal.EntriesNewView = Ember.View.extend
    className: ['entries-new']
    templateName: 'entries/new'

Journal.EntriesNewController = Ember.Controller.extend
    heading: "New Journal Entry"

    createEntry: ->
        title = @get 'newTitle'
        content = @get 'newContent'

        if !title.trim()  and !content.trim() then return null

        Journal.Entry.createRecord
            title: title
            content: content

        @get('store').commit()
        return

And the entries/new template

{{ heading }}

{{view Ember.TextField id="entry-title" placeholder="Enter a title" valueBinding="newTitle"}}

{{view Ember.TextArea id="entry-content" placeholder="What do you have to say?" valueBinding="newContent"}}

<button {{action "createEntry"}} class="save">Save</button>

Upvotes: 0

Views: 191

Answers (1)

Jordy Kirkman
Jordy Kirkman

Reputation: 180

In your route, the 'into' should target the route that has your {{outlet}}

renderTempalate: ->
    @render 'entriesNew', {
        into: 'entries'
    }

Though the renderTemplate hook's default action is to render into it's resources outlet, so as long as your Entries template has an {{outlet}} in it and your obeying the strict naming conventions, you don't need to define that hook at all.

If that's not the issue maybe post your Entries template

Upvotes: 2

Related Questions