Search code examples
jqueryjquery-pluginscallbackjquery-callbacktextboxlist

Using TextboxList events and callbacks


Has anyone gotten callbacks working with Guillermo Rauch's TextboxList Autocomplete? I've tried multiple ways to bind and multiple events (e.g. hover) - nothing seems to register.

$('#entSearch').textboxlist({unique: true, plugins: {
            autocomplete: {
                minLength: 3,
                queryRemote: true, 
                placeholder: false, 
                remote: {
                    url: "{{=URL(r=request, f='call/json/suggest')}}", 
                    extraParams: {type: "", guid: ""}
                    }
                }
            }, 
            onHover: function(token) {
                alert('hover 1');
            }
        });

        $('#entSearch').hover(function() {
            alert('hover 2');
        });

        $('#entSearch').bind('hover', function() {
            alert('hover 3');
        });

Solution

  • The author enabled listeners in a very specific way for TextboxList (see "Events" on this page):

    var t = new $.TextboxList('#entSearch', {unique: true, plugins: {
                autocomplete: {
                    minLength: 3,
                    queryRemote: true, 
                    placeholder: false, 
                    remote: {
                        url: "{{=URL(r=request, f='call/json/suggest')}}", 
                        extraParams: {type: "", guid: ""}
                        }
                    }
                }
            });
    
            t.addEvent('bitBoxAdd', function(bit) {
                alert('add');
            });