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

Telerik's JQuery version in conflict with the JQuery.validate.unobtrusive lib

4 Answers 537 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.
rodri
Top achievements
Rank 1
rodri asked on 05 Jan 2011, 05:02 PM
[ASP.NET MVC 3 RC 2, Telerik ASP.NET MVC Extensions]
Hi,

I'm using  the MS's unobtrusive library for my validation and of course your extensions.

I have to prevent the double clic on my forms so I call the valid() method (on the form) which comes from the JQuery.validate library. My call to valid() works well on pages where telerik is not used, I mean where ScriptRegistrar is not placed.

I assume there's a conflict between the JQuery lib from Telerik (v JQuery-1.4.3.min.js) vs mine (JQuery-1.4.4.min.js) because when I run this script:
$('form').valid()

I have an error message telling me that the valid method is not a function.

if I remove my reference to my JQuery library, unobtrusive doesn't either.

I'm attaching a case with telerik and without it.
Can you help me out?

best regards

Rodrigo Caballero

4 Answers, 1 is accepted

Sort by
0
rodri
Top achievements
Rank 1
answered on 07 Jan 2011, 03:52 PM
Answering to myself,

[HOW I SOLVED IT]

1. I left my call to JQuery library at the begging of my layout:
<script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
If I don't do this, my calls to JQuery functionality won't work.

2. Then at the end, I modified the default ScriptRegistrar method to:

@Html.Telerik().ScriptRegistrar().Scripts(scripts =>
            scripts.AddGroup("CommonScript", group =>
                group.Add("~/Scripts/jquery-1.4.4.min.js")
                     .Add("~/Scripts/jquery.validate.js")
                     .Add("~/Scripts/jquery.validate.unobtrusive.js")
                     .Add("~/Scripts/JQueryUI/jquery.ui.core.js")
                     .Add("~/Scripts/JQueryUI/jquery.ui.widget.js")
                     .Add("~/Scripts/JQueryUI/jquery.ui.position.js")
                     .Add("~/Scripts/JQueryUI/jquery.ui.dialog.js")
            )
         )
3. Finally, I had to copy my jquery.validate.unobtrusive.js file to the telerik's "2010.3.1110" folder

Now it works fine. although I can't call some JQuery functions like the "JQuery" selector i.e. JQuery("#myDiv") -> replace it for $("#myDiv"). I don't know if I'll have any throuble in the future with any other library.
0
Kenneth
Top achievements
Rank 1
answered on 11 Mar 2011, 04:47 PM
Try using:

<%= Html.Telerik().ScriptRegistrar().jQuery(false) %>

This tells Telerik's ScriptRegistrar to ignore adding jQuery files as they're already handled elsewhere.
0
Agzam
Top achievements
Rank 1
answered on 26 May 2011, 04:14 PM
well, even after putting 
Html.Telerik().ScriptRegistrar().jQuery(false) 
it still loads jquery.validation.min.
how to prevent this?
0
Lee
Top achievements
Rank 1
answered on 06 Sep 2011, 08:20 PM
Html.Telerik().ScriptRegistrar().jQuery(false).jQueryValidation(false)

that's the command you are looking for. 
Tags
General Discussions
Asked by
rodri
Top achievements
Rank 1
Answers by
rodri
Top achievements
Rank 1
Kenneth
Top achievements
Rank 1
Agzam
Top achievements
Rank 1
Lee
Top achievements
Rank 1
Share this question
or