2
我裝盤遷移我的骨幹木偶應用程序,但我在路由的錯誤:骨幹木偶路由
window.App = new Backbone.Marionette.Application
Models: {}
Collections: {}
Views:
Layouts: {}
Routers: {}
layouts: {}
Helpers: {}
init: ->
App.start()
App.main.show(App.layouts.main)
App.addRegions
main: '#container'
App.addInitializer (options) ->
new App.Routers.Profiles()
Backbone.history.start()
$(document).ready ->
App.init()
這是我的路由器
class App.Routers.Profiles extends Backbone.Marionette.AppRouter
routes:
'profiles/:id': 'show'
show: (id) ->
@profile = new App.Models.Profile(id: id)
view = new App.Views.ProfilesShow(model: @profile)
@profiles = new App.Collections.Profiles(@profile)
@profile.fetch()
App.layout.content.show(view)
這是我的查看
class App.Views.ProfilesShow extends Backbone.Marionette.ItemView
template: JST['profiles/show']
initialize: ->
@model.on('change', @render, @)
render: ->
$(@el).html(@template(profile: @model))
@
這是我的主要佈局
class App.Views.Layouts.Main extends Backbone.Marionette.Layout
template: JST['layouts/main']
regions:
content: '#content'
App.addInitializer ->
App.layouts.main = new App.Views.Layouts.Main()
當我試圖表明該行App.layout.content.show(視圖)的佈局來看,我有一個消息錯誤:「類型錯誤:應用程序。佈局未定義「。我不知道我是否在做一個好的練習。