Can anyone help me understand what's causing an issue with this call to a partial view that has its own JavaScript code?
This is the main cshtml file:
@model Ads_Negocio.FormTest
@{
ViewBag.Title = "Reportone";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div> <p>Parent view</p> </div>
<p>----------Partial view section-----------</p>
<div>
<p>Partial view</p>
@Html.Partial("Componente/_aTestView")
</div>
@section scripts{
<script type="text/javascript">
$(document).ready(function () {
alert("parent view rendering")
});
</script>
}
The partial view _aTestView.cshtml:
<button type="button" id="btnGraficNew">Run</button>
<script type="text/javascript">
$(document).ready(function () {
alert("partial view rendering");
$("#btnGraficNew").click("click", function () {
alert("Call from partial view");
});
});
</script>
Issues:
- The alert inside the partial view is never triggered after the view is rendered.
- When pressing the button, no alert is displayed.