Files
dss/static/js/app/models/notifications/notificationCollection.coffee
2013-07-17 16:02:38 +01:00

22 lines
944 B
CoffeeScript

define ['backbone', 'vent', 'models/notifications/notificationItem', 'app.lib/backbone.dss.model.collection'], \
(Backbone, vent, NotificationItem, DssCollection) ->
class NotificationCollection extends DssCollection
model: NotificationItem
url:com.podnoms.settings.urlRoot + "notification/"
limit: 5
initialize: ->
@listenTo vent, "model:notification:new", (url) =>
console.log("NotificationCollection: notification:new")
item = new NotificationItem()
item.fetch
url: url,
success: (response) =>
console.log("NotificationCollection: item fetched")
console.log(response)
@add response
comparator: (item)->
-item.id
NotificationCollection