CodeIgniter Forums

Full Version: [Solved] Summernote Text Editor With Codeigniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I use summer note text editor with codeigniter. I am able to get summer note text it working with one text area OK. But when I create a new row by clicking on my button I would like summer note to show at the moment it only displays default bootstrap text area.

Each textarea creates its own id when click on button in <textarea id="code0"></textarea> <textarea id="code1"></textarea> <textarea id="code2"></textarea> and so on each time create new row.


Any one know best way so that I could add the script to my addContent function


Quote:<script type="text/javascript">

  $(document).ready(function() {
    $('#code_preview0').summernote({height: 300});
    });
</script>


Quote:var content_row = 1;


function addContent() {
  html = '<div id="content-row">';
  html += '<div class="form-group">';
  html += '<label class="col-sm-2">Page Content</label>';
  html += '<div class="col-sm-10">';
  html += '<textarea class="form-control" id="code_preview' + content_row + '" name="page_code[' + content_row + '][code]" style="height: 300px;"></textarea>';
  html += '</div>';
  html += '</div>';
  html += '</div>';
  $('#content-row').append(html);

  content_row++;
}


Live Demo

http://codepen.io/riwakawebsitedesigns/pen/yNJYYq

Live Demo Full View

http://codepen.io/riwakawebsitedesigns/full/yNJYYq/
Hi, 

you must call summernote function after append content:
Code:
var content_row = 1;

function addContent() {
 html = '<div id="content-row">';
 html += '<div class="form-group">';
 html += '<label class="col-sm-2">Page Content</label>';
 html += '<div class="col-sm-10">';
 html += '<textarea class="form-control" id="code_preview' + content_row + '" name="page_code[' + content_row + '][code]" style="height: 300px;"></textarea>';
 html += '</div>';
 html += '</div>';
 html += '</div>';
 $('#content-row').append(html);
 $('#code_preview' + content_row).summernote({height: 300});

 content_row++;
}[/code]
(05-16-2015, 05:02 AM)nicojmb Wrote: [ -> ]Hi, 

you must call summernote function after append content:

Code:
var content_row = 1;

function addContent() {
 html = '<div id="content-row">';
 html += '<div class="form-group">';
 html += '<label class="col-sm-2">Page Content</label>';
 html += '<div class="col-sm-10">';
 html += '<textarea class="form-control" id="code_preview' + content_row + '" name="page_code[' + content_row + '][code]" style="height: 300px;"></textarea>';
 html += '</div>';
 html += '</div>';
 html += '</div>';
 $('#content-row').append(html);
 $('#code_preview' + content_row).summernote({height: 300});

 content_row++;
}[/code]

Thank you so much for advice.