I have the following code (which is the HTML from the example):
var modal=
'<div class="modal fade" id="infoModal"'+id+'tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">'
+'<div class="modal-dialog">'
+'<div class="modal-content">'
+'<div class="modal-header">'
+'<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'
+'<h4 class="modal-title">Modal title</h4>'
+'</div>'
+'<div class="modal-body">'
+'<p>One fine body…</p>'
+'</div>'
+'<div class="modal-footer">'
+'<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>'
+'<button type="button" class="btn btn-primary">Save changes</button>'
+'</div>'
+'</div>'
+'</div>'
+'</div>';
document.body.appendChild(modal);
And I get the error:
Uncaught NotFoundError: Failed to execute 'appendChild' on 'Node': The new child element is null.
If I put the same HTML inside my index.html it works just fine. What's the problem here?