Skip to content

Instantly share code, notes, and snippets.

@alexwebgr
Created May 30, 2019 09:06
Show Gist options
  • Save alexwebgr/68a0d1d8c9f22068404f8287d29866f9 to your computer and use it in GitHub Desktop.
Save alexwebgr/68a0d1d8c9f22068404f8287d29866f9 to your computer and use it in GitHub Desktop.
autocomplete search function
var keys = [8,
46,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
96,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106,
107,
109,
110,
111,
186,
187,
188,
189,
190,
191,
192,
219,
220,
221,
222
];
$('#q').off().on({
keyup: function (e) {
if (keys.indexOf(e.which) > -1) {
// can be resource intensive in which case _.debounce should be used as part of this solution
Rails.fire($('#qForm')[0], 'submit');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment