If you want to pass a razor var to a function you can do this:
@{
var someItem = "Hello! Welcome to MVC";
}
<script type="text/javascript">
$(document).ready(function () {
alert(@someItem );
});
</script>
I think you might consider something like this as an alternative:
@{
var kit = new Test.Controllers.kitClass("something");
Func<bool,bool> Incio = delegate(bool cleanMe) { return kit.clean(); };
}
<script type="text/javascript">
$(document).ready(function () {
executeTheFunc();
});
function executeTheFunc() {
if('@Incio(true)' == 'True'){
alert("This is clean!");
} else {
alert("This is not clean!");
}
}
</script>
Mock class - not sure what yours looks like:
public class kitClass {
public kitClass(string something) {
}
public bool clean() { return true; }
}