0

最近,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>
4

1 回答 1

3

为什么你有filteredContent一个actions哈希呢?它是一个计算属性,因此不应该在actions散列中。

尝试在哈希filteredContent之外移动。actions

希望能帮助到你。

于 2013-09-06T22:13:05.833 回答