           buttons: [{
             text: 'Ok'
             click: (e) -> 
-              console.log "OK button clicked:", e, w
+              attrform.find("div.attrform:hidden").each (e) ->
+                console.log "removing", $(this).data('attribute_name')
+                editorNode.removeAttr $(this).data('attribute_name')
+              attrform.find("div.attrform:visible").each (e) ->
+                console.log "setting", $(this).data('attribute_name'), "to", $(this).find('.attrinput').val()
+                editorNode.attr $(this).data('attribute_name'), $(this).find('.attrinput').val()
               wm.close(null, w.id)
           }, {
             text: 'Cancel'

        }
      else
        console.log "no attributes"
      console.log "attrform", attrform
      console.log "Required:", attrrequired
      console.log "Optional:", attroptional


  init = (editor) ->
    return new ElementHandler(editor)

      attroptional = {}
      attrrequired = {}
      attrgroups = {}
      editorNode = @editorNodeFromListNode node
      newtagname = $(editorNode).attr("data-xmlel") || params['key']
      elementattrs = @editor.plugins.textorum.schema.defs[newtagname]?.attr

      attrRequiredList = $(document.createElement("ul"))
      attrlist = $(document.createElement("ul"))
      attrform = $(document.createElement("div"))

      attrwindow = $(document.createElement("div"))
      attrwindow.addClass "textorum_attributewindow"
      attrlists = $(document.createElement("div"))
      attrlists.append attrRequiredList
      attrlists.append attrlist
      attrwindow.append attrlists
      attrwindow.append attrform
      
      attrlists.on 'click', 'li.optional', (e) ->
        el = $(this)
        window.foo = el
        el.parents(".textorum_attributewindow").find("div.#{el.data('target')}").toggle()

      for own attr of elementattrs
        attrform.append @attrFormElement(attr, elementattrs[attr], node)
        if elementattrs[attr].required
          attrRequiredList.append @attrListElement(attr, elementattrs[attr], node)
          attroptional[attr] = elementattrs[attr]
        else
          attrlist.append @attrListElement(attr, elementattrs[attr], node)
          attrrequired[attr] = elementattrs[attr]
      if attrform.children().length
        window.attrform = attrform
        wm = @editor.windowManager
        w = wm.open {
          inline: true
