流星选择器不工作,出现意外字符串错误

Meteor selectors not working with Unexpected string error

本文关键字:意外 字符串 错误 选择器 工作 流星      更新时间:2023-09-26

我遵循这个指南,其中一个选择器不适合我。下面是我的一些代码:

Template.todoItem.events({
'click .delete-todo': function(event){
  event.preventDefault();
  var documentId = this._id;
  var confirm = window.confirm("Are you sure you want to delete this task?");
  if(confirm){
    Todos.remove({ _id: documentId });
  }
}
'keyup [name=todoItem]': function(event){
  console.log("You just tapped a key on your keyboard.");
 }
});

和HTML的:

<template name="todoItem">
 <li>
  <input type="checkbox">
  <input type="text" value="{{name}}" name="todoItem">
  [<a href="#" class="delete-todo">Delete</a>]
 </li>
</template>

当我尝试运行这段代码流星给我的错误:错误阻止启动:当构建应用程序:todos.js:32:5:意外字符串

我认为这是因为JavaScript中的'keyup [name=todoItem]'位。如果有人知道发生了什么,帮助将非常感激:)

谢谢,Alaister

这是一个语法错误,两个事件监听器之间需要一个逗号。

在我的移动设备上,无法格式化代码。