我有一个 ember.js 原型,到目前为止它运行良好。自从我上次部署以来,我一直收到错误 Uncaught TypeError: Cannot read property 'hash' of undefined。
app.js 文件
// Application
Welcome = Ember.Application.create({
ready : function() {
}
});
// Model
Welcome.Ticket = Ember.Object.extend({
id : null,
buyerPartyId : null,
name : null,
priority : null,
description : null,
comment : null
});
// Controller
Welcome.ticketsController = Ember.ArrayController.create({
content : [],
loadTickets : function() {
var self = this;
$.getJSON('url here', function(
data) {
for ( var i = 0; i < data.serviceRequest.length; i++) {
self.pushObject(Welcome.Ticket.create(data.serviceRequest[i]));
}
});
}
});
索引.html
<!doctype html>
<html>
<head>
<title>Ticket List</title>
<link rel="stylesheet" href="css/normalize.css">
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/libs/ember-0.9.5.min.js"></script>
<script src="js/app.js"></script>
</head>
<body>
<h1>Ticket List</h1>
<script type="text/x-handlebars">
{{#view Ember.Button target="Welcome.ticketsController" action="loadTickets"}}
Load Tickets
{{/view}}
{{#each contentBinding="Welcome.ticketsController" tagName="ul"}}
<b>{{content.id}}</b> - {{content.buyerPartyId}}, <i>{{content.name}}</i>
{{/each}}
</script>
</body>
</html>
我确信我忽略了一些简单的东西!任何建议,将不胜感激 !!
这是来自 Chrome 开发控制台的错误堆栈。
Uncaught TypeError: Cannot read property 'hash' of undefined ember-0.9.5.min.js:13
(anonymous function) ember-0.9.5.min.js:13
(anonymous function)
b.VM.template ember-0.9.5.min.js:9
Ember.View.Ember.Object.extend.render ember-0.9.5.min.js:12
Ember.View.Ember.Object.extend.renderToBuffer ember-0.9.5.min.js:12
Ember.View.Ember.Object.extend.createElement ember-0.9.5.min.js:12
Ember.View.states.preRender.insertElement ember-0.9.5.min.js:12
Ember.View.Ember.Object.extend.invokeForState ember-0.9.5.min.js:12
c ember-0.9.5.min.js:10
j ember-0.9.5.min.js:10
f.flush ember-0.9.5.min.js:10
f.end ember-0.9.5.min.js:10
Ember.run.end ember-0.9.5.min.js:10
i ember-0.9.5.min.js:10