0
我有一个向导这样的:http://jsfiddle.net/rniemeyer/FyuSD/当我点击按钮当前步骤的下一个数据被发送到服务器中我有服务器(发送数据其不在该链接显示功能)像这样的动作:敲除向导用Asp.net MVC3
控制器:
[HttpPost]
public ActionResult SocialNetworkChoice(string[] selectedSocialNetwork)
{
if (selectedProduct!= null)
{
// check if the user got a social account linked in for
// all the selected networks and redirect to the link account page
....
if (q.Count() > 0)
{
return RedirectToAction("LinkAccount", "Account",
new LinkAccountModel() { ProviderName = q.First() });
}
else
{....}
}
}
敲除:
<script id="socNetchoiceTmpl" type="text/html">
<ul data-bind="foreach: socialNetworksList, visible:
socialNetworksList().length > 0">
<li>
<input type="checkbox" data-bind="value: $data, checked:
$parent.selectedSocialNetworks" /><span data-bind="text: $data"/>
</li>
</ul>
</script>
function SocialNetChoicesViewModel() {
var self = this;
self.socialNetworksList = ko.observableArray([]);
self.selectedSocialNetworks = ko.observableArray([]);
self.save = function() {
$.ajax("/Home/SocialNetworkChoice", {
data: ko.toJSON({ selectedSocialNetworks: self.selectedSocialNetworks }),
type: "post", contentType: "application/json",
success: function (result) {
if (result.Success) {
//alert(result.Message);
}
else {
alert(result.Message);
}
}
});
};
// Load initial state from server, convert it to Task instances,
// then populate self.tasks
$.getJSON("/Home/SocialNetworkChoice", function (allData) {
var mappedItems = $.map(allData, function (item) { return item });
self.socialNetworksList(mappedItems);
});
};
在第一步我有两个社交网络复选框,当用户检查ckeckbox数据发送到行动SocialNetworkChoice。 (q.Count()> 0)如果(q.Count()> 0)不显示动作视图“重定向到LinkAccount(查看)别的第二步
我为我的英语不好对不起,
感谢,
我不熟悉knockout ..哪一段代码在Javascript中调用您的控制器? – ikh 2012-08-08 13:57:51
@ikh当我点击按钮下一个功能保存其调用 – ramo 2012-08-08 14:17:56