Sha256: e7fe4f97767e54a209b41affb86ceb9875c84859f23d704ab9faf03888ef13d2

Contents?: true

Size: 935 Bytes

Versions: 2

Compression:

Stored size: 935 Bytes

Contents

class Perkins.Views.MyRepos extends Backbone.View
  el: "#main-content"

  events:
    "click .add-repo" : "addRepo"

  initialize: (opts={})->
    @model = new Backbone.Model(name: opts.name)

  template: ->
    JST["repos/github"](@model.toJSON())

  render: ()->
    @model.fetch
      url: "/myrepos"
      success: =>
        $(@el).html(@template())

  #TODO: use a collection view and decouple
  addRepo: (ev)->
    target = $(ev.currentTarget)
    target.text("adding...")
    target.addClass("btn-diabled")
    repo_id = target.data('gb-id')
    url = "/repos/add/#{repo_id}"

    #add repo & refresh sidebar on success.
    $.ajax
      url: url
      success: ->
        sidebar = Applayout.appLayout.sidebar.currentView
        sidebar.repos.reset()
        sidebar.repos.fetch()
    false

  close: ()->
    $(@el).html("")
    console.log "CLOSED VIEW CALLED"
    @.stopListening()
    @.undelegateEvents()
    @.unbind()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
perkins-0.0.3 lib/perkins/assets/javascripts/perkins/v/my_repos.js.coffee
perkins-0.0.2 lib/perkins/assets/javascripts/perkins/v/my_repos.js.coffee