Sha256: 37668067da6f7812af53c62f52c46c5b4d05ef0e71d52260ec79faf7b39efbe6

Contents?: true

Size: 961 Bytes

Versions: 1

Compression:

Stored size: 961 Bytes

Contents

class TentStatus.Views.FollowingGroupsForm extends Backbone.View
  initialize: (options = {}) ->
    @parentView = options.parentView

    followingId = @$el.attr 'data-following-id'
    @following = TentStatus.Collections.followings.get(followingId)

    @$groupsSelect = ($ 'select[name=groups]', @$el)
    @$groupsSelect.chosen
      persistent_create_option: true
      no_results_text: 'No groups match'
      create_option_text: 'Create new group'
      create_option: (name) =>
        group = new TentStatus.Models.Group({ name: name })
        group.once 'sync', =>
          TentStatus.Collections.groups.push(group)
          @following.set 'groups', (@following.get('groups') || []).concat([group.get('id')])
          @following.save()
          @parentView.render()
        group.save()

    @$groupsSelect.change =>
      @following.set 'groups', @$groupsSelect.val()
      @following.once 'sync', => @parentView.render()
      @following.save()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tent-status-0.0.1 assets/javascripts/views/following_groups_form.js.coffee