Dynamically add buttons to spacepen panel


#1

I’m adding a side panel to a package I’m working on. It uses space-pen-views, and initially sets itself up like this (simplified):

{$$, View} = require 'space-pen'

module.exports = class PanelView extends View
  @content: (state) ->
    @div class: 'panel-view', =>
      @button class: 'inline-button', click: 'onButton', id: 'foo', 'foo'
 
  initialize: (state) ->
    @state = state
    @panel = atom.workspace.addRightPanel(item: this, visible: false)

  toggle: ->
    if @panel?.isVisible()
      @panel.hide()
      @state.visible = false
    else
      @panel?.show()
      @state.visible = true
 
  onButton: (evt) ->
    console.log evt

This works fine, but I want to add more buttons to the div during runtime, and I can’t work out how to do that. Anyone know?