Error: Failed to execute 'insertBefore' on 'Node' - The node before which the new node is to be inserted is not a child of this node


Hi Everyone,

I have build a web app using meteor with blaze in front. There are some hidden errors which I am not able to solve. This is the exact error.

Error: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
    at Function.DOMRange._insertNodeWithHooks (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:407)
    at Function.DOMRange._insert (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:376)
    at Blaze._DOMRange.DOMRange.attach (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:453)
    at Function.DOMRange._insert (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:371)
    at Blaze._DOMRange.DOMRange.attach (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:453)
    at Function.DOMRange._insert (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:371)
    at Blaze._DOMRange.DOMRange.attach (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:453)
    at Blaze._DOMRange.DOMRange.setMembers (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:497)
    at doMaterialize (blaze.js?hash=f33d3dfed63a491d24e3aa07ad66c24b5fe8c761:2093)
    at Object.Tracker.nonreactive (tracker.js?hash=997515fa2d5b0530ba07741da556c4b36963ef3b:640)

I am not able to find out which of the component is causing error.

Here is the page, I have used trumb

<template name="createblog">
      width:100% !important;
   {{> header}}
   {{> blogcreate}}
   {{> sAlert}}
<template name="blogcreate">
   <!-- <button id="check_alert" > check alert</button> -->
   <div class="page_wh">
      <div class="page_all_white">
         <div class="row ">
            <div class="col s12 m6 l6" style="padding: 0px;">
               <h5 class="heading_create" id="createblog"> Create Blog</h5>
            <div class="col s12 m6 l6">
               <h5 class="heading_create_inside"> <i class="fa fa-times pull-right" style="display: none !important;"></i> </h5>
         <div class="row">
            <div class="col s12 m12 ll2" style="padding: 0px;">
               <div class="card" style="padding: 0px; box-shadow: none;">
                  <div class="card-image" id="imagebox">
                     <img id="my_image" src="" style="height: 300px;"  > 
                     <input type="hidden" name="cover_image" id="cover_image" value="">
                     <label for="coverimage">
                     <span style="cursor: pointer;" class="card-title sppan_icons_one"><i class="fa fa-camera"></i></span></label>
                     <input type="file" name="cover_pic" id="coverimage" style="display:none !important;">
                     <span style="display: none;cursor: pointer;" id="removecoverpic" class="card-title sppan_icons_two"><i class="fa fa-trash sppan_icons_two"></i></span>
                  <div style="display: none;" class="card-image" id="divcrop">
                     <img id="my_image2">
                     <span style="cursor: pointer;" id="crop_image" class="card-title sppan_icons_one"><i class="fa fa-crop sppan_icons_one"></i></span>
               <p class="text-center">
                  <!--  <img src="" alt="img" class="img-responsive">   -->
         <div class="row">
            <div class="input-field col s12 m12 l6">
               <p class="heading_create_inside"> Blog Title <sup><span class="red_start"> * </span></sup> </p>
               <input value="" id="blog_title" type="text" class="validate frmt_inpt">        
               <!--      <input value="" id="grp_title" type="text" class="validate frmt_inpt"> -->        
            <div class="input-field col s12 m12 l6">
               <p class="heading_create_inside">When to publish <sup><span class="red_start"> * </span></sup> </p>
               <input type="text" class="datepicker frmt_inpt" id="Blog_publish_date">
         <div class="row">
            <form >
               <div class="row">
                  <div class="input-field col s12">
                     <p class="heading_create_inside"> Description <sup><span class="red_start"> * </span></sup> </p>
                     <textarea id="blog_description" class="materialize-textarea frmt_inpt"></textarea>
         <div class="loading loader_visiblity_block"  id="loading_div" ></div>
         <script type="text/javascript">
            var trumbowyg = $('#blog_description').trumbowyg(
            btnsDef: {
                  // Create a new dropdown
              // Redefine the button pane
              btns: [
                  ['strong', 'em', 'del'],
                  ['superscript', 'subscript'],
                  // ['insertImage'],
                   ['justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull'],
                  ['unorderedList', 'orderedList'],
                  // ['fullscreen']
            <script type="text/javascript">       
              $("#blog_visibility").dropdown("set selected","");
            </script> -->
         <div class="row">
            <div class="col s12 m12 l5"> &nbsp;  </div>
            <div class="col s12 m12 l2"><a class="waves-effect waves-light cncl_btm clicked_cancel">Cancel</a> </div>
            <div class="col s12 m12 l2"><a class="waves-effect waves-light save_button" id="save_blog_draft_btn" > Save in draft</a></div>
            <div class="col s12 m12 l3"><a class="waves-effect waves-light save_button" id="save_blog" > Preview to Publish</a></div>

When I refreshes this page, the error vanishes away and I got the page.

Please help. Any help would be greatly appreciated


This typically happens when a DOM node which Blaze was expecting to be there, is not anymore.

That editor plugin that I see in your code, try without first and see what happens. I’m almost certain that that’s the cause. When using Blaze, you initialise an external plugin in the onRendered callback of your template, not like this.


HI @illustreets, I tried in onRendered callback but that does not work either, got the same results


Difficult to say, then, what you can do. Likely tumowyg is shifting the DOM in ways that make Blaze complain.

Actually, I remember that a while ago we needed an editor in our own app, but couldn’t make trumbowyg play nicely with Blaze, so we settled for TinyMCE.


Thanks, Man will give it a try!


Hi @illustreets, I just want to know why don’t you go with ckeditor, its even better. I have not integrated it though but is there any issue or something like that


Can’t remember what else we tried, but at the time TinyMCE was the easiest to integrate relative to the features that we wanted. Still works very well, so not keen on changing it soon.


ok & Thanks for your time.

1 Like