こんにちは、require.js と backbone.js の初心者です。開発プログラミングの助けが必要です。
私はコードを持っています:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scaleable=no">
<link rel="stylesheet" href="css/jquery.mobile.structure-1.3.1.min.css" />
<link rel="stylesheet" href="css/themes/red.min.css" />
<link rel="stylesheet" href="css/menu.css" />
<link rel="stylesheet" href="css/table.css" />
<script>
curl = {
apiName: 'require'
};
</script>
<script src="js/libs/amd/require.js"></script>
<script src="js/bootstrap.js"></script>
</head>
<body>
<div data-add-back-btn="true" data-role="page" id="accountenquiry" data-url="/accountenquiry"> </div>
</body>
</html>
ビュー/アカウント照会/AccountEnquiryView.js
define([
'underscore',
'backbone',
'text!templates/account-enquiry/accountenquiry.html'
], function(_, Backbone, tmpl){
var serverUrl = 'http://localhost/agro-rib-mobile/restful/crud/get_all_accounts.php';
Account = Backbone.Model.extend({
urlRoot: serverUrl,
parse: function(response) {
console.log(response);
return response;
},
defaults: {
ACCOUNT_ID: null,
ACCOUNT_TYPE: '',
FULL_NAME: '',
ACCOUNT_NUMBER : '',
CURRENT_BALANCE: 0
}
});
var AccountCollection = Backbone.Collection.extend({
model:Account,
urlRoot: serverUrl,
parse: function(response) {
console.log(response);
return response;
}
});
var AccountEnquiryView = Backbone.View.extend({
el: '#accountenquiry',
template: _.template(tmpl),
initialize:function () {
console.log('Initializing Account Enquiry');
},
render: function() {
var AccountsCollection = Backbone.Collection.extend({
model : Account,
url: serverUrl,
parse: function(response) {
console.log(response);
return response;
}
});
var accounts = new AccountsCollection;
accounts.fetch();
//console.log(accounts.toJSON());
$(this.el).html(this.template(accounts.toJSON()));
return this;
}
});
return AccountEnquiryView;
});
templates/account-enquiry/accountenquiry.html
<!-- Start of second page: two -->
<div data-role="header">
<h1>Account Enquiry</h1>
</div><!-- /header -->
<div data-role="content" data-theme="a">
<p>All Account</p>
<table border="1" cellpadding="5" cellspacing="0" width="100%" class="ui-responsive" id="my-table" data-role="table" data-mode="columntoggle" >
<thead>
<tr>
<th width="50%">Account</th>
<th width="50%">Current Balance</th>
</tr>
</thead>
<tbody>
<% _.each(accounts, function(account) { %>
<tr>
<td>
<span><strong>Current Account(s)</strong></span><br>
<a class="detail" href="#/accountdisplay">
<%= account.FULL_NAME %> </a><br>
<span>19710257104</span>
</td>
<td>RM1,411,421,532</td>
</tr>
<% }); %>
</tbody>
</table>
</div>
なぜこのエラーが発生したのですか? 参照エラー {}