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

MeteorJS: Input value in a table is displayed twice

本文关键字:两次 显示 输入 MeteorJS      更新时间:2023-09-26

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

我有可用的代码:https://github.com/jeffrey-effendy/sudolver

谢谢你的帮助!

我在可满足字段中也遇到过类似的情况。认为这是因为值留在单元格中,但是{{value}}也添加了一个值,所以它显示了两次。

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

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

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

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