Sha256: fa323535a6c4ece2373b84c0746adfed3a921e086d5892874160484c8bd8c985

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 Bytes

Contents

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

    @buttons = {}
    @buttons.submit = ($ '[type=submit]', @$el)

    following = new TentStatus.Models.Following
    following.fetch
      url: "#{TentStatus.api_root}/followings?entity=#{encodeURIComponent(TentStatus.domain_entity)}&guest=true"
      success: (f, res) =>
        if res.length
          @setFollowing()

    @$el.on 'submit', @submit

  submit: (e) =>
    e.preventDefault()
    entity = TentStatus.domain_entity
    @buttons.submit.attr 'disabled', 'disabled'
    following = new TentStatus.Models.Following { entity: entity }
    following.once 'sync', =>
      @setFollowing()
    following.save()
    false

  setFollowing: =>
    @buttons.submit.val 'Following'
    @buttons.submit.attr 'disabled', 'disabled'

Version data entries

1 entries across 1 versions & 1 rubygems

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