Skip Navigation

[Résolu] Select2 Library

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: I would like to use select2.js in some of my site's custom code. I see that Toolset has its own select2.js dependency. Should I enqueue the library separately, or can I use the Toolset select2 feature?

Solution: At this time, it's best to enqueue the library separately.

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.

This topic contains 4 réponses, has 2 voix.

Last updated by mohammadD Il y a 3 années et 4 mois.

Assigned support staff: Christian Cox.


I am trying to use select2 library in the code below for creating custom search in my view.
I have seen that you have select2 library queued in the header. the path of this library is :
I wanted to know how can i trigger it.
now I am using the select2 CDN , which i think is conflicting with yours.
here is my code for custom search and the js part.

[wpv-filter-start hide="false"]
<div class="form-group">
	<label>[wpml-string context="wpv-views"]Pol[/wpml-string]</label>
	[wpv-control-postmeta field="wpcf-ptp-pol" url_param="wpv-wpcf-ptp-pol"]
<div class="form-group">
	<label>[wpml-string context="wpv-views"]PoD[/wpml-string]</label>
	[wpv-control-postmeta field="wpcf-ptp-pod" url_param="wpv-wpcf-ptp-pod"]
<div class="form-group">
	<label>[wpml-string context="wpv-views"]Container Type[/wpml-string]</label>
	[wpv-control-postmeta field="wpcf-ppt-container-type" url_param="wpv-wpcf-ppt-container-type"]
[wpv-filter-submit output="bootstrap"]
[wpv-filter-spinner spinner="<em><u>hidden link</u></em>"][/wpv-filter-spinner]

and the js part :

$(document).ready(function() {

Christian Cox

Languages: Anglais (English )

Timezone: America/New_York (GMT-04:00)

Hi, let me ask my 2nd tier support team if we offer any best practices for integrating with select2.js. Can you tell me more about the conflict you mentioned? In a local test, I was able to enqueue select2 CSS and JS in a child theme and then call jQuery(...).select2() to initialize some select fields on the site. Is there a specific problem I can look at?


No i just wanted to make sure that i am not using something twice as the speed optimization is the most important thing to me.


Christian Cox

Languages: Anglais (English )

Timezone: America/New_York (GMT-04:00)

After discussion with my 2nd tier team, it appears that enqueueing the library independently is your best option. No public API is available for utilizing the select2 library implemented by Toolset, and we do not recommend attempting to access it directly in your own custom code.