class Perkins.Views.Org extends Backbone.View el: "#main-content" events: "click .add-repo" : "addRepo" initialize: (opts={})-> @model = new Perkins.Models.Org(name: opts.name) template: -> JST["org"](@model.toJSON()) render: ()-> @model.fetch success: => $(@el).html(@template()) 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()