i have try to add in the @RenderSection("Header") in Master.cshtml and also
@section Header {
<p>Hello bbbbbbbbbbbbbbb</p>
}
in Home.cshtml, when i run the web and look at the source of the page, the 'Hello ......' is not in the source, i am missing something ?
I am new to umbraco, just install it 1 week ago, and i just need to execute some javascript in my page, the umbraco TV javascript video is useless, just show javascript alert, the video should show step by step how to modify the Master.cshtml or Home.cshtml or _layout.html to import the js file, and how to execute the js file function into page ( template ? partial view ? or ? )
* i am using umbraco starter kit, in this project got any javascript sample ?
and it executes just fine when I click on any page.
Also tried it from a custom /scripts/script.js file (added it in the Settings section under Scripts) and that worked as well after adding it to the Master template like so:
JavaScript runtime error: '$' is undefined
Hi,
i have add below line into Master.cshtml inside
<body ... </body>
when i run the web, i am getting '$' undefined
* i try to move above line into
<head> ... <head>
result still the same.this is my partial view :
Please help. Thanks.
View the source of the page. If the script block is rendered before the reference to the jquery file then you'll get this.
Also check that the jquery file is being loaded successfully (use browser tools - look for a 404 in the network tab).
The best way of doing this is to add the scripts at the bottom of the master template and then your custom scripts below it from the page templates - use a template section to do this - see http://www.computermagic.gr/tutorials/umbraco-7/templates/sections/
Though if you want custom javascript in the partials you might not be able to go this way.
Hi Steve,
i have try to add in the
@RenderSection("Header")
in Master.cshtml and alsoin Home.cshtml, when i run the web and look at the source of the page, the 'Hello ......' is not in the source, i am missing something ?
I am new to umbraco, just install it 1 week ago, and i just need to execute some javascript in my page, the umbraco TV javascript video is useless, just show javascript alert, the video should show step by step how to modify the Master.cshtml or Home.cshtml or _layout.html to import the js file, and how to execute the js file function into page ( template ? partial view ? or ? )
* i am using umbraco starter kit, in this project got any javascript sample ?
Please help.
Hi Steve
The starterkit already loads in jQuery. You can see it in the bottom of the Master template.
I tried adding some jQuery both in the existing
umbraco-starterkit-app.js
like this:and it executes just fine when I click on any page. Also tried it from a custom
/scripts/script.js
file (added it in the Settings section under Scripts) and that worked as well after adding it to the Master template like so:Either way the custom script runs after loading in jquery. If you execute your script before it will not work.
If you want to use named sections from a child template you will have to render the section after as well in Master.cshtml. Eg:
and then from the child template, eg. Home.cshtml:
You cannot use sections from a partial view, only from child tempates.
Hope that helps :)
all the best
Rune
thanks.
You're welcome :D
is working on a reply...