Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Добавление текстового поля с редактором, javascript.


Recommended Posts

Как через javascript добавить textarea, сразу с активированым текстовым редактором? Подскажите пожалуйста.

Edited by magneto2010
Link to comment
Share on other sites

Все зависит от редактора и метода инициализации

для sumernote


$('#somediv').append('<textarea id="idtextarea"></textarea>');
            lang: $(this).attr('data-lang'),
            disableDragAndDrop: true,
            height: 300,
            emptyPara: '',
            codemirror: { // codemirror options
                mode: 'text/html',
                htmlMode: true,
                lineNumbers: true,
                theme: 'monokai'
            fontsize: ['8', '9', '10', '11', '12', '14', '16', '18', '20', '24', '30', '36', '48' , '64'],
            toolbar: [
                ['style', ['style']],
                ['font', ['bold', 'underline', 'clear']],
                ['fontname', ['fontname']],
                ['fontsize', ['fontsize']],
                ['color', ['color']],
                ['para', ['ul', 'ol', 'paragraph']],
                ['table', ['table']],
                ['insert', ['link', 'image', 'video']],
                ['view', ['fullscreen', 'codeview', 'help']]
            popover: {
                   image: [
                    ['custom', ['imageAttributes']],
                    ['imagesize', ['imageSize100', 'imageSize50', 'imageSize25']],
                    ['float', ['floatLeft', 'floatRight', 'floatNone']],
                    ['remove', ['removeMedia']]
            buttons: {
                image: function() {
                    var ui = $.summernote.ui;
                    // create button
                    var button = ui.button({
                        contents: '<i class="note-icon-picture" />',
                        tooltip: $.summernote.lang[$.summernote.options.lang].image.image,
                        click: function () {
                                url: 'index.php?route=common/filemanager&user_token=' + getURLVar('user_token'),
                                dataType: 'html',
                                beforeSend: function() {
                                    $('#button-image i').replaceWith('<i class="fa fa-circle-o-notch fa-spin"></i>');
                                    $('#button-image').prop('disabled', true);
                                complete: function() {
                                    $('#button-image i').replaceWith('<i class="fa fa-upload"></i>');
                                    $('#button-image').prop('disabled', false);
                                success: function(html) {
                                    $('body').append('<div id="modal-image" class="modal">' + html + '</div>');
                                    $('#modal-image').delegate('a.thumbnail', 'click', function(e) {
                                        $(element).summernote('insertImage', $(this).attr('href'));
                    return button.render();


  • +1 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.