繁体   English   中英

使用Knockout.js在textarea中添加数据绑定和静态文本

[英]Adding data-bind and static text in textarea using Knockout.js

我想将静态文本和属性添加到文本区域。 例如,我要显示“ [开发x]在[开始日期]上开始工作”,其中Development_Name()和Start_Date()是分别存储名称和日期的属性

这是文本区域的外观,Development_Name()属性可以正常工作

<text area rows="6" class="textarea-box" id="txtComments" data-bind="Development_Name()"

我该如何添加静态文本。 这样做(下)显然是不正确的

textarea rows="6" class="textarea-box" id="txtComments" data-bind="Development_Name()'+Started work on+'Start_Date()"></textarea>

有什么建议么

在.js文件中创建方法并向其中添加数据绑定值即可解决该问题。

这是视图

<textarea rows="6" class="textarea-box" id="txtComments" data-bind="value: EmailBodyText"></textarea>

这就是视图模型的样子

 SendEmail: function () {
        if (FlagResult() == "EI") {
           // $("#rowWrapParticipation").addClass('alert alert-danger');
            EmailBodyText("There was an attempt by your company to enter " + SponsorName() + "-" + $("#ddlDevelopment option:selected").text() + ". Unfortunately, at this time, you do not meet the controlled insurance program requirements to come onto the project site. Please contact Rebecca Osborne at Consolidated Risk Solutions via 678.893.7483 or rebecca.osborne@c-r-solutions.com to address this issue");
        }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM