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

[Solved] Web Assets Documentation

2 Answers 93 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.
Steve
Top achievements
Rank 1
Steve asked on 28 Nov 2009, 08:25 PM
I've read through the document on web assets, and I'm finding this to be... confusing  :)

I follow that a Master page contains the registration of scripts used throughout the site.

What I don't understand are how to setup page specific scripts.  It never shows an actual example in the documentation so it left me confused.

I see another thread on xml... but I'm not going that route - I'm trying to get away from xml  :)   

Let me understand this:
I have a page that has a jQuery tablesorter script that I normally call in the head of the page and it's specific to that page:

ie.
$(document).ready(function() { 
   $("#SummaryTable").tablesorter({ widthFixed: true }); 
}); 

So I need a page specific setup for this ?  

Do I have multiple ScriptRegistrar - one for the site, and one for each page ?

Some samples in the documentation would be helpful - this is going to be a common theme for building pages.  I have page specific scripts through my code base.

More explanation is needed please!

Thanks

2 Answers, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 1
answered on 29 Nov 2009, 03:08 AM
Ok, I got this figured out.

Might help to give a few examples still - but it's pretty clear once I realized I could have more than one ScriptRegistrar

Thanks
0
Alex Gyoshev
Telerik team
answered on 30 Nov 2009, 08:37 AM
Hello Steve,

I'm glad that you figured it out by yourself - still, if anyone else stumbles upon this problem, this can be handled by adding a OnDocumentReady handler to the ScriptRegistrar. Just place the following code in your view:

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

Note that the Render method is not called - it should be called only once, in the Master page.

Regards,
Alex
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Steve
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or