Backbone と Require JS の両方が初めてです。
次のエラーが表示されます。
未定義のプロパティ ビューを読み取れません。
したがって、バックボーンは利用できませんが、どこに問題があるのか わかりません。どんな助けでも大歓迎です。
次の3つのファイルがあります。
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<script data-main="boot" src="../libs/require/require.js"></script>
</head>
<body>
<div id="main">Magic!</div>
</body>
</html>
boot.js:
require.config({ baseUrl: "../", paths: { jquery : "libs/jquery/jquery-1.8.3.min", underscore : "libs/underscore/underscore-min", backbone : "libs/backbone/backbone-min" } }); require( [ "app/views/app" ], function(AppView) { var app = new AppView(); });
app.js:
define([
"jquery",
"underscore",
"backbone"
], function( $, _, Backbone ) {
var AppView = Backbone.View.extend({
el: $( "#main" ),
initialize: function () {
this.render();
},
render: function() {
this.el.html("huzzah!");
}
});
return AppView;
});