本文介绍了Query-params在EmberJS 1.6.0中不更新URL或触发模型刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用查询参数在EmberJS中为日志列表界面开发搜索功能,但我无法使其工作。
根据此示例:我有:
I'm trying to develop a search feature for a log list interface in EmberJS using query-params but I can't get it to work.Based on this example: http://emberjs.jsbin.com/ucanam/2708/edit I have:
App.DashboardLogsRoute = Ember.Route.extend({
queryParams: {
search: {
refreshModel: true
}
},
model: function(params){
console.log(params.search)
if(params.search && params.search != '')
return Ember.$.getJSON("/logs.json?search=" + params.search);
else
return Ember.$.getJSON("/logs.json");
},
actions: {
queryParamsDidChange: function(){
this.refresh();
}
}
});
App.DashboardLogsController = Ember.ArrayController.extend({
queryParams: ["search"],
search: null,
searchText: Ember.computed.oneWay("search"),
actions: {
search: function(){
this.set("search", this.get("searchText"));
console.log(this.get("search"))
}
}
});
console.log(this.get(search))显示我提交的更改我的输入,但是URL都没有被更新,这个模型是不是刷新了?我错过了一些东西?
The console.log(this.get("search")) displays the changes that I submit on my input but neither the URL is updated, neither the model is refreshed... I'm missing something?
推荐答案
queryParams只能在当前的测试版中完全实现。有关详细信息,请参阅
The queryParams are only fully implemented in the current beta. For more information, see the current documentation
这篇关于Query-params在EmberJS 1.6.0中不更新URL或触发模型刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!