jQuery 脚本被多次附加并与 DevExpress 脚本混淆

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

我已经使用 jQuery UI 可拖动插件对 MVC 网格中的项目重新排序。但是我收到错误 "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>

我在索引中使用了上面的代码,web.config设置如下。

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

听起来问题是因为这个 CDN 脚本定义而发生的,它实际上在相应的视图页面中注册了单独的 jQuery 副本,同时自动脚本注册功能仍然启用并导致资源冲突:

<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>

请注意,某些 DevExpress 扩展(GridViewPivotGridReportsCharts 等)需要外部客户端 JS 库才能正确使用其功能,并在 web.config 文件中启用某些设置时自动注册(最引人注目的是 <resources> 部分)。这是启用脚本注册的解释,摘自 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.

如果您想手动注册 jQuery 库,请尝试删除 web.config 中的自动脚本注册功能(有关详细信息,请参阅下面的参考资料)。

参考文献:

Script Registration Issues

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

Embedding Third-Party Libraries