我想从事件处理程序访问 parentView,但是当我单击子视图文本时,我收到 this.parentView 未定义的错误?event.view.parentView 也不起作用。
<html>
<head>
</head>
<body>
<script src="js/libs/jquery-1.9.1.js"></script>
<script src="js/libs/handlebars-1.0.0-rc.3.js"></script>
<script src="js/libs/ember-1.0.0-rc.2.js"></script>
<script>
App = Ember.Application.create();
App.ChildView = Ember.View.extend({
template : Ember.Handlebars.compile("Child View {{ view.elementId }} parent={{ view.parentView.elementId}}"),
click:function(event){
alert("parent="+this.parentView.elementId);
}
});
App.TopView = Ember.View.extend({
template : Ember.Handlebars.compile("Top View {{ view.elementId }} {{ view App.ChildView }}")
});
var v = App.TopView.create();
v.append();
</script>
</body>
</html>