MeteorJS:表格中的输入值显示两次

时间:2015-05-15 08:58:10

标签: javascript html web meteor meteor-blaze

我在MeteorJS上遇到了关于向可编辑表插入值的问题。每当我插入一个值并调用blur事件处理程序(对db执行更新操作)时,表格单元格中的值将显示两次。

我的代码位于:https://github.com/jeffrey-effendy/sudolver

感谢您的帮助!

2 个答案:

答案 0 :(得分:2)

我经历过类似于满足感领域的事情。认为它的原因是因为值保留在单元格中,但{{value}}也会添加一个值,因此它会显示两次。

您可以先清除单元格来修复它:

Template.createCell.events({
    "blur .cell": function(e) {
       var val = $(e.currentTarget).text();
       $(e.currentTarget).text('');
       Meteor.call("update", this._id, val);
    }
});

答案 1 :(得分:0)

event事件函数中的createCell是什么?似乎你没有在事件的参数中定义它:

  Template.createCell.events({
    "blur .cell": function(event) { // here
      Meteor.call("update", this._id, event.target.innerHTML);
    }
  });