Skip to content

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