Hi everyone. I'm new to umbraco, and learning by doing and reading documentation.
I currently don't have any custom controllers yet. I am grabbing & parsing the data from CMS to the Views by setting up something like the below at the top of every .cshtml file
@{
var allDataToDisplay = Model.Root().Descendants(ContentType.SomeDocType).ToList();
}
I realise this may not be ideal.
I want to pass data from the CMS (i.e. allDataToDisplay variable) to some javascript at the bottom of .cshtml to render/reload the page in some way. The original intent is to store query string via javascript to create a multi-dropdown list sort.
Passing values from view .cshtml to javascript
Hi everyone. I'm new to umbraco, and learning by doing and reading documentation.
I currently don't have any custom controllers yet. I am grabbing & parsing the data from CMS to the Views by setting up something like the below at the top of every
.cshtml
file@{ var allDataToDisplay = Model.Root().Descendants(ContentType.SomeDocType).ToList(); }
I realise this may not be ideal.I want to pass data from the CMS (i.e.
allDataToDisplay
variable) to some javascript at the bottom of.cshtml
to render/reload the page in some way. The original intent is to store query string via javascript to create a multi-dropdown list sort.``` @foreach (var item in allDataToDisplay) {
Hi Rachel,
first of all welcome to the Umbraco Community!
Can you give some more details about what you are trying to do because its not completely clear what you are trying to achieve.
Do you want to render a dropdown based on this list and use javascript to perform an url change with a querystring? Is that correct or... ?
/Michaël
Example of how I've used Razor within JavaScript:
Just by adding the '@' before your c# variable within the js calls that variable.
is working on a reply...