[annotator-dev] Problem with adding fields to an annotator editor

Ewald Zietsman ewald at siyavula.com
Thu Sep 1 10:34:18 UTC 2011


Hi All,

I'm busy writing a 'categories' plugin for annotator. Its a bit rough and I
almost have it working but I've run into an issue I don't understand.

I'm adding fields to the editor using this code:

class Annotator.Plugin.Categories extends Annotator.Plugin

  pluginInit: ->
    return unless Annotator.supported()

    @field = @annotator.editor.addField({
      type: 'radio'
      label:  'Errata'
      category: 'errata'
      load:   this.updateField
      submit: this.setAnnotationCat
    })

    @field = @annotator.editor.addField({
      type: 'radio'
      label:  'Suggestion'
      category: 'suggestion'
      load:   this.updateField
      submit: this.setAnnotationCat
    })

    @field = @annotator.editor.addField({
      type: 'radio'
      label:  'Comment'
      category: 'comment'
      load:   this.updateField
      submit: this.setAnnotationCat
    })

    @annotator.viewer.addField({
      load: this.updateViewer
    })


I'm handling the radio buttons in the editor with code like this:

switch (field.type)
      when 'textarea'          then input = $('<textarea />')
      when 'input', 'checkbox' then input = $('<input />')
      when 'radio'             then input = $('<input type="radio"/>')

if field.type == 'radio'
      input[0].type = 'radio'
      input[0].name = 'radio'
      input[0].value = field.category
      element.addClass('annotator-radio')
      element.append($('<label />', {for: field.id, html: field.label}))


The issue I'm getting is that the last field I add to the editor doesn't get
its 'value' attribute set. In the above example the 'comment' element will
have an empty 'value' attribute.

Any help will be greatly appreciated.

-- 
*
Ewald Zietsman

Technical Coor**dinator*
*
*
*
*
Website: www.siyavula.com
The Open Innovation Studio, 27 Buitenkant Street, Cape Town, 8001

A Shuttleworth Foundation Seeded Project
Website: www.shuttleworthfoundation.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20110901/581ceb75/attachment-0002.html>


More information about the annotator-dev mailing list