[annotator-dev] Hide annotator and reload annotations

Riccardo Tasso riccardo.tasso at gmail.com
Tue Feb 18 10:16:35 UTC 2014


Thanks Randall,
    I see what you mean. I used jquery interface since it was the one I
found in the documentation.

I my version of annotator (based on 1.9) it seems that the annotator object
ins't stored inside the data attribute you said. It wasn't a problem, for
me storing it in this way:

var text = $(this.element).find('.text').first();
var annotator = new Annotator(text);
text.data('annotator', annotator);
annotator.addPlugin('MyAnnotatorPlugin');
...

In this way I can always access to the annotator object to invoke the
destroy method.

I hope this is what you meant.

I'm a bit unhappy, since my version of annotator is slightly modified to
support multi-colored annotations and I can't be aligned with your version.
Cheers,
   Riccardo


2014-02-14 23:11 GMT+01:00 Randall Leeds <tilgovi at hypothes.is>:

> On Fri, Feb 14, 2014 at 6:58 AM, Steph Skardal <steph at endpoint.com> wrote:
>
>> On 02/14/2014 02:11 AM, Riccardo Tasso wrote:
>>
>>> it would be nice having something like this:
>>>
>>> $(button).on('click', function() {
>>>
>>>    var text = $(this.element).find('.text').first();
>>>    if(text.annotator == undefined) {  // everytime I turn on I reload
>>> annotations
>>>       text.annotator();
>>>       text.annotator('addPlugin', 'MyAnnotatorPlugin');
>>>       ...
>>>    } else {
>>>        text.annotator.destroy();
>>>        // at this point text.annotator is undefined
>>>    }
>>> });
>>>
>>
>>
>> +1 on this request
>
>
> This should work if you spell it `text.annotator('destroy')`.
> But see this caveat: https://github.com/okfn/annotator/issues/265
>
> I'm strongly considering that should deprecate the jquery interface for
> v2. There's simply no good reason I see for it and it destroys
> introspection IMO. Having the annotator object and being able to enumerate
> its methods one can inspect the surface API in their browser dev tools.
> `.annotator('<method_name>', <params ...>)` is unnecessary.
>
> Annotator does store the Annotator instance object under the jquery data
> key 'annotator'. So you might consider instead something like this instead:
>
> ```
>
> var text = $(this.element).find('.text').first()
>     , annotator = text.data('annotator')
>     ;
>
> if(text.data('annotator') == undefined) {
>     annotator = new Annotator(text);
>     annotator.addPlugin('MyAnnotatorPlugin');
> } else {
>     annotator.destroy();
> }
> ```
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20140218/e492afd3/attachment-0004.html>


More information about the annotator-dev mailing list