Domanda

I'm trying to call focus() on a YUI3 autocomplete control, but nothing happens.

The code is:

var ac = new Y.AutoComplete({ inputNode: '#ac-input' });
ac.focus(); //doesn't do anything
ac.fire('focus'); //neither this
ac.simulate("focus"); //no success either, yes I did include 'node-event-simulate'
ac.invoke("focus"); //no success either

replaced 'focus' with 'click' but nothing.

Tried using focusmanager, but no success yet.

How do I focus the query field of the autocomplete?

È stato utile?

Soluzione

I think ac is not a the node you think it is.

Try to call the focus method on the input node.

var inputNode = Y.one('#ac-input'),
    ac = new Y.AutoComplete({ inputNode: inputNode });

inputNode.focus();
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top