モデルの新しいインスタンスをインスタンス化すると、常にエラーが発生します。誰でもエラーをスパイできますか?
Uncaught TypeError: Object [object Object] has no method 'apply'
脚本:
(function() {
var Ticket = new Backbone.Model.extend({
urlRoot: "/api/tickets",
Subject: "",
Created: null
});
var TicketView = new Backbone.View.extend({
Model: Ticket,
el: "body",
render: function() {
return this.$el.html(this.Model.Subject);
}
});
// Error here
var t = new Ticket();
var tv = new TicketView({ model: t });
tv.render();
})()
HTML:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.2/underscore-min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js" type="text/javascript"></script>
</head>
<body>
<div>
<div id="Main">Main</div>
</div>
<script type="text/javascript" src="/Scripts/Home_Index.js"></script>
</body>
</html>