Archives / 2011 / January
  • Using Telerik MVC with your own custom jQuery and or other plug-ins

    Tags:, .NET, .NET 4.0, MVC

    If you are using MVC it might be worth checking out the telerik controls (, they are free if you are doing an internal or “not for profit” application.

    If however you do choose to use them, you could come up against a little problem I had.  Using the telerik controls with your own custom jQuery.  In my case I was using the jQuery UI dialog.

    It kept throwing an error where I was setting my div to a dialog.

    Code Snippet
    1. $("#textdialog").dialog({

    The problem is when you use the telerik mvc stuff you need to call ScriptRegistrar

    Code Snippet
    1. @Html.Telerik().ScriptRegistrar()

    in order to setup the javascript for the controls.

    By default this adds a reference to jQuery and if you have already added a reference to jQuery because you are using it elsewhere, this causes a problem.

    I found the solution here

    And it was to change the above ScriptRegistrar call to this…

    Code Snippet
    1. @Html.Telerik().ScriptRegistrar().jQuery(false).DefaultGroup(g => g.Combined(true).Compress(true));

    If you come across this one on stackoverflow it wont work – in my case the HtmlEditor would render no problem, but was unusable.  Which is the same as someone else found when using the tab control – they went to the bother of re-writing the ScriptRegistrar.  Not for me that one!!