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

Is there any harm in this?

3 Answers 44 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.
Kyle Pike
Top achievements
Rank 1
Kyle Pike asked on 08 Sep 2010, 06:39 PM
wrapping a
<script type="text/javascript">
// nothing here
</script>


around the

<% Html.Telerik().ScriptRegistrar()
       .OnDocumentReady(() =>
       { %>
 
//stuff
 
<%
       });
%>

in my view pages?
that allows Visual Studio to format my jQuery/js code correctly and offer intellisense...

I'm wondering if there's a better way to get there than adding 58 bytes to every view?

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 09 Sep 2010, 12:16 PM
Hi Kyle Pike,

Unfortunately this is not correct HTML.

After first closing script tag the code is not anymore interpreted as Javascript. In other words the code after first closing script tag will not work.

Anyway you can add script tag, only when you type, and remove it when you save the file. Unfortunately I could not figure out better way to enable intellisence in the action.

Sincerely yours,
Georgi Krustev
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
0
Kyle Pike
Top achievements
Rank 1
answered on 14 Sep 2010, 08:12 PM
no, i meant wrapping the script tags around the telerik block. it's valid html as long as you leave something - one comment - in there between the script tags.
0
Alex Gyoshev
Telerik team
answered on 15 Sep 2010, 09:18 AM
Hello Kyle,

Unfortunately, we cannot control the syntax highlighting, nor the VS intellisense in the code block. You figured out a nice hack, though; I assume that you may be able to filter it out from the view through an HTTP module, but it would be too much of a hassle. The other work-around for this is to write the JavaScript in a function in a script block and call it on DocumentReady, like this:

<script type="text/javascript">
function contentLoad() {
    // etc
}
</script>

<% Html.Telerik().ScriptRegistrar().OnDocumentReady(() => {
       %>contentLoad();<%
   }); %>



Best wishes,
Alex Gyoshev
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
Tags
General Discussions
Asked by
Kyle Pike
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Kyle Pike
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or