Javascript Emberjs模型查找方法未填充模板
我把我的路线设置为Javascript Emberjs模型查找方法未填充模板,javascript,ember.js,Javascript,Ember.js,我把我的路线设置为 # ROUTER MAPPING App.Router.map( -> this.resource("alertInstances", path:"/" ) this.resource("alertInstance", path:"/:alertInstance_id" ) ) # ALERT INSTANCES ROUTE App.AlertInstancesRoute = Ember.Route.extend( model
# ROUTER MAPPING
App.Router.map( ->
this.resource("alertInstances",
path:"/"
)
this.resource("alertInstance",
path:"/:alertInstance_id"
)
)
# ALERT INSTANCES ROUTE
App.AlertInstancesRoute = Ember.Route.extend(
model: ->
App.AlertInstance.all()
setupController: (controller, model) ->
controller.set("content", model)
)
# ALERT INSTANCE ROUTE
App.AlertInstanceRoute = Ember.Route.extend(
model: (params) ->
App.AlertInstance.find(params.alertInstance_id)
setupController: (controller, model) ->
controller.set("content", model)
)
当我转到路由“/”时,我会得到所有“警报实例”的列表,然后单击其中一个,它会显示单个“警报实例”的详细信息
我的模型对象设置如下
# ALERT INSTANCE MODEL
App.AlertInstance = Ember.Object.extend()
App.AlertInstance.reopenClass(
allAlertInstances: []
currAlertInstance:null
all: ->
@allAlertInstances = []
$.ajax
url:base + "api/alert_instances"
dataType: "JSON"
context:this
success: (response) ->
for i in response
i.clinical = if i.alert_type is "clinical" then true else false
@allAlertInstances.addObject App.AlertInstance.create(i)
@allAlertInstances
)
这一切都非常有效。但是,当用户直接转到“/10”(通过指定警报实例ID)时,由于没有从服务器检索到数据,因此没有显示任何内容
因此,我添加了以下“find”方法
但视图为空,不显示任何内容
我可以在我的Chrome控制台网络中看到,一个警报实例JSON对象确实已返回
有什么想法吗?使用“路线渲染”来渲染模板
App.AlertInstancesRoute = Ember.Route.extend({
render: function() {
this.render([<handlebar_name>], {
[outlet: <outlet_name>],
[into: <template_name_to_render_to>]
});
},
model: function(params) {
App.AlertInstance.all();
},
setupController: function(controller, model) {
controller.set("content", model);
}
})
App.AlertInstancesRoute=Ember.Route.extend({
render:function(){
这个.render([]{
[出口:],
[插入:]
});
},
型号:功能(参数){
App.AlertInstance.all();
},
设置控制器:功能(控制器、型号){
controller.set(“内容”,模型);
}
})
欲了解更多信息,请按
App.AlertInstancesRoute = Ember.Route.extend({
render: function() {
this.render([<handlebar_name>], {
[outlet: <outlet_name>],
[into: <template_name_to_render_to>]
});
},
model: function(params) {
App.AlertInstance.all();
},
setupController: function(controller, model) {
controller.set("content", model);
}
})