2015-09-05 51 views
2

我得到一个“无法执行‘的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(); 
}; 
+0

必须与您的铁路由器,模板内的评论不会导致任何副作用。下面是证明:http://jsfiddle.net/b4f9wwt8/ –

+0

尝试使用空格键而不是HTML注释:'{{! - COMMENT - }}' – saimeunt

+0

这有点奇怪。经过更多测试后,网站破坏的是那些对话。如果我删除了该评论,评论可以保留,但如果同时存在,评论存在时应用会崩溃。此外,如果我更改了任何未包含标签(例如,随机文本)的注释,该应用程序会崩溃,但是如果我标记它,它会起作用 –

回答

0

每​​:

{{! Comments can be one line}} 

{{! 
    Or they can be 
    multi-line 
}} 

{{!-- They can also be written like this --}} 

请发表您的更新的代码,如果它不尝试此方法后工作。

+0

任何这些仍然崩溃的网站替换评论。他们工作的唯一方式(或标准html注释)是如果我用div包围它们的。 '{{! - 它们也可以这样写 - }}崩溃。 '

{{!-- They can also be written like this --}}
'不会崩溃。 –

+0

如果这是一个错误,您可能需要向问题回复发布问题:https://github.com/meteor/meteor/issues –

+0

好的。我真的不想发布它,因为我认为这是Jquery-ui的错。该网站有两个对话框(每页一个),当任何一个被删除时,它工作正常。 尽管感谢您的帮助,但! –