最近,Emberjs 升级到了 1.0.0 版本。我对控制器进行了更改以符合一些新的更改,
App.UsersController = Ember.ObjectController.extend({
actions : {
filteredContent : function() {
var searchText = this.get('searchText'), regex = new RegExp(searchText, 'i');
return this.get('model').filter(function(item) {
return regex.test(item.name);
});
}.property('searchText', 'model')
}
});
这与文本框相关联,
{{input type="text" value=searchText}}
但我仍然不断得到这个:
DEPRECATION: Action handlers contained in an `events` object are deprecated in favor of putting them in an `actions` object (error on <Ember.Route:ember189>)
at Object.triggerEvent (http://ember.local/js/libs/ember.js:30519:13)
at trigger (http://ember.local/js/libs/ember.js:29641:16)
at handleError (http://ember.local/js/libs/ember.js:29903:9)
at invokeCallback (http://ember.local/js/libs/ember.js:8055:19)
at null.<anonymous> (http://ember.local/js/libs/ember.js:8109:11)
at EventTarget.trigger (http://ember.local/js/libs/ember.js:7878:22)
at http://ember.local/js/libs/ember.js:8180:17
at Object.DeferredActionQueues.flush (http://ember.local/js/libs/ember.js:5459:24)
at Object.Backburner.end (http://ember.local/js/libs/ember.js:5545:27) ember.js:394
Error while loading route:
Object {readyState: 4, getResponseHeader: function, getAllResponseHeaders: function, setRequestHeader: function, overrideMimeType: function…}
ember.js:394
Uncaught #<Object>
我在这里可能做错了什么?
此外,如果有人感兴趣,这里是完整的 App.js,https: //gist.github.com/ankurkaushal/55dd21838acb0dd3fb10
这是完整的 HTML:
<script type="text/x-handlebars" data-template-name="users">
{{input type="text" value=searchText}}
{{#each item in filteredContent }}
<tr><td>
{{#link-to 'user' item}} <p>{{item.name}}</p>{{/link-to}}
</td></tr>
{{/each}}
{{outlet}}
</script>
<script type="text/x-handlebars">
<h1>Application Template</h1>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="user">
<h2>
{{email}}
</h2>
</script>