Skip to content

Instantly share code, notes, and snippets.

@psykidellic
Created July 24, 2013 19:10
Show Gist options
  • Select an option

  • Save psykidellic/6073525 to your computer and use it in GitHub Desktop.

Select an option

Save psykidellic/6073525 to your computer and use it in GitHub Desktop.
_ = require('underscore')
Backbone = require('backbone')
data =
id: 1
queue_items: [
id: 1
song:
id: 1
name: 'song 1'
,
id: 2
name: 'song 2'
,
id: 2
song:
id: 3
name: 'song 3'
,
id: 4
name: 'song 4'
]
class Song extends Backbone.Model
class QueueItem extends Backbone.Model
initialize: ->
console.log("queueitem called")
@song = new Song(@get('song'))
class QueueItems extends Backbone.Collection
model: QueueItem
class Queue extends Backbone.Model
initialize: ->
console.log("initialize called")
@items = new QueueItems(@get('queue_items'))
queue = new Queue(data)
# console.log(queue.get('queue_items'))
@bewest

bewest commented Jul 24, 2013

Copy link
Copy Markdown

Might do:

initialize: ->
  @queueItems(@get('queue_items'))
qeueueItems: (_q) ->
  if (_q)
    @_queueItems = _q
  return @_queueItems

So you can swap them out later if you change your mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment