我得到一个“无法执行‘的insertBefore’上‘节点’”的错误点击一个链接到另一个页面后:HTML注释打破了网站
<template name="reminderPage">
<a href="/newRemind">New!</a>
{{>reminder}}
<!-- Random comment -->
</template>
<template name="reminder" class="reminder">
<p>Hello reminder</p>
{{>editForm}}
</template>
<template name="editForm">
<div id="dialog-form" title="Edit Reminder">
<p class="validateTips">All form fields are required.</p>
<form>
<fieldset>
<label for="taskf-name">Name</label>
<input type="text" name="taskf-name" id="taskf-name" maxlength="20">
<label>Bought</label>
<input type="text" name="taskf-bought" id="taskf-bought">
<label>Expire</label>
<input type="text" name="taskf-expire" id="taskf-expire">
</fieldset>
</form>
</div>
</template>
显然,那个小注释与代码干扰因为在我删除它之后,一切都很完美。
虽然问题解决了,但我真的很想知道这条线怎么会挡住代码的路。
有谁知道为什么?我使用流星与铁路由器。
谢谢!
编辑
如果有帮助,我使用jQuery的用户界面,这是我的JavaScript文件
Template.reminder.rendered = function() {
$("#dialog-form").dialog({
autoOpen: false,
modal: true,
open: function() {
},
buttons: [
{
id: "button-ok",
text: "Save",
click: function() {
$(this).dialog("close");
}
},
{
id: "button-cancel",
text: "Cancel",
click: function() {
$(this).dialog("close");
}
}
]
});
}
的“newRemind”页面只具有最基本的对话,而且它的js文件只是启动它。
<template name="newRemindPage">
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
</template>
的Javascript:
Template.newRemindPage.rendered = function() {
$("#dialog").dialog();
};
必须与您的铁路由器,模板内的评论不会导致任何副作用。下面是证明:http://jsfiddle.net/b4f9wwt8/ –
尝试使用空格键而不是HTML注释:'{{! - COMMENT - }}' – saimeunt
这有点奇怪。经过更多测试后,网站破坏的是那些对话。如果我删除了该评论,评论可以保留,但如果同时存在,评论存在时应用会崩溃。此外,如果我更改了任何未包含标签(例如,随机文本)的注释,该应用程序会崩溃,但是如果我标记它,它会起作用 –