Guillermo Ruffino
Guillermo Ruffino

Reputation: 3020

Using Script # 0.7 with MVC 3

I'm trying to use Script# 0.7 with MVC 3 using the ScriptSharpSection and all that stuff. So far I'm doing

@{ Ajax.InitializeScripts();  
   }

but I get the exception: "The referenced script named 'loader' was not registered in configuration as a script."

I can bypass that exception adding a <script name="loader" ... but I don't know that scripts has to do.

Is there any example showing how this is done? Thanks.

Upvotes: 0

Views: 570

Answers (1)

Nikhil Kothari
Nikhil Kothari

Reputation: 5225

I still need to get examples out.

Does your web.config have this:

  <configSections>
    <section name="scriptSharp" type="ScriptSharp.Web.Configuration.ScriptSharpSection, ScriptSharp.Web"
             allowDefinition="MachineToApplication" requirePermission="false" />
  </configSections>
  ...
  <scriptSharp clientScriptStorageCookie="scripts">
    <script name="loader" url="/Content/Scripts/ssloader.js" version="0.7" />
    <script name="loader.debug" url="/Content/Scripts/ssloader.debug.js" version="0.7" />
    <script name="core" url="/Content/Scripts/mscorlib.js" version="0.7" />
    <script name="core.debug" url="/Content/Scripts/mscorlib.debug.js" version="0.7" />
    <script name="jquery" url="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" />
    <script name="jquery.debug" url="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js" />
  </scriptSharp>

And do you have the ssloader.js script to go along with it?

The MVC APIs render out scripts that are then downloaded by the script loader while managing dependency order etc. For now it is required. Eventually I need to add couple of things:

  1. Have a mode where this is not required, i.e. it does the dependency ordering on the server and renders out vanilla script tags.
  2. Have the ss.init/ss.ready callback functionality implemented in mscorlib.js as well, if someone is only loading mscorlib.js and not ssloader.js.

Hope that explains the current implementation and what will be added in the future to make ssloader.js optional.

Upvotes: 1

Related Questions