Solved - $(...).select2 is not a function

 Some time we face a common problem with select2 if select2 library added to all pages and js function too but selection did not exist or was not loaded. So we can fix that issue using below method:

Make sure $("#selector") is exists or not.

if ( $("#selector").length > 0 ){     //Check selection
     $("#selector").select2();    // Call select 2
}

Comments

Popular posts from this blog

Stop video playing when Bootstrap modal is closed

Creating Protected routes in ReactJS