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字段。這是我希望能夠過濾的字段。
任何想法/幫助將不勝感激!
謝謝!
豐富