Reputation: 86
I am trying to call a jquery method from inside a view, I found some help on stack overflow, however for me it does not seem to work, any idea why?
@{
var status = Model.Status;
}
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
$(document).ready(
function DisableFeature() {
alert("here");
}
@if (status != 1)
{
//<h1>It worked!!</h1>
DisableFeature();
}
);
</script>
}
DisabledFeature() gets underlined in red when I call it and says "the name DisabledFeature does not exist in the current context".
Upvotes: 1
Views: 56
Reputation: 1
You can try this:
@{
var status = Model.Status;
}
@if (status != 1)
{
<script>
$(document).ready(function () {
function DisableFeature() {
alert("here");
}
DisableFeature();
});
</script>
}
Checking for status
before calling javascript.
Upvotes: 1