@Ajax.ActionLink("new game", "Game",null, ajaxMainArea,new { @id="aNewGame" })
スクリプトで、機能を要素にバインドします。
$(function () {
$("#aNewGame").click(function (e) {
e.preventDefault();
$.get("YourController/ActionMethod", { yourData: "someValue" }, function (response) {
//Do whatever with the reponse.
});
});
});
ページにjQueryがロードされていると仮定します。
そのようなリンクを使用してカスタム作業を行っている場合は、通常のActionLink
HTMLヘルパーを使用して、このような機能をバインドします。
@Html.ActionLink("new game", "Game",null,new {@id="aNewGame"})
スクリプトは
$(function () {
$("#aNewGame").click(function (e) {
e.preventDefault();
$.post("YourController/ActionMethod", { yourData: "someValue" }, function (response) {
$("#main_area").html(response);
//If you want to do something else, you can do it here. :)
});
});
});