废话少说,直接上干货,以下是我OA项目中的实例代码,前端用ZUI配套使用。
<div class="form-group"> <label for="txtDescription" class="col-xs-2 col-sm-2 col-md-2 col-lg-2"><span class="red">*</span>详情</label> <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10"> <asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" Rows="20" MaxLength="4000" EnableTheming="True" CssClass="form-control kindeditor" Text=""></asp:TextBox> </div> </div>
//初始化编辑器 var editor = KindEditor.create('textarea.kindeditor', { //width: '100%', //height: '350px', filterMode: false, //默认不过滤HTML resizeType: 1, uploadJson: '../../../Tools/Uploader.ashx?action=EditorFile&SubFolder=Notice&IsWater=0', fileManagerJson: '../../../Tools/Uploader.ashx?action=ManagerFile&SubFolder=Notice', allowFileManager: true, bodyClass: 'article-content', //经测试,下面这行代码可有可无,不影响获取textarea的值 //afterCreate: function(){this.sync();} //下面这行代码就是关键的所在,当失去焦点时执行 this.sync(); afterBlur: function(){this.sync();} });