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

Not able to add id value for input and label for tag while using autocomplete #166

Closed
tbshrr opened this issue Jan 29, 2022 · 1 comment
Closed

Comments

@tbshrr
Copy link

tbshrr commented Jan 29, 2022

Is there any way to add the value for the input field after selecting a tag from autocomplete. I tried with inputformatter. But that doesn't seem to work.

$(document).ready(function() {
    var example4 = new Taggle('all_tags', {
        tags: ['Try', 'entering', 'one', 'of', 'these', 'tags'],
        duplicateTagClass: 'bounce'
    });
    var container = example4.getContainer();
    var input = example4.getInput();

    $(input).autocomplete({
        source: function( request, response ) {
            $.ajax({
            url: '<?php echo base_url("URL_HERE_TO_GET_EXISTING_TAGS_FROM_SERVER") ?>',
            dataType: "json",
            data: {
                q: request.term
            },
            success: function( data ) {
                response( data );
            }
            });
        },
        appendTo: container,
        position: { at: "left bottom", of: container },
        select: function(event, data) {
            event.preventDefault();
            //Add the tag if user clicks
            if (event.which === 1) {
                let some = example4.add([data.item.label]);

                
                example4.setOptions({
                   inputFormatter: function(i){
                        i.val(data.item.value);
                    }
                }
                )
                // input.val(data.item.value);
                // example4.getInput().val(data.item.value);
            }
        }
    });
@okcoker
Copy link
Owner

okcoker commented Jan 29, 2022

Could this be the same issue as reported here? #123

@okcoker okcoker closed this as completed Feb 10, 2022
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

No branches or pull requests

2 participants