Permalink
Browse files

Modified URL creation for collections.

  • Loading branch information...
1 parent b2d827b commit 650ef2a37d88ac66048c6f814d164fcbb05f50f4 Brandon R. Stoner committed Jun 21, 2012
Showing with 16 additions and 1 deletion.
  1. +16 −1 src/collections.coffee
View
17 src/collections.coffee
@@ -1,4 +1,19 @@
class TastyPieCollection extends Backbone.Collection
+ url: (data) ->
+ if @models? and @models.length > 0
+ pull_id = (from) ->
+ to = from.split '/'
+ to = to[to.length - 2]
+
+ idList = _.pluck @models, 'id'
+ idList = _.reduce idList, (left, right) ->
+ return left + ';' + (pull_id right)
+ idList = pull_id idList
+
+ return @urlRoot + 'set/' + idList
+
+ @urlRoot
+
parse: (data) ->
if data? and data.meta?
@meta = data.meta
@@ -8,7 +23,7 @@ class TastyPieCollection extends Backbone.Collection
@factory = (model, endpoint) ->
class AutoTastyPieCollection extends TastyPieCollection
model: model
- url: endpoint
+ urlRoot: endpoint
window.TastyBone.Collection = TastyPieCollection

0 comments on commit 650ef2a

Please sign in to comment.