【发布时间】:2017-07-06 09:24:26
【问题描述】:
我有以下淘汰赛
<select multiple="multiple" height="5" data-bind="options:allItems,
selectedOptions:selectedItems"> </select>
上面生成了敲除脚本中“observableArray”中所有项目的列表。
我需要以某种方式绑定它,就好像它是 razor 中的 @html.etc 元素一样。
例如,我有以下
@using (Html.BeginForm("SubmitFull", "ENCOUNTER", null))
{
@Html.HiddenFor(model => model.Name)
@Html.ValidationSummary(true)
<fieldset>
<legend>ENCOUNTER</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Date)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Date)
@Html.ValidationMessageFor(model => model.Date)
</div>
所以当我点击页面底部的按钮时,我在视图顶部定义的模型
@model MVC_MONGODB.Models.PATIENT.Patient
现在将加载一个“日期”属性和一个“名称”属性。
我还需要使用淘汰赛 observableArray 中的值加载模型。我以前从未这样做过,我不确定最好的方法是什么,甚至 任何可能的方式,我什至不能 100% 确定这是可能的。
http://knockoutmvc.com/ 似乎是一个很有前途的参考。
使用“ValueUpdate”似乎是一种可能性,或者可能是某处的(输入类型=“隐藏”)元素..
我想基本上从我在这个问题顶部提到的淘汰代码中获得文本框,就像它实际上在里面一样
@Html.TextAreaFor(model => model.ChiefComplaintsStr, 5, 100, new {
HtmlAttributes = new { } })
【问题讨论】:
标签: asp.net-mvc razor knockout.js