Reputation: 13
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.
Upvotes: 1
Views: 1774
Reputation: 3046
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: [...
Upvotes: 1
Reputation: 2251
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.
Upvotes: 0
Reputation: 2251
You should use VAL(), not HTML,TEXT. So you code has to be like this:
$(function() {
$('#attrArticleHtml').keyup(function() {
$('#attrArticleSecond').val($('#attrArticleHtml').val());
});
});
Upvotes: 0