javascript - Load a different jQuery library from Layout in View for DataTables in MVC -
i need load specific jquery library version in view use datatables library.
the problem use jquery 3.1 project , include reference in _layout view, datatables allow:
bootstrap's javascript requires jquery version 1.9.1 or higher, lower version 3
how can i, if possible, load different version of jquery in specific view?
edit:
regarding davidg comment, seems message based on bootstrap jquery supported library not support jquery v3.
i going update bootstrap 3.3.7 avoid problem ("added support jquery 3") , use jquery 3.1.0, datatables problem remains case.
edit2 (solution):
i decided follow shyju's suggestion keep simple , based in single stable jquery version, have downgraded jquery 2.2.4 (last v2 stable version) , have keeped bootstrap last version (v3.3.7).
datatables version remains same (1.10.12).
if absolutely need load different version of library specific page, can this.
in specific action method returns view has data table, set viewbag
item
public actionresult list() { viewbag.needsspecialjquery = true; return view(); }
and in layout(_layout.cshtml
), check viewbag item , based on it's existence/value, conditionally load jquery version need.
@{ if (viewbag.needsspecialjquery != null && viewbag.needsspecialjquery ) { <script src="path jquery 1.9.1 here"></script> } else { <script src="path other jquery here"></script> } }
while may solve current problem, suggest consider updating jquery version (& other libraries depending on jquery) need single version. might little bit of work. worth it. not need workarounds
another option use separate layout file specific view
Comments
Post a Comment