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

[Solved] Telerik MVC ScriptRegistrar duplicating javascript

0 Answers 102 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.
bbeatty
Top achievements
Rank 1
bbeatty asked on 13 Aug 2012, 05:25 PM
I have the following script in my master layout at the bottom of my _Layout.cshtml page
  @(Html.Telerik().ScriptRegistrar()
        .DefaultGroup(group => group
        .Add("telerik.all.min.js")
        .Add("telerikHelper.js")
        .Add("jquery-ui-1.8.20.js")
        .Add("jquery.form.js")
        .Add("jquery.validate.js")
        .Add("jquery.validate.unobtrusive.js")
        .Add("customValidation.js")
.Add("ba-debug.js")            
                .Compress(true)
                .Combined(true)
     ))
  

I also have the following in my main page


@(Html.Telerik().ScriptRegistrar()
       .DefaultGroup(group => group
           .Add("bbq.js")
           .Add("jquery.form.wizard.js")
           .Add("jquery.alphanumeric.js")
           .Add("jquery.qtip.min.js")
           .Add("StudentRegistration.js")
            )))

The problem is that I'm getting duplicate files. If I turn off combine. I can see multiple js files that are the same.
I've tried switching the main page to use @{} instead of @() as referenced here:http://www.telerik.com/community/forums/aspnet-mvc/general/scriptregistrar-and-razor-duplicating-output-issue.aspx and http://stackoverflow.com/questions/5864506/telerik-mvc-scriptregistrar-duplicating-javascript 
but then I get javascript errors.

Seems that the scripts are not downloading  in the same order as the add. I have methods in StudentRegistration.js that reference methods in customValidation.js but they fail because they cannot be found.

I do not get this error if I allow the duplicates to be downloaded.


Tags
General Discussions
Asked by
bbeatty
Top achievements
Rank 1
Share this question
or