0
我正在做以下操作,但我無法從方法searchAgain
和removeUser
中的上下文中檢索this
obj。這是我正在採取的示例http://www.adobe.com/devnet/html5/articles/flame-on-a-beginners-guide-to-emberjs.html在Ember中如何從ArrayController中刪除對象
<div id="recent">
<h3>Recent Users</h3>
<ol>
{{#each App.recentUsersController.reverse}}
<li>
<a href="#" title="view again" {{action "searchAgain" target="App.recentUsersController"}}>{{this}}</a> -
<a href="#" title="remove" {{action "removeUser" target="App.recentUsersController"}}>X</a>
</li>
{{/each}}
</ol>
</div>
App.recentUsersController = Em.ArrayController.create({
content: [],
addUser: function(name) {
if (this.contains(name)) this.removeObject(name);
this.pushObject(name);
},
removeUser: function(view){
alert(view.context);
this.removeObject(view.context);
},
searchAgain: function(view){
alert(view.context);
App.tweetsController.set('username', view.context);
App.tweetsController.loadTweets();
},
reverse: function(){
return this.toArray().reverse();
}.property('@each')
});
view.context
裏面的SearchAgain
和removeUser
給我未定義。有人可以幫助我嗎?