Example: http://jsfiddle.net/atfb8huL/
.... and it will going on like this.
I don't know if recieved ajax content will contain summernote editor before loading the content. So initializing summernote in ajax success function is not an option.
Body:
<body>
<a href="modal.html" class="ajaxPopup">Open Summernote</a>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<div class="te"></div>
</div>
</div>
</div>
</div>
<script type='text/javascript'>
var $myModal = null;
$(document).ready(function () {
$myModal = $('#myModal');
$('.ajaxPopup').on('click', function () {
$.ajax({
url: 'modal.html',
type: 'GET',
context: this,
success: function (response) {
$myModal.find('.modal-title').html("Summernote");
$myModal.find('.modal-body').html(response);
$myModal.modal({
show: true,
backdrop: true
});
}
});
return false;
});
});
</script>
</body>
modal.html content
<div id='commentBox'></div>
<script type='text/javascript'>
$(function () {
$('#commentBox').summernote();
});
</script>
Any suggestions?
Emptying your modal body content prior to opening it fixes this issue.
var $myModal = null;
$(document).ready(function () {
$myModal = $('#myModal');
$('.ajaxPopup').on('click', function () {
$myModal.find('.modal-body').html('');
$.ajax({
url: '/echo/html/',
data: {
html: "<div id='commentBox'></div>" + "<script type='text/javascript'>$(function () {$('#commentBox').summernote();});<\/script>"
},
type: 'POST',
context: this,
success: function (response) {
$myModal.find('.modal-title').html("Summernote");
$myModal.find('.modal-body').html(response);
$myModal.modal({
show: true,
backdrop: true
});
}
});
return false;
});
});