Hello
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 :
./types/vendor/toolset/toolset-common/res/lib/select2/select2.js?ver=4.0.3
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"]
[wpv-filter-controls]
<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>
<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>
<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"]
</div>
[wpv-filter-submit output="bootstrap"]
[wpv-filter-spinner spinner="<em><u>hidden link</u></em>"][/wpv-filter-spinner]
[/wpv-filter-controls]
[wpv-filter-end]
and the js part :
$(document).ready(function() {
$('.js-wpv-filter-trigger').select2();
});
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.
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.