Jump to content

Adding ckeditor for dynamically generated rows


dishadcruze

Recommended Posts

While adding line items in invoice, i am trying to give product description in ckeditor editable form. But the editor is showing only for 1st product.

 

Here is the code

<table class="table table-bordered"> 
<tr>
<th><input class='check_all' type='checkbox' onclick="select_all()"/></th> 
<th>Name</th>
<th>Description</th>
<!-- Other heading like qty,tax...etc -->
</tr> 
<tr>
<td><input type='checkbox' class='case'/></td> 
<td><input type="text" class="form-control" id="productname_1" name="productname[]" style="width:120px;"></td> 
<td><textarea class="editor form-control" id="description_1" name="description[]"></textarea></td>
<!---other input values -->
<td><button type="button" class='btn btn-danger delete'>-</button></td>
<td><button type="button" class='btn btn-success addmore'>+ </button></td>
</tr></table>

Through jquery i add as many as products . my add.js goes like this

$(".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' style='width:120px;' id='productname_" + i + "' name='productname[]'/></td><td><textarea class='editor form-control' id='description_"+ i + "' name='description[]' ></textarea></td></tr>";

I add editor like this within <head> </head>

<script src="../assets/ckeditor/ckeditor.js" type="text/javascript"></script> 
<script type="text/javascript" src="../assets/ckeditor/adapters/jquery.js"></script> 
<script type="text/javascript">
$(function(){
$('.editor').ckeditor(); 
}); 
</script>

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.