我确实有一个表格,其中包含一些数据和一个表格。我在单击表格的任何行时绑定此表格,这意味着与相应行相关的数据被填充到来自数据库的表格中,我担心的是,在来自数据库的这些数据中,其中一个字段是“def_text”,它基本上以 HTML 格式存储,但我想以我绑定它的形式以纯文本格式显示它。
<form class="form report live " data-table="contractlistTable" id="contractlistForm" data-bind="foreach:items" target="_blank" method="post">
<input type="hidden" name="pid" id="pid" />
<div class="control-group ">
<label class="control-label">Title</label>
<div class="controls">
<input type="text" id="title" name="title" required title="required" placeholder="title" data-bind="value:title" />
<input type="checkbox" id="active" name="active" class="check" data-bind="checked: active=='true'" />Active
</div>
</div>
<div class="control-group ">
<label class="control-label">Default Text</label>
<textarea id="def_text" name="def_text" class="htmleditor" rows="9" cols="50" style="width: 600px; height: 190px;" data-bind="value:def_text"> </textarea>
</div>
</form>
这是表格,表格的代码是
<table class="table table-hover table-bordered" id="contractlistTable" style="width: 304px;">
<thead>
<tr>
<th>Title</th>
<th>Active</th>
</tr>
</thead>
<tbody data-bind="foreach:items" class="bindable" data-model="companycontract">
<tr data-bind="attr:{'data-value': id,'data-index':$index}">
<td data-bind="text:title"></td>
<td>
<!-- ko if:active === 'true' -->
<span class="badge badge-success"></span>
<!-- /ko -->
<!-- ko if: active === 'false' -->
<span class="badge"></span>
<!-- /ko -->
</td>
</tr>
</tbody>
</table>
并且为了绑定它,我正在使用 Knockout.js
$(function () {
var myForm = "";
var formFields;
$("#contractlistTable tbody tr").live('click', function () {
var data = [model.companycontract[$(this).attr("data-index")]];
if (!!formFields) formFields.refill(data);
else {
formFields = new DynamicModel(data);
ko.applyBindings(formFields, document.getElementById("contractlistForm"));
};
var id = [$(this).attr("data-value")];
var kunnr = $('#kunnr').val();
$('.report').attr("action", 'http://wcidevapps.com/salescentral/pcontract.php?ct=i&knr=' + kunnr + '&cid=' + id);
});
});
所以请帮我解决这个问题..