How to programmatically add terms to field using Javascript?

Created on 13 June 2019, almost 6 years ago
Updated 7 March 2023, about 2 years ago

Hey there,

is there a way to manually add terms to the field using, for instance, the console? I have a hard time accessing functions like addValue or any other way to add terms to the field.

Background: I have a list of all terms beneath the field, by clicking them I want the deluxe field to apply/ add that clicked term to the actual bar.

Thanks

πŸ’¬ Support request
Status

Active

Version

2.0

Component

Multiple values

Created by

πŸ‡©πŸ‡ͺGermany sic

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States mtovey

    Attaching a patch that changes the module js as @sic outlined earlier. This then allows subsequent js code with a reference to the HTML widget element to access the properties/methods from the MultipleWidget setup method. For example:

    let widgetObject = jQuery('#autocomplete-deluxe-input').data('autocomplete_deluxe_widget');
    let itemInit = {
    label: 'Create a new tag: #Sample tag',
    value: 'Sample tag',
    newTerm: true
    };
    widgetObject.addValue(itemInit);

  • πŸ‡ΊπŸ‡ΈUnited States eadamse

    This is a re-roll of the patch from #6 πŸ’¬ How to programmatically add terms to field using Javascript? Active for version ^2.1. You can utilize the widgetObject using the jQuery `data` method as described there.

Production build 0.71.5 2024