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

Change tokenize dataSource #91

Open lailaabb opened 2 years ago

lailaabb commented 2 years ago

Hello, is it possible to change the tokenize dataSource url on a trigger?

dragonofmercy commented 2 years ago

Hi, I have no idea just now, you can try to do something with this snippet

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