Welcome Guest, Not a member yet? Register   Sign In
[Solved] Summernote Text Editor With Codeigniter
#1

(This post was last modified: 05-16-2015, 05:42 AM by wolfgang1983.)

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/
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

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]
Reply
#3

(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.
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB