开发者

YUI AutoComplete: how do you get it to expand when the input is selected?

开发者 https://www.devze.com 2023-01-02 05:25 出处:网络
I\'ve got a YUI AutoComplete control, works great.Except that I\'d like it to expand the list of suggestions as soo开发者_JAVA技巧n as the user selects the input box.How do I make that happen?

I've got a YUI AutoComplete control, works great. Except that I'd like it to expand the list of suggestions as soo开发者_JAVA技巧n 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消