New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add support for optional tags auto-complete in the tags plugin #92

Closed
pombredanne opened this Issue Feb 15, 2012 · 4 comments

Comments

Projects
None yet
3 participants
@pombredanne

pombredanne commented Feb 15, 2012

It would be great to have the option to get tag autocompletion support . There are jquery ui and jquery plugins for this alright... yet this could be part of the standard tag plugins (and configured optionally with options)
The source of autocompletion list could be so varied so this is likely best as open to the user to provide.

@pombredanne

This comment has been minimized.

pombredanne commented Feb 15, 2012

Actually this can be done without changing anything in the plugin but using jquery ui autocomplete this way:

  1. add jquery ui and its css to your page for instance with:

    <link href="lib/vendor/jquery-ui.css" rel="stylesheet" type="text/css" />
    <script src="lib/vendor/jquery-ui.js"></script>
  2. initialize annotator and autocomplete this way for instance for the elemenToAnnotate div, the key being to grab the annotator instance

    jQuery(function ($) {
      $('#elementToAnnotate').annotator().annotator('addPlugin', 'Tags');
    
      var availableTags = [
        "Tag1",
        "OtherTag",
        "Tag2",
      ];
    
      $('#elementToAnnotate').data('annotator').plugins.Tags.input.autocomplete({
        source: availableTags
      });
    
    });
@anjesh

This comment has been minimized.

anjesh commented Jul 13, 2015

Just wondering if it is possible to use select2 https://select2.github.io/examples.html instead of jquery ui autocomplete for the tags.

@tilgovi

This comment has been minimized.

Member

tilgovi commented Jul 13, 2015

Probably. If it's not, let us know what we can do to make that possible.

@anjesh

This comment has been minimized.

anjesh commented Jul 14, 2015

I managed to make this work, however i copied the tag plugin from the annotatorjs and created new tags plugin to use select2. Not a good hack, but it works :) https://github.com/anjesh/annotatorjs-hacks/blob/master/lib/annotator.plugin.tags.js
here's the demo https://rawgit.com/anjesh/annotatorjs-hacks/master/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment