dragonofmercy / Tokenize2

Tokenize2 is a plugin which allows your users to select multiple items from a predefined list or ajax, using autocompletion as they type to find each item. You may have seen a similar type of text entry when filling in the recipients field sending messages on facebook or tags on tumblr.
https://dragonofmercy.github.io/Tokenize2/
BSD 3-Clause "New" or "Revised" License
83 stars 25 forks source link

Tokenize init successfully but suggestion not showing? #2

Closed hieuhlc closed 8 years ago

hieuhlc commented 8 years ago

I can see that tokenize inited without error. But I don't know why suggestion not showing when I type. I noticed there was some changes in DOM.

screen shot 2016-07-15 at 14 24 18

Is there any binding event when user's typing? If so I can debug from there, now I have no clue. Thank you.

dragonofmercy commented 8 years ago

Hi you can use the events below:

eliluong commented 8 years ago

Do you have any example code how to implement those events? I tried to bind a keydown event but it wasn't working. Thanks.

    $('.tokenize-demo').keydown(function(event) {
        if (event.keyCode == 13) {
            alert('enter pressed');
            console.log('enter pressed');
        }
    });
hieuhlc commented 8 years ago

@eliluong this is sample code from Tokenize 2 config docs

$('.tokenize-source-demo-3').tokenize2({
    dataSource: function(search){
        var $this = $('.tokenize-source-demo-3').data('tokenize2');
        $.ajax('remote.php', {
            data: { search: search, start: 0 },
            dataType: 'json',
            success: function(data){
                var $items = [];
                $.each(data, function(k, v){
                    $items.push(v);
                });
                $this.trigger('tokenize:dropdown:fill', [$items]);
            }
        });
    }
});

Btw @zellerda i fixed the problem. It's not Tokenize2 bug, it's mine.