dishadcruze Posted September 1, 2017 Share Posted September 1, 2017 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> Quote Link to comment https://forums.phpfreaks.com/topic/304834-adding-ckeditor-for-dynamically-generated-rows/ Share on other sites More sharing options...
requinix Posted September 1, 2017 Share Posted September 1, 2017 Turn data into an actual DOM object, insert it into the document, then find the .editor in data and .ckeditor() it. Quote Link to comment https://forums.phpfreaks.com/topic/304834-adding-ckeditor-for-dynamically-generated-rows/#findComment-1550555 Share on other sites More sharing options...
dishadcruze Posted September 1, 2017 Author Share Posted September 1, 2017 @requinix : Can you please explain more? sorry, i did not get Quote Link to comment https://forums.phpfreaks.com/topic/304834-adding-ckeditor-for-dynamically-generated-rows/#findComment-1550560 Share on other sites More sharing options...
requinix Posted September 1, 2017 Share Posted September 1, 2017 You already have code that inserts the data stuff into the page, right? What is it? Also, your ID generation does not support when the user deletes a row from the middle of the table and then adds a new one. Quote Link to comment https://forums.phpfreaks.com/topic/304834-adding-ckeditor-for-dynamically-generated-rows/#findComment-1550561 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.