Jage
Jage

Reputation: 8086

Trying to catch hideDropdown event in TextExt.js

I am using TextExtJs for an autocomplete feature where you start typing and the dropdown of suggestions appears below the text input and you can select a suggested option with arrow keys or mouse.

Everything is working great except that I am trying to perform a function after the user selects one of the suggestions. There is a hideDropdown event which I think is the proper event to use for this. Unfortunately I'm not understanding how to do this, this is what I have tried:

$('#usearch').textext({
    plugins : 'autocomplete ajax',
    ajax : {
        url : 'usersuggest.php',
        dataType : 'json',
        cacheResults : true
    },
    autocomplete : {
        onHideDropdown : function(){
            alert('A happened');
        },
        hideDropdown : function(){
            alert('B happened');
        }
    }, 
    onHideDropdown : function(){
        alert('C happened');
    },
    hideDropdown : function(){
        alert('D happened');
    }
});

None of these functions with the alert actually ever run. They do not interfere with the suggestion piece of it. How do I attach a callback to this event?

Upvotes: 1

Views: 162

Answers (1)

MJay
MJay

Reputation: 537

I'm facing the same problem here....

Unfortunately there is no proper solution. The manual is as rudimental as the examples provided on the plugin page.

I managed to bind a kind of "onAddingTag" event, refer to this: http://textextjs.com/manual/plugins/tags.html#istagallowed

$('#textarea').textext().bind('isTagAllowed', function(e, data) {
  var valueAdded = data.tag;
  data.result = true; //needs to be done, since we're abusing this event 
};

Despite the fact that this may help with this issue, your next problem would be: when does the user remove a tag? Finally I ended up, using another autocomplete library.

Upvotes: 0

Related Questions