Sha256: b4724178d87b1fa35b21b05316a4ec0e9a6fc8b2a2d5d3c3fae04d574db8b0ef
Contents?: true
Size: 1000 Bytes
Versions: 10
Compression:
Stored size: 1000 Bytes
Contents
class @Select2Input.RelatedCollectionView extends Backbone.View initialize : (options) -> @collection.on 'add', @appendRelatedView @_views = options.views appendRelatedView : (model) => view = new Select2Input.RelatedView model : model @$el.append view.render().$el @_views.push view initSort : () -> @$el.disableSelection() if @$el.data('sortable') @$el.sortable stop : () => $children = @$el.children() _.each @_views, (view) => view.model.set 'position', $children.index(view.$el) + 1 @collection.resort() @init : ($list) -> views = [] collection = new Select2Input.RelatedCollection $list.find('li').each () -> relatedView = Select2Input.RelatedView.init $(this) views.push relatedView collection.add relatedView.model collectionView = new this collection : collection el : $list views : views collectionView.initSort() collectionView
Version data entries
10 entries across 10 versions & 1 rubygems