Sha256: eb23fcc141044189232599bdc32dc0ce6808c5c061546a02d0298d46d9b7eae2

Contents?: true

Size: 593 Bytes

Versions: 10

Compression:

Stored size: 593 Bytes

Contents

class @Select2Input.RelatedCollection extends Backbone.Collection

  comparator : 'position'

  initialize : () ->
    @on 'add', @addPosition
    @on 'relation-remove', @removeFromCollection

  addPosition : (model) ->
    model.set 'position', @length

  removeFromCollection : (model) =>
    @remove model
    @_triggerChange()

  resort : () ->
    @sort()
    @_triggerChange()

  update : (data) ->
    @add new Select2Input.RelatedModel(data), merge : true
    @_triggerChange()

  getData : () ->
    @map (model) -> model.getData()

  _triggerChange : () ->
    @trigger 'data-change'

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rademade_admin-0.2.2 app/assets/javascripts/rademade_admin/app/select2/related/collection.coffee
rademade_admin-0.2.1 app/assets/javascripts/rademade_admin/app/select2/related/collection.coffee
rademade_admin-0.2.0 app/assets/javascripts/rademade_admin/app/select2/related/collection.coffee
rademade_admin-0.1.6 app/assets/javascripts/rademade_admin/app/select2/related/collection.coffee
rademade_admin-0.1.5 app/assets/javascripts/rademade_admin/app/select2/related/collection.coffee
rademade_admin-0.1.4 app/assets/javascripts/rademade_admin/app/select2/related/collection.coffee
rademade_admin-0.1.3 app/assets/javascripts/rademade_admin/app/select2/related/collection.coffee
rademade_admin-0.1.2 app/assets/javascripts/rademade_admin/app/select2/related/collection.coffee
rademade_admin-0.1.1 app/assets/javascripts/rademade_admin/app/select2/related/collection.coffee
rademade_admin-0.1.0 app/assets/javascripts/rademade_admin/app/select2/related/collection.coffee