-
Notifications
You must be signed in to change notification settings - Fork 0
Instance methods
These methods are available on any TagTrain instance and are the only recommended way to interface with the element.
Assume tagTrain is an instance of TagTrain created in the manner described here.
tagTrain.addTag(String value) -> Boolean
Attempts to add a new tag to the visible element and the internal tags array. If successful, returns true and triggers the add-tag event; otherwise, returns false. The following conditions may cause tag creation to fail (see options for details):
-
valueis empty - The maximum number of tags is already filled
-
valueis longer than the maximum allowed tag length -
valuefails the regular expression specified in the options - The given tag already exists
tagTrain.removeAll() -> void
Removes all the tags from both the visible element and the internal tags array. Triggers the remove-all event.
tagTrain.getTags() -> Array[String]
Returns an array of the tags that have been inputted. This is a copy of the actual internal tags array, so modifying it is safe (does not have side-effects).
tagTrain.setTags(Array[String] tags) -> void
Removes all of the currently existing tags and adds in all the tags specified by tags. Triggers the remove-all and (repeatedly) add-tag events. Note that these tags are still subject to the validation rules explained in addTag.
tagTrain.takeFocus() -> void
Selects the contents of the tag input field.