I need to append multiple nodes to a container. Rather than doing a slow DOM append inside each iteration, I want to queue up the nodes in a document fragment (open to other ideas) and append them all at one time. Here is my code:
var fragment = document.createDocumentFragment();
$.each( poFailureInfoMultiple, function(i,e){
fragment.appendChild(
$('<button/>', {
'class': 'el-contents-center multiple-record'
})
);
});
$('#some-container').html( fragment );
My problem is I am getting an error message stating:
Could not convert JavaScript argument arg 0 [nsIDOMDocumentFragment.appendChild]
So how can I append multiple element nodes to my DOM at once? I don't HAVE to use the fragment method (I just found it and it seemed viable).
Note: I DO NOT WANT TO USE HTML SYNTAX FOR THE APPEND
i.e. $('#some-container').append('<button class="myclass"></button>');
poFailureInfoMultiplecome from?jQuery.appendChilddoesn't take ajQueryobject and$.htmldoes not take aDocumentFragmentThat's what your error is telling you.