エイ!モデルのデータを使用して部分ビューを更新するにはどうすればよいですか? 初めて、ページが読み込まれると正しく動作しますが、アクションから呼び出すと動作しません。私が作成した構造は次のようになります。
私のビューのどこでも:
@{ Html.RenderAction("UpdatePoints");}
私のPartialView「UpdatePoints」:
<h3>Your points are @ViewBag.points </h3>
コントローラーには次のものがあります。
public ActionResult UpdatePoints()
{
ViewBag.points = _Repository.Points;
return PartialView("UpdatePoints");
}
ご協力いただきありがとうございます!
アップデート
助けてくれてありがとう!最後に、モデルを使用してパラメーターを渡し、提案したように JQuery/AJAX を使用しました。
したがって、JS では次のようになります。
$('#divPoints').load('/Schedule/UpdatePoints', UpdatePointsAction);
var points= $('#newpoints').val();
$element.find('PointsDiv').html("You have" + points+ " points");
コントローラーで:
var model = _newPoints;
return PartialView(model);
ビューで
<div id="divPoints"></div>
@Html.Hidden("newpoints", Model)