将 Backbone.Marionette LayoutView 正确附加到应用程序
Properly Attaching a Backbone.Marionette LayoutView to the Application
我正在尝试使用 marionette inspector, but the inspector can not find my views, presumably because they are not properly attached to the Application。我需要做什么才能将 Backbone.Marionette.LayoutView
的实例注册到 Backbone.Marionette.Application
的实例?
这是我当前的代码(在 coffeescript 中),它没有正确附加视图:
App = Backbone.Marionette.Application.extend({
initialize: (options) ->
console.log("App Initialized")
LayoutView = Backbone.Marionette.LayoutView.extend({
el: '#app'
template: (data) ->
return "<section>
<navigation id='menu'>...</navigation>
<article id='content'>...</article>
</section>"
regions:
menu: "#menu"
content: "#content"
})
layoutView = new LayoutView()
layoutView.render()
sampleModel = new Backbone.Model(name: "test")
});
app = new App({container: '#app'})
app.start()
marionette-inspector github page.
的热心人士回答了问题
App = Backbone.Marionette.Application.extend({
initialize: (options) ->
console.log("App Initialized")
LayoutView = Backbone.Marionette.LayoutView.extend({
el: '#app'
template: '#main_template'
regions:
menu: "#menu"
content: "#content"
})
@rootView = new LayoutView()
我正在尝试使用 marionette inspector, but the inspector can not find my views, presumably because they are not properly attached to the Application。我需要做什么才能将 Backbone.Marionette.LayoutView
的实例注册到 Backbone.Marionette.Application
的实例?
这是我当前的代码(在 coffeescript 中),它没有正确附加视图:
App = Backbone.Marionette.Application.extend({
initialize: (options) ->
console.log("App Initialized")
LayoutView = Backbone.Marionette.LayoutView.extend({
el: '#app'
template: (data) ->
return "<section>
<navigation id='menu'>...</navigation>
<article id='content'>...</article>
</section>"
regions:
menu: "#menu"
content: "#content"
})
layoutView = new LayoutView()
layoutView.render()
sampleModel = new Backbone.Model(name: "test")
});
app = new App({container: '#app'})
app.start()
marionette-inspector github page.
的热心人士回答了问题App = Backbone.Marionette.Application.extend({
initialize: (options) ->
console.log("App Initialized")
LayoutView = Backbone.Marionette.LayoutView.extend({
el: '#app'
template: '#main_template'
regions:
menu: "#menu"
content: "#content"
})
@rootView = new LayoutView()