Tuesday, 10 September 2013

Backbone.js- I got this error message ReferenceError {}

Backbone.js- I got this error message ReferenceError {}

hello i am newbie in require.js and backbone.js i need u help for my
development programming..
i have code in :
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 id="menu">
<h3>Menu</h3>
<ul>
<li><a href="" class="contentLink">Home </a></li>
<li><a href="" class="contentLink">About </a></li>
<li><a href="" class="contentLink">Portfolio </a></li>
<li><a href="" class="contentLink">Contact </a></li>
</ul>
</div>-->
<div data-role="page" id="login" data-url="/login"> </div><!-- /page
login -->
<div data-role="page" id="main" data-url="/main"> </div><!-- /page main -->
<div data-add-back-btn="true" data-role="page" id="accountenquiry"
data-url="/accountenquiry"> </div><!-- /page account enquiry -->
<div data-add-back-btn="true" data-role="page" id="accountdisplay"
data-url="/accountdisplay" > </div><!-- /page account display -->
<div data-add-back-btn="true" data-role="page" id="fundtransferlist"
data-url="/fundtransferlist" > </div><!-- /page fundtransferlist -->
<div data-add-back-btn="true" data-role="page" id="ownfundtransfer"
data-url="/ownfundtransfer" > </div><!-- /page ownfundtransfer -->
<div data-add-back-btn="true" data-role="page" id="newthirdpartydetail"
data-url="/newthirdpartydetail" > </div><!-- /page newthirdpartydetail
-->
<div data-role="page" id="two" data-url="/two" > </div>
</body>
</html>
views/account-enquiry/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>
Why i got this error? ReferenceError {}

No comments:

Post a Comment