我有非常奇怪的问题,完全不知道如何解决它。
我正在尝试构建非常简单的fullpage.js
和meteor.js
实现。下面的代码有效,但几分钟后,它就会中断。当我打开一个新的隐身窗口时,它再次工作几分钟,但是当我刷新页面时,我得到以下错误3次(每个文档收集一次)。
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>
的客户机/ app.js
Template.fullPage.rendered = function () {
$('#fullpage').fullpage();
};
Template.fullPage.helpers({
products: function () {
return Products.find();
}
});
服务器/ 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');
答案 0 :(得分:3)
在<div>
周围添加{{#each products}}
可能会解决您的问题。
我不熟悉fullpage.js,但我收到了与maazalik:malihu-jquery-custom-scrollbar包完全相同的错误消息。该插件通过将元素复制并粘贴到新div中来操作,如果该元素的第一个子元素是{{#each}}
或{{#if}}
,则可能会导致问题。添加<div>
解决了这个问题。
您可以在此github issue找到更多信息。
答案 1 :(得分:0)
您可以尝试在每个函数中添加else
以查看它是否解决了什么问题?
<template name="fullPage">
<div id="fullpage" class="section">
{{#each products}}
<div class="slide"><h2>{{name}}</h2></div>
{{else}}
{{! does this help? }}
{{/each}}
</div>
</template>