我有一个MVC表单,我正在填充,并能够通过表单发送来回。我有一个淘汰赛observableArray,它正在收集列表中的所选项目。
<select multiple id="RecipientsListSelect" size="20" class="form-control" data-bind="options: recipientList, selectedOptions: selectedRecipientList, optionsText: function(i) {return i.FirstName +' '+ i.LastName}"></select>
我所遇到的是,当我添加data-bind = click:提交到我的提交表单帖子按钮时,我只收到淘汰数据,而不是我的MVC视图中的其他数据
<button type="submit" @*data-bind="click: submit"*@ class="btn btn-primary">Send</button>
这是我的Controller Post方法。
[HttpPost,ValidateInput(false)]
public ActionResult eBlast(eBlastViewModel model)
{
List<string> eblastList = new List<string>();
List<string> recipients = model.Recipients;
var emailText = model.TextMail;
var subject = model.EmailSubject;
MailMessage msg = new MailMessage();
eblastList.Add("");
var eblastsubjecttext = InteBlast.GetSelectedEblastSubjectText(model.EblastSubject);
emailUtility.SendEblastEmail("EBlast", emailText, eblastList, subject, true, "", "ff", msg);
model.ListEblastSubject = InteBlast.GetEmailSubject();
return View(model);
}
这是我的ViewModel
public class eBlastViewModel
{
public IEnumerable<EmailSubject> ListEblastSubject { get; set; }
public int EblastSubject { get; set; }
public string Subject { get; set; }
public string EmailSubject { get; set; }
public List<string> SendEmailToList { get; set; }
public List<string> Recipients { get; set; }
public int[] SelectedRecipients { get; set; }
public string SendEmailTo { get; set; }
public virtual ICollection<EmailContent> Contents { get; set; }
public IEnumerable<HttpPostedFileBase> Attachments { get; set; }
public string TextMail { get; set; }
}
我的帖子Json方法收集我的observable并将其发送给控制器。
$.post("eBlast", request, function () {
})
问题是,如果我摆脱通过淘汰赛将数据发送到帖子,它会在我的视图中发送剩余的数据而不是我的可观察数据。我如何让它发送?
由于我的viewModel中有一个Recipients属性,我试图像这样传递数据
@Html.TextBoxFor(model => model.Recipients, new {data_bind="value: eblastList"})
没有运气