i am using select2 plugin for dropdown search but it is not working in react and i tried a lot for this.For bootstrap modal i am giving parent id as well .Apart from modal it is also not working.What could be the reason as i am getting list in the dropdown but search input is not available for filteration which is my requiremnt.Anyone can help me regarding this.
Thank you
$.fn.select2.defaults.set("theme", "bootstrap5");
$.fn.select2.defaults.set("width", "100%");
$.fn.select2.defaults.set("selectionCssClass", ":all:");
Hello Sir, Please tell me where should i add this code of line in my react project
Hi Zahid,
You can add this initialization code in src/index.tsx.
Regards,
Lauris Stepanovs,
Keenthemes Support Team
Hi Zahid,
Thank you for reaching out to us.
Since Select2 requires jQuery and combining jQuery with React isn't good practice, Selec2 wasn't included in our React version.
If you want to use Selec2 then you can refer to our HTML version.
Install Selec2 and jQuery npm pacakge. Import selec2 and jQuery globally.
Initialize selec2 gloabally:
$.fn.select2.defaults.set("theme", "bootstrap5");
$.fn.select2.defaults.set("width", "100%");
$.fn.select2.defaults.set("selectionCssClass", ":all:");
$("your-select-selector).select2();
$.fn.select2.defaults.set("theme", "bootstrap5");
$.fn.select2.defaults.set("width", "100%");
$.fn.select2.defaults.set("selectionCssClass", ":all:");
Hello Sir, Please tell me where should i add this code of line in my react project