我在控制台中收到以下错误消息:
http://localhost/web/js/text.js
404 Not Found
如果一个删除文本!在“text!templates/collector/indexTemplate.html”表单collector_index.js中,我收到以下错误消息:
http://localhost/web/js/templates/collector/indexTemplate.html.js
404 Not Found
main.js
require.config({
paths: {
html5shiv: "libs/html5shiv",
jquery: "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min",
jqueryui: "http://code.jquery.com/ui/1.10.3/jquery-ui",
tablesorter: "libs/jquery.tablesorter.min",
script: "script",
underscore: "libs/underscore.min", /*"http://underscorejs.org/underscore",*/
backbone: "libs/backbone.min", /*"http://backbonejs.org/backbone-min",*/
utils: "utils",
// Collector
collectorModel: "models/collectorModel",
collectorCollection: "collectorCollection",
collectorRouter: "collectorRouter",
// Views
index: "views/collector/collector_index",
row: "views/collector/collector_row",
},
shim: {
jqueryui: {
deps: ["jquery"],
exports: "Jqueryui"
},
tablesorter: {
deps: ["jquery"],
exports: "TableSorter"
},
script: {
deps: ["jquery"],
exports: "Script"
},
underscore: {
exports: "_"
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
}
}
});
require(....
索引模板.html
<script type="text/template" id="indexTemplate">
<table class="tables">
<thead>
<tr>
<th>Name</th>
<th>Role</th>
</tr>
</thead>
<tbody></tbody>
</table>
<a class="btns" href="#collector/new">New Collector</a>
</script>
收集器索引.js
define([
"backbone",
"underscore",
"row",
"text!templates/collector/indexTemplate.html"
], function (Backbone, _, CollectorRowView) {
var CollectorIndexView = Backbone.View.extend({
initialize: function (options) {
this.collectors = options.collectors;
this.collectors.bind('reset', this.addAll, this);
},
// populate the html to the dom
render: function () {
this.$el.html($('#indexTemplate').html());
this.addAll();
return this;
},
addAll: function () {
// clear out the container each time you render index
this.$el.find('tbody').children().remove();
_.each(this.collectors.models, $.proxy(this, 'addOne'));
},
addOne: function (collector) {
var view = new CollectorRowView({collectors: this.collectors, collector: collector});
this.$el.find("tbody").append(view.render().el);
}
});
return CollectorIndexView;
});
目录结构:
js
views
main.js
...
templates
collector
indexTemplates.html
main.js
谢谢。