Skip to content

Instantly share code, notes, and snippets.

@bttmly
Last active August 29, 2015 14:05
Show Gist options
  • Save bttmly/ca5d2e2e16081805c5cb to your computer and use it in GitHub Desktop.
Save bttmly/ca5d2e2e16081805c5cb to your computer and use it in GitHub Desktop.
class Bill extends Backbone.Model
initialize: ( id ) ->
@id = id;
@_when = $.when( @getAmendments(), @getVotes() )
then: ( callback ) ->
@_when.then( callback )
@
getAmendments: ->
$.ajax( "/api/bills/#{ @id }/amendments" ).then ( data ) =>
@amendments = new Amendments( data.results )
getVotes: ->
$.ajax( "/api/bills/#{ @id }/votes" ).then ( data ) =>
@votes = new Votes( data.results )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment