I wanted to turn an HTML <select> element into an autocomplete. I also wanted to match on more than one attribute. So, I made
jquery.autocomplete_from_select.js.
Thoughts?
Hey! Why don't you make your life easier and subscribe to the full post
or short blurb RSS feed? I'm so confident you'll love my smelly pasta plate
wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!
Leave a comment
Have you checked out Chosen or Select2? (I prefer Select2.)
Posted by James Moberg
on Feb 25, 2013 at 02:47 PM UTC - 6 hrs
Thanks James, yes I've seen them and they are both awesome!
However, they have a little too much UI chrome for what I was looking for: they'd have looked out of place in the app I was working on that led to this little "project". Rather than try to style them appropriately, it seemed better to just use what I had with jQuery UI, since it already fit in well.
Also, the file I wrote is less than 4 KB without minification. In this app, asset size isn't a huge consideration, but it might be in others.
Posted by
Sammy Larbi
on Feb 26, 2013 at 07:06 AM UTC - 6 hrs
I dropped the demo script + markup into an existing framework and it didn't working right. (Win8-64, Chrome, jQuery 1.8.3, jQuery UI 1.9.1) It displays a text field. Typing in the value didn't do anything. Reattempting entry would show a drop-down with all options, but typing in "abc" didn't reveal any results and pressing tab cleared out the entry since it didn't match anything.
Will you be posting an simple online demo? I like online demos because I can verify that the script works and does what I think it should do before I download it to try it out. (Some scripts break with newer versions of jQuery.)
Posted by James Moberg
on Feb 26, 2013 at 08:57 AM UTC - 6 hrs
Sure thing. I'll put something in there later today. I did have it clear the entry on purpose if there is no match, though it's easy enough to change that if you're interested.
Posted by
Sammy Larbi
on Feb 26, 2013 at 09:05 AM UTC - 6 hrs
Great breakfast reading! :)
Posted by
William
on Jul 17, 2017 at 05:28 AM UTC - 6 hrs
Leave a comment