Javascript 将模型更改绑定到EmberJS中的视图

Javascript 将模型更改绑定到EmberJS中的视图,javascript,ember.js,Javascript,Ember.js,我正试图用EmberJS实现一个日志记录器的接口,这很好,但我遇到了麻烦 目前我有以下代码: logs.hbs ... {{input action="search" onEvent="keypress" value=searchText class="search" placeholder="Search"}} ... <table id="log" class="log"> <thead> <th>Service</th>

我正试图用EmberJS实现一个日志记录器的接口,这很好,但我遇到了麻烦

目前我有以下代码:

logs.hbs

...
{{input action="search" onEvent="keypress" value=searchText class="search" placeholder="Search"}}
...
<table id="log" class="log">
    <thead>
        <th>Service</th>
        <th>Start Time</th>
        <th>End Time</th>
        <th>URL</th>
        <th>Method</th>
        <th>User</th>
        <th>Response Code</th>
    </thead>
    <tbody>
        {{render "dashboard/logTableLine" model}}
    </tbody>
</table>
...
我的问题是将该模型绑定到视图,这样在对服务器进行搜索调用之后,视图就会重新加载。我想搜索所有数据,而不仅仅是界面中的数据(最后100条记录)

那么,第一个问题:为什么视图没有更新(绑定)到模型? 第二:有没有更好的方法(最佳实践)来做到这一点


提前感谢您的帮助。

现在您正在实施搜索,而不会触发重新路由。因此,如果用户搜索,然后想在搜索前返回页面,他们将没有办法这样做。您要做的是将用户重新路由到同一页面,但传入查询参数。然后在模型函数中,您可以看到传入了哪些参数,并相应地获取数据。Ember最新也是最棒的方法是查询参数特性:它已经开发了一段时间,现在已经是beta版了。我会尝试一下,因为这是一种非常干净、直观的解决问题的方法。祝你好运

首先,谢谢你的帮助。我确实听从了你的建议,并遵循了这个示例:我更改了代码,实际上与示例相同,我的变量工作正常,但url没有更新。我的代码:注意:console.log显示变量的正确值,即我输入到搜索中的更改。我的ember版本是1.6.0。。。所以与添加的新问题不同的问题:
{{#each model}}
    {{#link-to "dashboard.log" _id tagName="tr"}}
        <td>{{ServiceID}}</td>
        <td>{{DateString StartTime}}</td>
        <td>{{DateString EndTime}}</td>
        <td>{{URL}}</td>
        <td>{{Method}}</td>
        <td>{{AuthName Auth}}</td>
        <td>{{StatusCode}}</td>
    {{/link-to}}
{{/each}}
App = Ember.Application.create({
    LOG_TRANSITIONS: true,
    LOG_TRANSITIONS_INTERNAL: true
});

App.Router.map(function(){
    this.resource("dashboard", { path: "/" }, function(){
        this.route("logs", { path: "/logs" });
        this.route("log", { path: "/logs/log/:_id" });
    });
});

App.DashboardLogsRoute = Ember.Route.extend({
    model: function(){
        return Ember.$.getJSON("/logs.json");
    },
    actions: {
        search: function(value){
            if(value != '')
                this.set("content", Ember.$.getJSON("/logs.json?search=" + value));
        }
    }
});

App.DashboardLogRoute = Ember.Route.extend({
    model: function(params){
        return Ember.$.getJSON("/logs/log/" + params._id + ".json");
    }
});