Skip to content
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

added tagmanager publicMethod 'extractTagsFromString' #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bmaso
Copy link

@bmaso bmaso commented Nov 10, 2018

  • bmaso needed ability to parse multiple tags at once specifically when users "paste" text w/ multiple tags into tm-input
  • Created new tagmanager public method extractTagsFromString: returns an array of the tags present in any given string as if text had been typed in one character at a time
    • splits input string on tag delimiters
    • trims whitespace of each tag
  • External code can then use extractTagsFromString and pushTag methods in conjunction to push multiple tags at once, e.g. as part of a "paste" event handler:
$(".tm-input").on("paste", function(e) {
  setTimeout(function() {
    //...compute tags present in the pasted text...
    var text = $(".tm-input").val();
    tagsArr = $(".tm-input").tagsManager("extractTagsFromString", text);

    //...clear input element contents...
    $(".tm-input").val('');

    //...push tags...
    for(var ii=0; ii<tagsArr.length; ii++) {
      $(".tm-input").tagsManager("pushTag", tagsArr[ii]);
    }
  }, 0);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant