View Problem

Topics: General
Mar 28, 2011 at 9:30 PM

Using the latest dev branch in my View the text 'Orchard.UI.Resources.RequireSettings' is always displayed above "Customer Information.

Index.cshtml

@Script.Require("jQuery")
<h2>Customer Information</h2>
@using (Script.Foot())
{
<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        alert('page loaded');
    });
</script>
}

Coordinator
Mar 28, 2011 at 9:49 PM

Script.Require is meant to be used as a statement. It does not output any HTML. Rather, it returns an object that allows you to further customize 'settings' on the requirement (e.g. that you require the script to be in the head section, Script.Require(..).AtHead().

You are using @Script.Require which means you are outputting the return value. Razor converts it to a string since it doesn't know what to do with it, and that's just the name of the class that was returned.

Use this syntax instead:

@{
Script.Require("jQuery")
}

Apr 25, 2012 at 9:30 PM

I was having exactly the same problem. The solution is obvious now that you point it out. Thanks.