Marionette: childViewContainer was not found
Marionette: childViewContainer was not found
我正在努力学习如何将Marionette与Backbone一起使用。我不确定为什么会出现以下错误:Uncaught ChildViewContainerMissingError: The specified "childViewContainer" was not found: ul
这是我的密码:http://jsfiddle.net/e7L822c8/
这是我的JavaScript:
window.App = new Backbone.Marionette.Application();
App.addRegions({
mainRegion: '.js-page'
});
App.start();
var TheModel = Backbone.Model.extend({});
var TheCollection = Backbone.Collection.extend({
model: TheModel,
});
var ListView = Backbone.Marionette.CompositeView.extend({
tagName: 'div',
className: 'js-list-container',
template: _.template( '#ListViewTemplate' ),
childViewContainer: 'ul',
childView: ItemView
});
var ItemView = Backbone.Marionette.ItemView.extend({
initialize: function() {
console.log('this.model =',this.model);
console.log(this);
},
tagName: 'li',
className: 'list-item',
template: _.template( '#ItemViewTemplate' )
});
var dataArray = [
{"name":"FirstObject"},{"name":"SecondObject"},{"name":"ThirdObject"}
];
var theCollection = new TheCollection(dataArray);
var listView = new ListView({collection: theCollection});
App.mainRegion.show(listView);
这是我的HTML:
<div class="js-page">
</div>
<script type="text/template" id="ListViewTemplate">
<h3>Here is a list</h3>
<ul class="js-list">
</ul>
</script>
<script type="text/template" id="ItemViewTemplate">
Display List Item here
</script>
代码中有两个问题:
- 在js代码中,必须在ListView之前定义ItemView
-
js无法访问代码中的模板
template:_.template('#ListViewTemplate'),
如果将ListViewTemplate替换为其内容:
template: _.template( "<h3>Here is a list</h3><ul class='js-list'></ul>" ),
检查jsfiddle是否有效:http://jsfiddle.net/pwassqww/2/
所以问题出在你的模板定义上。
相关文章:
- JavaScript文件在IIS上返回404 Not Found
- react-css-module module not found
- grails3 jquery not found
- GeckoFX JSContext not found C#
- Marionette: childViewContainer was not found
- Js not found spring mvc
- Ajax POST MyUrl 404 (Not Found)
- 节点webkit中的Require('jquery ui')产生navigator not found错
- xmlhttp.send() returns 404 Not Found (Ajax)
- Socket.io.js not found (node.js + express + socket.io)
- Module not found: Error: Cannot resolve module 'fs'
- 状态码:404 Not Found (from cache) |使用AngularJS的混合型应用
- not found error: DOM exception 8
- Systemjs and tsc setup - *.ts.js 404 (Not Found) Error
- Angular2材质设计alpha.9-3有'404 not found'@angular /材料
- Laravel Routes/jQuery $.post() returning 404 Not Found
- http://localhost/undefined 404 (Not Found)
- /bin/sh not found -- spawnSync
- 节点路由器.delete函数返回404 Not Found
- Angular2 + ag-Grid无法加载ag-Grid -ng2/main.js (404 Not Found)