Autocomplete and store with jQuery

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

Autocomplete and store with jQuery

Post by Kailey »

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 Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: Autocomplete and store with jQuery

Post by mrgoldy »

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.
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3732
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: Autocomplete and store with jQuery

Post by Kailey »

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 Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
Post Reply

Return to “Extension Writers Discussion”