This is a migrated thread and some comments may be shown as answers.

[Solved] Script conflicts when using Telerik controls

4 Answers 256 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Max
Top achievements
Rank 1
Max asked on 28 Nov 2011, 06:41 PM
Hi all,
Every time I try to use a jquery UI control or even a @Ajax.ActionLink call I get all sorts of errors: "jQuery undefined, Dialog not defined, etc"
I try to use jQuery(false) and then manually register the rest of the scripts like the code below in my Layout file.
The problem is that I don't know how to find out what script is missing.
@(Html.Telerik().ScriptRegistrar()
              .jQuery(false)
              .DefaultGroup(group => group
              .Add("telerik.common.js")
              .Add("telerik.grid.min.js")
              .Add("telerik.component.js")
              .Add("~/Scripts/MicrosoftAjax.js")
              .Add("~/Scripts/MicrosoftMvcAjax.js")
              .Add("~/Scripts/jquery.unobtrusive-ajax.js")
              .Add("~/Scripts/jquery.validate.js")
              .Add("~/Scripts/jquery.validate.unobtrusive.js")                                                                                                      .Combined(true).Compress(true)
              )
)

If you are using Telerik controls, and jQuery UI controls and also the Ajax.ActionLink calls, what is the best way to register the scripts?What scripts do I need? how to pinpoint WHAT is missing?

Thank you

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 28 Nov 2011, 07:08 PM
Hi Max,

In your case you should register jQuery before the ScriptRegistrar. A list ot required Javascript files for each component can be found at:

http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-required-javascript-files.html

However, in standard scenarios you don't have to register any Telerik scripts manually, the ScriptRegistrar takes care of that.

Is there a specific problem when you disable automatic jQuery registration?

Kind regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Max
Top achievements
Rank 1
answered on 28 Nov 2011, 09:00 PM
Hello Dimo,
I am not sure what a "standard scenario" would be (perhaps only Telerik controls). However, my experience so far is that every time I try to use a jQuery ui control such as a popup window I would get an error such as .Dialog method not existent or something like that.

If I used .jQuery(false) then the error would go away but the Telerik controls would not work. So with your advice, once I registered everything BEFORE the ScriptRegistar() call, the error went away but I still have problems with Ajax calls.

So I guess my question would be: what exaclty is ScriptRegistrar().DefaultGroup() registering? Besides the files you mentioned in your link : http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-required-javascript-files.html ; what other files I have to register if I run:
jQuery(false) and jQueryValidation(false)

All I am trying to do is to avoid conflicts with ScriptRegistrar().DefaultGroup() because I dont know what it is actually registering .

Thank you for your time on this matter. I am now half way to resolve my issues :)

PS: this is the "final" code in case you were interested:
<head>
    <link href="@Url.Content("~/Content/demos.css")" rel="stylesheet" type="text/css" />
 
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")"                 type="text/javascript"></script>
    @*<script src="@Url.Content("~/Scripts/jquery-ui.min.js")"                  type="text/javascript"></script>*@
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"      type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")"              type="text/javascript">)</script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"  type="text/javascript"></script>
 
    <script src="@Url.Content("~/Scripts/MicrosoftAjax.js")"                    type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")"                 type="text/javascript"></script>
 
    @(Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.windows7.css").Combined(true).Compress(true)))
 
</head>
...
 
    @(Html.Telerik().ScriptRegistrar()
                    .jQuery(false)
                    .jQueryValidation(false)
                    .DefaultGroup(group => group
                                        .Add("telerik.common.js")
                                        .Add("telerik.component.js")
                                        .Add("telerik.grid.js")                                                                                                         
                                        .Combined(true).Compress(true)                                                       
                                 )
    )

0
Accepted
Dimo
Telerik team
answered on 29 Nov 2011, 08:28 AM
Hi Max,

Standard scenarios include scenarios in which you don't need additional Telerik scripts after an AJAX request, but even these cases are now handled by the ScriptRegistrar when using the latest version of our MVC components.

If you disable the automatic jQuery registration, there is nothing else to register manually besides the jQuery scripts.

If you disable combining and compression, you can easily see what script files the ScriptRegistrar is calling.

The Default web asset group is simply the only group the ScriptRegistrar is using. You can add more groups manually.

By the way, I am not aware of a telerik.component.js file, I suppose this is something yours.

Also, you should make sure that the jQuery version that you are using is compatible with the MVC component's version (it would be best to be the same as the one that the ScriptRegistrar would register).

Your code looks OK to me. If your problem persists and you believe it is caused by our MVC components, please send a runnable demo for me to inspect locally.

Kind regards,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Max
Top achievements
Rank 1
answered on 29 Nov 2011, 04:38 PM
I think the telerik.component.js was something I copied from Internet, that file does not exist! :)

Thank you so much Dimo!!!
Tags
General Discussions
Asked by
Max
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Max
Top achievements
Rank 1
Share this question
or