[Resolved] Taxonomy filter as multiselect with searchbox (2)
This support ticket is created 7 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Hello and thank you very much,
It seems Gravity Forms uses specific html code (other than "select") to show the multiple select field with search bar.
But as you were saying before, if the html is correct, you may offer the flexibility to add the data attributes needed by the select. In deed, as you may see here hidden link it seems all it would need is to set the select as this :
Then I would simply just to add the JS and CSS to the view to show it properly.
If that makes any sens, please could you point me where to add the data attributes ?
Thank you so much for your help !
The problem I envisage with your solution is that the library you appear to be using runs straight away, it doesn't require initialising. And you would need to run some JS to add the data-attributes it needs to work, but it might be tricky to make sure your code runs before the library initialises.
A better solution would be one where you manually initialise the code the converts the select box into the multi-select search you are looking for.
Digging in my bookmarks I found this: hidden link
It doesn't require any special attributes to work, you manually initialise it on the required select element which it then converts.
So you simply need to
- enqueue your required scripts and styles
- add a JS code snippet on DOM ready that initialises selectize on your select groups
Check out the docs for selectize, I think it is fairly self-explanatory, but let me know if you have problems.
Hello and thank you very much for your help.
I've looked selectize.js but I don't see any multiselect on "select" elements ; the multiselects are "input" and "div" fields...
I don't know much about code so I may be missing something ?
Thank you.
In any case you can use the browser dev tools to check whether the links to the files have been added to the page.
The next issue is that the '$' prefix used by jQuery may not be available unless you specifically make it available to your custom JS snippet, and you should also wait for the dom ready event before initiating select2. (I suspect you will find an error in your console about $ undefined.)