2
我想弄清楚如何最好的方法创建一个方法来拉特定对象的基础上使用Ember.js属性。Ember.js - 如何过滤模型?
现在我的模型看起来是这样的:
App.Resume = Ember.Object.extend()
App.Resume.reopenClass
store: {}
findAll: ->
arr = Ember.ArrayProxy.create()
if xhr
xhr.abort()
return
xhr = $.ajax(
url: '../json/cv.json'
dataType: 'json'
timeout: 10000
).done (response) =>
response.users.forEach (user, i) =>
cv = @findOne(user.personId)
cv.setProperties(user)
return
values = (values for keys, values of @store)
arr.set('content', values)
arr
findOne: (id) ->
cv = @store[id]
if not cv
cv = App.Resume.create
id: id
@store[id] = cv
cv
如果你看一下循环的完成回调中,你会看到,它正在使用user.id创建模型 - 还有一个user.specialization字段。这是我希望能够过滤的字段。
任何想法/帮助将不胜感激!
谢谢!
丰富