#3 Passing parameters with turnOn
Requirements
Resources
Pass function parameters with turnOn
In this page turnOn passes parameters to a JavaScript function. The passed parameters then get deconstructed and used for DOM manipulation.
In this tutorial you'll learn how to:
- Pass parameters to JavaScript functions using turnOn.
- Deconstruct passed parameters
Output
turnOn Example 1 hasn't started yet.
turnOn Example 2 hasn't started yet.
#3 Passing parameters with turnOn
Source Code of this file
Below you'll see the source code of the file. Note that we're just showing the main part, and hiding some parts of the file which are not relevant for understanding the essentials. Click to expand the code
@using ToSic.Razor.Blade; @inherits Custom.Hybrid.Razor14 <!-- unimportant stuff, hidden --> <div @Sys.PageParts.InfoWrapper()> @Html.Partial("../shared/DefaultInfoSection.cshtml") <div @Sys.PageParts.InfoIntro()> <h2>Pass function parameters with turnOn</h2> <p>In this page turnOn passes parameters to a JavaScript function. The passed parameters then get deconstructed and used for DOM manipulation.</p> <br> In this tutorial you'll learn how to: <ul> <li> Pass parameters to JavaScript functions using turnOn. </li> <li> Deconstruct passed parameters </li> </ul> Look at the text below to see the effect. </div> </div> <div id="turn-on-example"> turnOn Example 1 hasn't started yet. </div> <div id="turn-on-example-deconstruct"> turnOn Example 2 hasn't started yet. </div> @* Passes the parameters Hello for greeting and World for name in a JSON format and executes the window.turnOnTutorial110.init function *@ @* This tutorial uses turnOn, see turnOn tutorials *@ @{ var data = new { greeting = "Hello", name = "World" }; var dataDemo = new { greeting = "Hello", name = "Moon" }; } @Kit.Page.TurnOn("window.turnOnTutorial110.init()", data: data) @Kit.Page.TurnOn("window.turnOnTutorial110.demoDeconstruct()", data: dataDemo) <script src="@CmsContext.View.Path/110-parameters.js" @Kit.Page.AssetAttributes()></script> @* Footer *@ @Html.Partial("../Shared/Layout/FooterWithSource.cshtml", new { Sys = Sys })