Sha256: 10baeaa495b8af4f79dc4d130190ab0cb81983451a58045925b0046d5b519188

Contents?: true

Size: 940 Bytes

Versions: 1

Compression:

Stored size: 940 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}.json"

    #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

1 entries across 1 versions & 1 rubygems

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