1

I'm trying to use below code to get text copied from jhtmlarea to another textarea but it do not work.

  <textarea id="attrArticleHtml"></textarea>
  <textarea id="attrArticleSecond"></textarea>

$(function() {
    $('#attrArticleHtml').keyup(function() {
        var textareaHtml = $('#attrArticleHtml').htmlarea('toHtmlString');
        console.log(textareaHtml);
        $('#attrArticleSecond').text(textareaHtml);

    });     
});

What ID I should use to get text copied using keyup? Seems that jhtmlarea is using iframe and therefore attrArticleHtml is not ok.

3 Answers3

1

This worked for me:

 $("#ctl00_Kontent_taHtmlEditor").htmlarea({
    loaded: function() {
        var mycontrol = { jhtmlarea: this };
        $(mycontrol.jhtmlarea.editor.body).keypress(function(e) {
            var segedmezo = $("#divDrop").find("iframe").contents().find("body");
            $("#ctl00_Kontent_hfHtmlWithCodes").val(reduceCodes(segedmezo.html()));
        });
    },
    toolbar: [...
speti43
  • 2,886
  • 1
  • 20
  • 23
0

You should use VAL(), not HTML,TEXT. So you code has to be like this:

$(function() {
    $('#attrArticleHtml').keyup(function() {
        $('#attrArticleSecond').val($('#attrArticleHtml').val());

    });     
});
Anton Baksheiev
  • 2,211
  • 2
  • 14
  • 15
0

you need to add load to params of creation of area.

 $("#attrArticleHtml").htmlarea({
                loaded: function () {

                    $(this.editor).find('BODY').keyup(function (e) { 

                    var htmlValue =  $('#attrArticleHtml').val();
                    $('#attrArticleSecond').val(htmlValue )

        });

If this is usfull for you please dont forget click rep.

Anton Baksheiev
  • 2,211
  • 2
  • 14
  • 15