Autocomplete and store with jQuery

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1888
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Autocomplete and store with jQuery

Post by kinerity » Wed Apr 18, 2018 1:53 pm

I currently have a select box in my Knowledge Base extension that allows you to select multiple categories (HTML/url], [url=https://github.com/kinerity/knowledgeba ... #L722-L731]PHP - insert code, PHP - build list code)

Is there anyway to accomplish this with jQuery? I found this jQuery autocomplete page with a view source link below it, but I'm a complete newbie to jQuery and don't really follow.
  1. How do I pass an array in PHP to the availableTags variable in jQuery?
  2. Once I press Submit on my posting page, how do I pass the categories back to PHP to insert them into the database?
  3. Can that code be trimmed further for my needs or do I need that full code? Just the <script></script> tags, I'm not worried about the rest of the HTML/CSS.
Kailey Truscott - Community Team

User avatar
posey
Registered User
Posts: 706
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: Autocomplete and store with jQuery

Post by posey » Fri Apr 20, 2018 12:40 pm

I'm not familiar with the jQuery auto-complete functionallity, but have you tried calling it on the select field with the options in place? It might just take the available options. Otherwise you can just use all child options from your select as the 'auto complete tags'.

Moreover, I personally am very fond of Select2, https://select2.org/
It lets you do exactly what you want and adds a nice style to it.
''I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking. And I plan on finding out what that is.''

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1888
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Autocomplete and store with jQuery

Post by kinerity » Fri Apr 20, 2018 11:42 pm

posey wrote:
Fri Apr 20, 2018 12:40 pm
Moreover, I personally am very fond of Select2, https://select2.org/
It lets you do exactly what you want and adds a nice style to it.
Thanks! I'll bookmark that so I can make it a feature of the 3.3 release.
Kailey Truscott - Community Team

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 16 guests