In order to make appendTo work, there must be a wrapper, otherwise it will add two copies (one to each div):
let $canvas = $(`<div></div>`, {html: `<div>1</div><div>2</div>`});
let $editor = $(`<div></div>`);
$editor.appendTo($canvas);
initializeEditor($editor);
Is there a method to add to the end so that the wrap isn't necessary? I tried insertAfter like this, but it doesn't seem to do anything:
let $canvas = $(`<div>1</div><div>2</div>`);
let $editor = $(`<div></div>`);
$editor.insertAfter($canvas);
initializeEditor($editor);
$editor.insertAfter($canvas.last())If you only want it inserted once, reduce the scope of what you are inserting it after$canvas.add(...html...)would probably work too$canvas = $canvas.add($editor)