[annotator-dev] Support for spaces in tag names

Randall Leeds tilgovi at hypothes.is
Wed May 20 22:17:27 UTC 2015


You will need to set the "stringifyTags" and "parseTags" options to the
Tags plugin.


content.annotator('addPlugin', 'Tags', {
  parseTags: function (string) { ... return Array ... },
  stringifyTags: function (Array) { ... return String ... }
});

That controls how the widget expects to parse the input and to display the
model as a string in the input field. You can change these to match your
comma separator in your autocomplete plugin.

On Fri, Apr 24, 2015 at 2:24 AM, Apurva Jalit <apurva.jalit at gmail.com>
wrote:

> Is there a straightforward way to enable support for space separated tags
> in the default annotator tag plugin? I need to support spaces in tag names
> and also be able to enter multiple tags at a time separated by say a comma.
> For each of the tags, we need to fetch auto completion source via ajax. I
> tried the following but it did not work:
>
>     var content = $('body');
>     var tags = ["python" ,"javascript", "C++"];
>     content.annotator();
>     content.annotator('addPlugin', 'Tags')
>     content.data('annotator').plugins.Tags.input.autocomplete({
>         source: tags,
>         multiple: true,
>         minLength: 1,
>         multipleSeparator: ","
>     })
>
> For the sake of simplicity, I have used a local source instead of ajax
>
> Thanks,
> Apurva Jalit
>
> _______________________________________________
> annotator-dev mailing list
> annotator-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/annotator-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/annotator-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20150520/d7e43e6c/attachment-0003.html>


More information about the annotator-dev mailing list