[英]Bind Action not working outside of the partialview
When I take away from the PartialView the click action jquery, the code stop working: 当我从PartialView拿走click action jQuery时,代码停止工作:
Partial View: 部分视图:
@model Heelp.ViewModels.CategoryGetAllBySearchListViewModel
<p class="float-left margin-top align-left"><span>Encontrámos <em><a href="#">@Model.TotalSearchCount</a></em> resultados nas categorias:</span></p>
<div class="clear-both">
<div id="searchResultsList" class="float-left">
<ul>
@foreach (var item in Model.CategoryGetAllBySearch)
{
<li>
@Html.ActionLink(
String.Format("{0} {1} ver »", item.SearchCount, item.Name),
MVC.Company.GetAllByCategory(item.Id, Model.Search, Model.Location, Model.IsCenterFromUser, Model.CenterLng, Model.CenterLat, Model.SearchRadius),
new { id = "getCompanies" })
</li>
}
</ul>
</div>
</div>
<script>
$("#getCompanies").on("click", function()
{
$.ajax({
url: this.href,
cache: false,
success: function (result) {
companyGetAllByCategoryOnSuccess(result);
}
});
return false;
});
</script>
If I put the script code in an external JS file, the code don't work, why? 如果我将脚本代码放在外部JS文件中,则该代码不起作用,为什么?
Thanks. 谢谢。
I removed all the validation and unobtrusive js files from the project and reload them from NuGet, and everything got solved. 我从项目中删除了所有验证和不干扰js的文件,然后从NuGet重新加载它们,一切都解决了。
Thanks for the help. 谢谢您的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.