[annotator-dev] Deleting an annotation from a plugin

Ewald Zietsman ewald at siyavula.com
Tue Apr 10 13:43:00 UTC 2012


Hi All,

I've nearly completed a better version of my comment plugin. I'm saving the
replies to annotations as more annotations, except that they have and empty
.range field and they contain the id of their parent annotation in a
.parent field. The saving and creating new replies to annotations work just
fine. Now I'm trying to add a delete button to each reply, so that users
can delete them if they wanted to. I've tried many different combinations
of publishing the delete event but can't seem to get it to do so. My code
looks like this at the moment

  deleteReply: (event) ->
    # delete the reply
    reply_item = $(event.target).parents('.reply')
    parent_id =
reply_item.parents('.annotator-annotation').data('annotation').id
    reply_text = reply_item.find('.replytext')[0].innerHTML

    # now look for annotations with parent == parent_id AND reply that
matches reply_text and delete them
    for ann in @annotator.dumpAnnotations()
      if ann.parent == parent_id
        if ann.reply.reply == reply_text
          console.log('match, ', ann)
          @deleteAnnotation(ann)
          console.log('deleted')



  deleteAnnotation: (annotation) ->
    @annotator.publish('annotationDeleted', [annotation])
    annotation


Is this supposed to work as I expect? Is there another way of asking the
annotator to delete an annotation object?

-- 
*
Ewald Zietsman

Technical Coor**dinator*
*
*
*
*
Website: www.siyavula.com
The Open Innovation Studio, 27 Buitenkant Street, Cape Town, 8001
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20120410/383e36f4/attachment.html>


More information about the annotator-dev mailing list