Isengo Isengo - 5 months ago 6
jQuery Question

Appind only once and replace when changed

Here is what I wanna do. Create diffrent contents with input and upload and finally add all the content together. I am using jQuery to append the content to my Modal for a preview. First had the problem that it appended multiple times, solved that with one("click"...

But when I am editing my content in the Editor it should recognize it and change the content. Can I add a change.() or something? Or is there a custom function already for that kind of purpose.

function appendAll($param){
var test = tinyMCE.activeEditor.getContent();

$($param).append(test);

}

$("#preview").one("click", function() {
$("#preview").change(appendAll('.modal-body'));

});

Answer

Try this.

function appendAll($param){
        var test = tinyMCE.activeEditor.getContent();            

        $($param).text(test);

    }

    $("#preview").on("click", function() {
        $("#preview").change(appendAll('.modal-body'));

    });
Comments