このコードを実行しようとしていますが、次のエラーが表示されます: Uncaught TypeError: string is not a function
at line where is written :var html = template(context);
誰か理由を知っていますか?
見る
define(["jQuery", "underscore", "Backbone", "Handlebars","models/person" ,"text!templates/userlistview.html"],
function($, _, Backbone, Handlebars,Person, template) {
var UserListView = Backbone.View.extend({
template: Handlebars.compile(template),
render: function() {
var context = JSON.parse(JSON.stringify(this.model));
console.log(context);
var html = template(context);
$(this.el).html(html);
return this;
}
});
return UserListView;
});
ルーター
define(["jQuery", "underscore", "Backbone", "collections/usercollection", "models/person", "views/userlistview"],
function($, _, Backbone, Usercollection, Person, UserListView) {
var AppRouter = Backbone.Router.extend({
routes: {
"": "list",
},
list: function() {
this.utenti= new Person({name:"stefano",cognome:"magli"});
this.page= new UserListView({model:this.utenti});
this.page.render();
}
});
return AppRouter;
});