سؤال

I've got a YUI AutoComplete control, works great. Except that I'd like it to expand the list of suggestions as soon as the user selects the input box. How do I make that happen?

Right now expansion doesn't happen until the user hits a key in the box.

هل كانت مفيدة؟

المحلول

You can use the textboxFocusEvent to send a query of the contents of the input, which will open the results pane. I tried using expandContainer without success but wasn't sure that would have worked anyways.

Working Example: http://tivac.com/yui2/autocomplete_jamesmoore.htm

نصائح أخرى

Tivac has the right idea -- use textboxFocusEvent to send an empty query that returns results to populate the container. Check out this example for some sample code: http://developer.yahoo.com/yui/examples/autocomplete/ac_combobox.html

This works when using YUI 3:

Y.one('#id').plug(Y.Plugin.AutoComplete, {source:['item1','item2','item3','etc']})
            .on('focus', function(){this.ac.fire('query')});

On focus of the attached input (id), the query event is fired to populate the 'menu' and display it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top