The problem with this is that I have my own custom controls (html helpers) that initialize on document ready - ie. my own customer masking controls.
Additionally - I do not want to put my script inside my aspx/ascx
Is is possible today to tell Telerik not to hijack the document ready of jQuery ?
5 Answers, 1 is accepted
You can still use $(document).ready. There are two ways to do so:
- Make the ScriptRegistrar not to include jquery by calling the jQuery(false) method and use $(document).ready as you would normally do:
<%= Html.Telerik().ScriptRegistrar().jQuery(false) %>
<script type="text/javascript">
$(document).ready(function() {
alert('ready');
});
</script> - Use any overload of the provided OnDocumentReady method of the ScriptRegistrar object:
- <%= Html.Telerik().ScriptRegistrar().OnDocumentReady("alert('ready')") %>
- <% Html.Telerik().ScriptRegistrar()
.OnDocumentReady(() =>
{ %>
alert('ready');
<%
})
.Render();
%>
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

ie.
On site.master - I am using Telerik Menu (and on some pages, I am using Telerik datepicker)
Additionally, on those pages I have my own customer html controls that use jQuery (programmatically they render the javascript and html)
If I turn off jQuery - does that mean the menu and datepicker won't work ?
Some clarification needed.
No, it just means that you have to include jquery by yourself.
Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

Please register me as a dissatisfied customer of the Premium package. I buy your software so that it does not break code when I upgrade. You have disappointed me.
I am discovering that the ScriptRegistrar call in the Master page raises a duplicate Render call error when the ScriptRegistrar().OnDocumentReady() "override" is used to cure the problem. So now I am wasting loads of time chasing your little update.
I also don't understand why we haven't gotten a Q2 release of MVC controls. Is this line of software being discontinued? If it looks like it won't be supported, I will be forced to go to other solutions and I won't be looking back.
I think there is some misunderstanding here. I will explain what the ScriptRegistrar does with regards to document.ready
Telerik Extensions for ASP.NET MVC have always used $(document).ready to initialize the client-side component. This cannot be changed as this is the right time to initialize a component. To embed code in our own document.ready handler you can use OnDocumentReady. If you don't want to - nothing prevents you from wiring up document.ready in your own code. Just make sure the jquery JavaScript is included before your script tag. Otherwise you will end up with a JavaScript error. This can be achieved by putting your script tag *after* the ScriptRegistrar which is rendered or by including manually the jquery JavaScript which then needs to disable the automatic including from the ScriptRegistrar by calling jQuery(false).
We have introduced the feature to disable the automatic including of jquery because quite a few 3rd party plugins do not work unless jquery and their own JavaScript files are not included within the HEAD tag of the page. Since the ScriptRegistrar must appear after all Telerik extensions jQuery's javascritp may appear too late.
The duplicate Render exception occurs if you render twice any Telerik UI component. In order to use multiple script registrars you should render only one of them. Here is an example:
Site.master:
// "Master" script registrar
<%= Html.Telerik().ScriptRegistrar() %>
// "Child" script registrar which is not output
<% Html.Telerik().ScriptRegistrar().OnDocumentReady(() =>
{
%>
alert('Child ScriptRegistrar');
<%
}); %>