Using Telerik MVC with your own custom jQuery and or other plug-ins

Posted by Steve Clements on Geeks with Blogs See other posts from Geeks with Blogs or by Steve Clements
Published on Wed, 05 Jan 2011 15:11:31 GMT Indexed on 2011/01/05 15:54 UTC
Read the original article Hit count: 253

Filed under:

If you are using MVC it might be worth checking out the telerik controls (http://demos.telerik.com/aspnet-mvc), 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!!

© Geeks with Blogs or respective owner