0

I maintain an ASP.NET MVC 5.2 site that uses the jQuery plugin select2 v3.5.2. The plan is to migrate the site to select2 v4 of the same plugin, and would like to do this by avoiding an all or nothing approach; my preference being to (CDN) reference both libraries and migrate view-by-view.

I've already explored using a different base layout for each select2 version, but the trouble is there are dependencies on select2 3.5.2 in dozens of script files that are included in sections in the underlying Views.

Looking at the documentation, both versions use the same name, i.e.

$("#id").select2(...)

Is there a clean, conflict-free approach to referencing both versions of the plugin on the same page? I thought perhaps renaming the old version, and rename all refs e.g.:

$("#id").select2z(...)

which would allow migrated code to adopt the defacto standard $("#id").select2(...), but references are currently by CDN, and I don't know how to / the impact of changing this.

If this is at all possible, then CSS would also need to be considered; I'm not sure how compatible the styling is across both versions.

Appreciate any help.

SteveChapman
  • 3,051
  • 1
  • 22
  • 37

0 Answers0