how to enter value into search box?

54 views
Skip to first unread message

pha...@gmail.com

unread,
Jun 17, 2016, 5:18:37 PM6/17/16
to select2
When the user focuses on the select box, if they start typing, I want the dropdown to open and let they type in the search.

I currently call open() on keypress, but while it opens it, the search box is empty. I'd like to take that captured keypress and also insert it into the search box. I can seem to figure out how to selected it. the select2 data object doesn't have $search attached to it that I can find.

Any ideas?

pha...@gmail.com

unread,
Jun 17, 2016, 5:38:46 PM6/17/16
to select2, pha...@gmail.com
Ok, so kind of figured it out

var keyString = evt.key;
s2Obj.open();
s2Obj.dropdown.$search.val(keyString);
// s2Obj.dropdown.$search.trigger('keyup'); //doesn't trigger?
s2Obj.trigger('query', {term:keyString});
evt.preventDefault();


For some reason triggering the keyup on the search doesn't do a thing, so I just tell it to do the search with that particular term

Reply all
Reply to author
Forward
0 new messages