【发布时间】:2015-12-01 08:09:16
【问题描述】:
单击另一个页面的链接后,我收到“无法在 'Node' 上执行 'insertBefore'”错误:
<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>
显然,那个小注释干扰了代码,因为在我删除它之后,一切都运行良好。
虽然问题得到了解决,但我真的很想知道这条线是如何妨碍代码的。
有人知道为什么吗?我在 Iron-Router 上使用 Meteor。
谢谢!
编辑
如果有帮助,我正在使用 Jquery-UI,这是我的 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();
};
【问题讨论】:
-
必须是你的 Iron-Router 的东西,模板内的 cmets 不会造成任何副作用。这是证据:jsfiddle.net/b4f9wwt8
-
尝试使用空格键 cmets 而不是 HTML cmets:
{{!-- COMMENT --}} -
这有点奇怪。经过更多测试,破坏网站的是那些对话框。如果我删除其中一个,评论可以保留,但如果同时保留,当评论出现时应用程序崩溃。此外,如果我更改没有被标签包围的任何内容(例如随机文本)的评论,应用程序崩溃,但如果我标记它,它可以工作
-
更改
hello的评论会破坏页面,但<p>hello</p>不会。空格键 cmets 也会打破它。 @saimeunt
标签: javascript html jquery-ui meteor iron-router