0
Eae guys,
I have a view that renders a partial view.
Index.cshtml
<script type="text/javascript" src="~/Scripts/jquery-2.1.1.js"></script>
<div class="tab-control" data-role="tab-control">
<ul class="tabs">
<li class="active">@Ajax.ActionLink(Resources.Base.Entry, "_List", "Entrada", null, new AjaxOptions() { UpdateTargetId = "_Content", InsertionMode = InsertionMode.Replace, LoadingElementId = "Div_Loading" })</li>
<li>@Ajax.ActionLink(Resources.Base.Data, "_Edit", "Entrada", null, new AjaxOptions { UpdateTargetId = "_Content", InsertionMode = InsertionMode.Replace, LoadingElementId = "Div_Loading" }, new { id = "Dados" })</li>
</ul>
<div class="frames" id="_Content">
@{Html.RenderPartial("_List");}
</div>
</div>
_List.cshtml
$(document).ready(function () {
$.get("@Url.Action("_Grid", "Data")", function (data) {
$('#con').replaceWith(data);
});
});
This view I do the jQuery include on it but in the partial view with this code above it says that jQuery does not exist. If I re-include jquery on top of the above mentioned code it works normal.
There is a way to make all my ajax requests after the page load have access to the included scripts?
All of them are being loaded at the bottom of the page (before the "< body>")
Vlw!
Off: I noticed that there are some questions on Stackoverflow that is worth reputation, how can I ask such a question?
And where should I call this @Section scripts?
– Trxplz0
@Trxplz0 I updated the response.
– Leonel Sanches da Silva
In case when I make the ajax request will it work? I load the page /controller/action it loads me this index.cshtml that renders _List.cshtml. From there all links within _List.cshtml loads via ajax giving replace in the content of the own div #con, which is found in _List.cshtml.
– Trxplz0
If the method of
Controller
return a Partial View as the answer suggests, yes.– Leonel Sanches da Silva
I’ll test the answer. How I was going to put @Rendersection in Layout.cshtml for me would not work since Partialviews does not make use of Layout Master.
– Trxplz0
Yep, it doesn’t work like that, because partial views don’t make use of Layout.cshtml(master) that has Rendersection. The way is to do as you did at the time when ajax became a fever. Intercept the ajax request scripts and interpret manually. Vlw even by the help anyway!
– Trxplz0