Meteor: Exception in queued task: Error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node

£可爱£侵袭症+ 提交于 2019-12-24 01:48:13

问题


I have really weird problem and totally no clue how to solve it.

I am trying to build very simple fullpage.js and meteor.js implementation. The code below works, but after a few minutes, it breaks. When I open a new incognito window it works for a few minutes again, but when I refresh the page I get the following error 3 times (one for each document in collection).

Exception in queued task: Error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
at Error (native)
at DOMRange.detach (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:512:24)
at DOMRange.setMembers (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:471:12)
at DOMRange.addMember (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:540:10)
at http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2541:32
at Object.Tracker.nonreactive (http://localhost:3000/packages/tracker.js?517c8fe8ed6408951a30941e64a5383a7174bcfa:513:12)
at Object.Blaze.Each.eachView.onViewCreated.eachView.stopHandle.ObserveSequence.observe.addedAt (http://localhost:3000/packages/blaze.js?efa68f65e67544b5a05509804bf97e2c91ce75eb:2528:17)
at Object.cursor.observe.addedAt (http://localhost:3000/packages/observe-sequence.js?2fd807ea171ead273b9e6458607cb226012d9240:339:19)
at LocalCollection._observeFromObserveChanges.observeChangesCallbacks.addedBefore (http://localhost:3000/packages/minimongo.js?e8806aa7782b729b2517ebc0cd10b321667f1427:3840:28)
at Object.LocalCollection._CachingChangeObserver.self.applyChange.addedBefore (http://localhost:3000/packages/minimongo.js?e8806aa7782b729b2517ebc0cd10b321667f1427:3777:56)

Meteorpad: http://meteorpad.com/pad/RT4HwXmXW6wbghNhK/Fullpage

main.html

<head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>

<body>
    {{>fullPage}}
</body>

<template name="fullPage">
        <div id="fullpage" class="section">
                {{#each products}}
                    <div class="slide"><h2>{{name}}</h2></div>
                {{/each}}
            </div>
</template>

client/app.js

Template.fullPage.rendered = function () {
    $('#fullpage').fullpage();
};

Template.fullPage.helpers({
    products: function () {
        return Products.find();
    }
});

server/app.js

Meteor.startup(function () {
  if (Products.find().count() === 0) {

    var Product1 = Products.insert({
        name: "1"
    });

    var Product2 = Products.insert({
        name: "2"
    });

    var Product3 = Products.insert({
        name: "3"
    });
  }
});

common.js

Products = new Mongo.Collection('products');

回答1:


Adding a <div> around your {{#each products}} may solve your problem.

I'm not familiar with fullpage.js, but I was getting the exact same error message with the maazalik:malihu-jquery-custom-scrollbar package. The plugin operates by copying and pasting elements into a new div, which can cause problems if the first child of that element is an {{#each}} or {{#if}}. Adding a <div> solves that.

You can find more info in this github issue.




回答2:


Could you try adding else in the each function to see if it solves anything?

<template name="fullPage">
    <div id="fullpage" class="section">
            {{#each products}}
                <div class="slide"><h2>{{name}}</h2></div>
            {{else}}
              {{! does this help? }}
            {{/each}}
        </div>
</template>


来源:https://stackoverflow.com/questions/28775611/meteor-exception-in-queued-task-error-failed-to-execute-removechild-on-nod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!