带有ko data-bind的@ Html.ActionLink

时间:2013-02-20 16:23:13

标签: asp.net-mvc-4 knockout.js

首先,是否可以将@Html.ActionLink用于敲除绑定?

如果是,我该怎么写?

这就是我需要的:

@Html.ActionLink( [I want display QuestionID() - a ko view model property] , "Question [controller action name]", "Project [controller name]", new { project = [here should be ProjectID() - a ko view model property]  id = [here should be QuestionID() - a ko view model property] }, new Dictionary<string, object> { { "data-bind", "title: 'View detailed question page'" } }))

简单来说,渲染时应该如下所示:

  

https://plus.google.com/photos/105612417165831662125/albums/5847070406315217649?authkey=CPqQ2oGYn46GFQ

提前致谢。

1 个答案:

答案 0 :(得分:1)

您当然可以在ActionLink中包含data-bind个属性;请看this question and its answers了解如何做到这一点。但请记住,Knockout纯粹是客户端,因此当你想让Knockout与MVC交谈时,你需要提出某种AJAX请求。