Вопрос

I am trying to insert some text into <textarea> by query but it is not working as I expect. I expect the colour code should get inserted into the textarea but textarea remains blank.

HTML code

<p id="niceedit">
    <script src="js/create/text_editor/nicEdit.js" type="text/javascript"></script>
    <script type="text/javascript">

    bkLib.onDomLoaded(function() {
          new nicEditor({height : 100}).panelInstance('area5');
    });
    </script>

    <textarea id="area5" ></textarea>
</p>

Jquery code

$(document).ready(function(){
    $('.simple_color').simpleColor();
    $('input#alert_button').click( function() {
        var currentlySelectedColor = $('input.simple_color')[0].value;

        $('#area5').val(currentlySelectedColor);//HERE IS THE CODE

        $.post("defualt_templates/T1/Class_File/template_editor.php", { bgcolor: currentlySelectedColor },
            function(data) {
                refreshIFrame();
        });

    });

});

Question

What am I doing wrong?


Reference to external library

NicEdit reference

Это было полезно?

Решение

try this

$('#area5').text(currentlySelectedColor); 

instead of this

$('#area5').val(currentlySelectedColor); 

Or, there is a method inside NicEditor to find editor and then get or set the content.

reference : http://wiki.nicedit.com/w/page/521/Javascript%20API

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top