trigger ajax with enter key

65 views
Skip to first unread message

abb...@gmail.com

unread,
Aug 25, 2015, 5:22:45 PM8/25/15
to select2
I'm kind of new to using select2, but I didn't find this documented anywhere.

I have a few select items in my form, and I want to allow someone to enter some text in there to do a search. I only want the ajax to be run after they press the enter key. I don't care about minimum or maximum text values, just if the enter key is pressed. Then I can have the ajax call my script that will check the entered text and return anything that is in my database that matches it.

How do we make this happen? I saw some postings in stackoverflow.com where you can capture the enter key input, but the ajax is not invoked unless some other key is pressed, but I don't need any other key to be pressed after the enter key has been pressed.

Reply all
Reply to author
Forward
0 new messages