我想从事件处理程序访问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>