【发布时间】:2013-07-25 19:00:54
【问题描述】:
我正在使用敲除将视图绑定到视图模型。
我的看法是
<table>
<tr>
<td data-bind ="text: ConcenatedData"></td>
</tr>
</table>
我的视图模型进行 ajax 调用并将数据绑定到可观察数组
function showData() {
return $.ajax({
url: "../Service/EmpData",
type: "PUT",
contentType: 'application/json',
processData: false,
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
},
success: function (allData) {
var Data = $.map(allitems, function (item) {
return new EmpList(item);
});
self.EmployeeData(Data);
}
});
}
function EmpList(items) {
this.EmpName = ko.observable(data.EmpName);
this.EmpId = ko.observable(data.EmpId);
this.ConcenatedData = ko.observable(data.ConcenatedData);
}
我在我的 observable 中得到了 <temp>Is this Emp required</temp>in our company 的数据
所以我想让标签<temp> and </temp>.之间的文本加粗,所以输出将是我们公司需要这个Emp`
如何做到这一点?
更新
我已经创建了小提琴 here 我希望标签 <temp> and </temp>. 之间的文本为粗体。
【问题讨论】:
-
现代浏览器会得到这个css规则:
temp{font-weight: bold;} -
@Cherniv 你能告诉我怎么做吗?
-
他刚刚做了,哈哈 xD 你只是把他给的代码放在一对
<style>标签中,就像任何其他 CSS 一样。或者,如果可以通过<temp style="font-weight:bold">将其放入<temp>选择器中 -
等你知道 knockout.js 而不是简单的 CSS?
-
不,很高兴。如果您有任何问题,请尝试查看并告诉我们。
标签: jquery html knockout.js