php - 将数据库中的动态项目中的所见即所得编辑器显示为类
问题描述
我正在开发报价模块,我可以在其中添加单个或 n 个行项目。名称、描述、价格等行项目详细信息来自项目主数据。我正在使用 jquery 从数据库中添加多个项目。
对于项目描述,我正在尝试使用 CKEditor,它只适用于第一个项目,而不是另一个。
$(".delete").on('click', function() {
$('.case:checkbox:checked').parents("tr").remove();
$('.check_all').prop("checked", false);
check();
});
var i = $('table tr').length - 1;
$(".addmore").on('click', function() {
count = $('table tr').length - 1;
var data = "<tr><td><input type='checkbox' class='case'/></td><td><input class='form-control' type='text' id='productname_" + i + "' name='productname[]'/></td><input class='form-control' type='hidden' id='productcode_" + i + "' name='productcode[]'/> <td><textarea class='form-control ckeditor' id='description_" + i + "' name='description[]' ></textarea></td><td><input class='form-control price' type='text' id='price_" + i + "' name='price[]'/></td>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table class="table table-bordered">
<th><input class='check_all' type='checkbox' onclick="select_all()" />
</th>
<th>Name</th>
<th>Description</th>
<th>Price</th>
</tr>
<tr>
<td><input type='checkbox' class='case' /></td>
<input type="text" class="form-control" id="productname_1" name="productname[]"></td>
<input type="hidden" class="form-control" id="productcode_1" name="productcode[]">
<td><textarea class="form-control ckeditor" id="description_1" name="description[]"></textarea></td>
<td><input type="text" class="form-control price" id="price_1" name="price[]"></td>
<td><button type="button" class='btn btn-danger delete'>-</button></td>
<td><button type="button" class='btn btn-success addmore'>+ </button></td>
</tr>
</table>
如何为所有行项目显示 CKEditor?
解决方案
推荐阅读
- angular - 访问 Tabulator 以前使用 Angular 创建的表
- timescaledb - 是否可以从 Timescale 中的双时态表访问审计数据
- vb.net - VB.net yyyymmdd 格式需要解析为日期
- junit - 如何在为 Spring-ws 端点编写 Junit 时模拟服务类
- javascript - 在 Firebase 实时数据库中创建直接引用比直接在父级设置数据更好吗?
- sql - INSERT INTO VALUES when select returns more than 1 value
- spring - HTTP 状态 404 - 基本 Spring Boot 程序未找到
- sql - 如何将一个或多个包文件放入sql格式的changelog中
- node.js - 如何通过 react-native 录制视频并上传到服务器
- python - AttributeError:“事件”对象没有属性“键”