0

Для редактирования текстов на своем сайте использую всплывающее диалоговое окно Bootstrap3. Все работает нормально, можно редактировать текст. Но при подключении TinyMCE содержимое textarea пропадает и невозможно редактировать. Вот html-код модального окна:

<!-- Modal --> 
<div class="modal fade" id="add_new" tabindex="-1" role="dialog" aria- labelledby="Labelnew_new" 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">&times;</button>
<h4 class="modal-title" id="Labelnew_new">Add article</h4>
</div>
<div class="modal-body">
<form role="form" id="f_new">
<div class="form-group">
<label for="ntitle">Title :</label>
<input type="text" class="form-control" name="ntitle" id="title" placeholder="Title of article"   data-provide="typeahead" data-items="4" autocomlete="off"/>
 </div>
 <div class="form-group">
 <label for="ntext">Text :</label>
    <textarea class="form-control" rows="9" name="ntext" id="ntext" placeholder="Text of article"></textarea>
 <input type="hidden" name="id_new">
 </div>
 </form>
 </div>
 <div class="modal-footer" id="modal_footer">
 <button type="button" class="btn btn-primary" id="save_new">Save</button>
 <button type="button" class="btn btn-warning" id="f_del">Delete</button>
 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
 </div>
 </div>
 </div>
 </div>

Js-код для активации модального окна

function set_new(){
$('#new_new').on('click',function(){ jQuery('form')[0].reset();
$('input[name="id_new"]').val('');
});
$('#table-new tbody').on('click','tr', function( event ){   
var tr = $( this );
var id = $( this ).attr('id');
$('input[name="id_new"]').val(id);
$("input[name='ntitle']").val( tr.find('td:eq(1)').text());
$("textarea[name='ntext']").val(tr.find('td:eq(2)').html()); 
$("#add_new").modal('show'); 
});
}

И инициализация TinyMCE:

<script src="/admin/template/news/tinymce/js/tinymce/tinymce.min.js">   </script>
<script>tinymce.init({ 
selector: '#ntext'
});
</script>

Где я ошибаюсь, как правильно подключить текстовый редактор?

2
  • перенесите код в jsfiddle.net так быстрее смогут вам помочь
    – Dmitry
    22 янв 2016 в 19:35
  • Добавил на jsfiddle.net - я там первый раз, прошу строго не судить, вот ссылка jsfiddle.net/ZaurK/eaqjnmvd . Видно, что область ввода текста в Tinymce пустая - в этом проблема, даже placeholder не отображается. Должен выводиться текст из базы mysql; Если отключить Tinymce , то placeholder отображается, да и текст из базы тоже(правда тут этого не видно).
    – ZaurK
    22 янв 2016 в 21:54

1 ответ 1

1

Попробуйте использовать так:

<script src="/admin/template/news/tinymce/js/tinymce/tinymce.min.js">   </script>
<script>tinymce.init({ 
selector: 'textarea#ntext'
});
</script>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.