使用Backbone.View我以这种方式获取外部模板(1)
如果我想使用Backbone.Marionette.Layout从外部文件获取模板怎么办? (2)
(1)
define(['myTemplate.html'], function (myTemplate) {
var MyView = Backbone.View.extend({
render: function ()
{
this.$el.html(myTemplate, this.getView());
}
});
return MyView;
});
(2)
define(['myTemplate.html'], function (myTemplate) {
var Layout = Backbone.Marionette.Layout.extend({
template: "#container",
regions: {
top: "#top",
main: "#main"
}
});
return Layout;
});
答案 0 :(得分:2)
看看这个:https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs
this.$el.html(myTemplate, this.getView());