Telerik (). ScriptRegistrar () How to prevent jquery libraries from loading?

Script logger loads jquery.validation.min.js even after

Html.Telerik().ScriptRegistrar().jQuery(false) 

Is there any way to say this not to do this?

Even when I try to download exactly what I need, do the following:

 @Html.Telerik().ScriptRegistrar().jQuery(false).DefaultGroup(g => { g.Add("telerik.common.min.js"); g.Add("telerik.tabstrip.min.js"); } 

And if, for example, I have a telerik grid on the page, it will load all the necessary scripts, including grid.min, grid.editing and jquery.validate.min.

I prefer to control it myself, but instead just get an error or broken elements if I forget to identify the correct scripts.

If I try to use this snippet:

 @Html.Telerik().ScriptRegistrar().jQuery(false).Scripts(s => { s.Add("telerik.common.min.js"); ... 

It ignores useTelerikContentDeliveryNetwork="true" in web.config and searches for scripts on the local server. I still want to use CDN.

UPD: Is there a way to use telerik CDN sources, but if for some reason they do not work, download all the materials from the project server?

+6
source share
2 answers

As an additional update to this answer for people coming from search engines: now you can remove jQuery Validation in addtion for jQuery using something like:

 @Html.Telerik().ScriptRegistrar().jQuery(false).jQueryValidation(false) 
+10
source

.jQuery(false) really prevents jquery.js only from being included. This does not affect jquery.validate.js and was never intended. There is currently no way to stop ScriptRegistrar from turning on jquery.validate.js when there is an editable grid on the page.

There is no built-in backup support if you use Telerik CDN. However, a manual workaround may be implemented. Something like that:

 @(Html.Telerik().ScriptRegistrar()) <script type="text/javascript"> if (typeof jQuery === "undefined" || typeof $.telerik === "undefined") { // the CDN failed for some reason use local files document.write("<script src='scripts/telerik.common.min.js'><\/script>"); document.write("<script src='scripts/telerik.grid.min.js'><\/script>"); // etc } </script> 
+4
source

Source: https://habr.com/ru/post/889126/


All Articles