我有一个这样的向导:http: //jsfiddle.net/rniemeyer/FyuSD/当我单击按钮时,当前步骤的下一个数据将发送到服务器中的服务器(发送数据的功能未显示在此链接中)我有这样的动作:
控制器:
[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);
});
};
在第一步中,我有两个用于两个社交网络的复选框,当用户检查复选框数据时,它发送到动作 SocialNetworkChoice。if (q.Count() > 0) 操作“LinkAccount”的视图不显示,向导进入第二步
如果 (q.Count() > 0) 重定向到 LinkAccount (View) 否则到第二步,如何解决这个问题
我很抱歉我的英语不好,
谢谢,