Ember视图未显示

时间:2012-10-10 08:47:56

标签: ember.js

我正在关注本教程http://www.adobe.com/devnet/html5/articles/flame-on-a-beginners-guide-to-emberjs.html

并且无法显示ReviewTextArea视图。

到目前为止我的代码是:

的index.html

<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.6.min.js"></script>
    <script src="js/app.js"></script>
</head>
<body>

<script type="text/x-handlebars">
    Hello <b>{{Songs.mixmaster}}</b>
</script>   

<script type="text/x-handlebars">
    {{view Songs.ReviewTextArea}}
</script>   

</body>
</html>

app.js

Songs = Em.Application.create({
    mixmaster: 'Andy',
    totalReviews: 0,
    ready: function() {
        alert('Ember sings helloooo');
    }
});

Songs.Song = Em.Object.extend({
    title: null,
    artist: null,
    genre: null,
    listens: 0
});


mySong = Song.create({
    title: 'Son of the Morning',
    artist: 'Oh, Sleeper',
    genre: 'Screamo'
});


Songs.ReviewTextArea = Em.TextArea.extend({
    placeholder: 'Enter your review',
});

但是,我的浏览器(Chrome 22.0.1229.92)仅显示页面中的原始{{view ...}}标记(使用Inspect Element)。

关于为什么这不起作用的任何想法?

1 个答案:

答案 0 :(得分:2)

您的代码出错 - 未定义歌曲。

mySong = Song.create({
   title: 'Son of the Morning',
   artist: 'Oh, Sleeper',
   genre: 'Screamo'
});

应为Songs.Song