jqueryasp.net-mvcdevexpressdevexpress-mvc

jQuery script was attached multiple times and mixed up with DevExpress scripts


I have used the jQuery UI Draggable plug-ins to reorder an items in MVC grid. However I'm getting error "jQuery script was attached multiple times and mixed up with DevExpress scripts."

<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<script>
    var jq112 = jQuery.noConflict(); //
</script>

I have use the above code in the index and web.config settings as below.

<settings rightToLeft="false" embedRequiredClientLibraries="true" doctypeMode="Xhtml" />

enter image description here


Solution

  • Sounds like the problem occurred because of this CDN script definition, which actually registers separate jQuery copy inside corresponding view page while automatic script registration feature is still enabled and causing resource conflict:

    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
    

    Note that some DevExpress extensions (GridView, PivotGrid, Reports, Charts etc.) require external client-side JS libraries to use their functionality properly, and automatically registered while certain settings enabled inside web.config file (most noticeable is in <resources> section). Here is an explanation why the script registration is enabled, taken from knowledge base:

    The client-side resources are automatically added to the Web.config file on adding a DevExpress web control to your application using the DevExpress template gallery. In this case, all necessary client-side libraries are automatically passed to the client.

    If you want to register jQuery libraries manually, try remove automatic script registration feature in web.config (see references below for further details).

    References:

    Script Registration Issues

    How to register DevExpress scripts with external client libraries that use jQuery

    Embedding Third-Party Libraries