When I put the html tags ckeditor outside activities but when I put ckeditor in jquery append then it does not work
<div class="input_fields_wrap">
<a class="add_field_button">Add More Fields</a>
<div></div>
</div>
<script>
$(document).ready(function() {
var max_fields = 10; //maximum input boxes allowed
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
var x = 1; //initlal text box count
$(add_button).click(function(e){ //on add input button click
e.preventDefault();
if(x < max_fields){ //max input box allowed
x++; //text box increment
$(wrapper).append('<div><div class="form-group"><label class="control-label col-md-3">Project</label><div class="col-md-9 col-xs-12"><select class="bs-select form-control" name="project"><option value="" >------------- Select project -----------</option>@forelse($parent as $item)<option value="{{$item->id}}">{{$item->title}}</option>@empty @endforelse</select></div></div><textarea class="form-control" id="editor1" name="content_vi[]" rows="6" required></textarea><a href="#" class="remove_field">Remove</a></div>'); //add input box
}
});
$(wrapper).on("click",".remove_field", function(e){ //user click on remove text
e.preventDefault(); $(this).parent('div').remove(); x--;
})
});
</script>
Use "insertHtml" or "insertText" function for appending data into the CKEDITOR. Like this:
CKEDITOR.instances['input-text-area-ID'].insertHtml(data);
If you want to remove previous data and add new one use "setData" function. Like this:
CKEDITOR.instances['input-text-area-ID'].setData(data);
You already have these 2 varibales
var wrapper = $(".input_fields_wrap");
var add_button= $(".add_field_button");
then you are using them like
$(wrapper).apend();
it means
$($(".input_fields_wrap")).append();
which is wrong either use it like wrapper.append(); or change var wrapper like
var wrapper = ".input_field_wrap";
same thing you are doing with the add_button and its always better to you
$().on('click',function(){
});
then
$().click(function(){
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.