【问题标题】:meteor update-how to update the value?流星更新-如何更新值?
【发布时间】:2016-03-29 12:35:11
【问题描述】:

请帮我解决这个问题:我需要在更新过程后更改值,到目前为止,我的代码不起作用。

这是代码:

Template. edit_peralatan.events({
  'submit .peralatan': function (event){
    event.preventDefault();

    var currentPostId= Session.get ('this._id');
    var profil=Profil.findOne(currentPostId);

    var properties={
      kategori: $(event.target).find('[name=kategori]'). val(),
      jenama: $(event.target).find('[name=jenama]'). val(),
      trPerolehan: $(event.target).find('[name=trPerolehan]'). val(),
      noSiri: $(event.target).find('[name=noSiri]'). val(),
      noRedicare: $(event.target).find('[name=noRedicare]'). val(),    
    };

    Profil.update( currentPostId,{ $set: properties },
      function (error){
        if (error){
          alert (error.reason);
        } else {
          Router.go('list_inventori',{_id:currentPostId});
        }
      });
    }
});

【问题讨论】:

  • 具体一点 - 什么不起作用?
  • 这是代码。我不知道如何解决它。单击“提交”按钮后,值没有改变。

标签: meteor


【解决方案1】:

var currentPostId= Session.get ('this._id'); 几乎肯定是您的错误的根本原因,因为将会话变量命名为 'this._id'(字符串)是没有意义的。你来这里的真正目的是什么?你的意思是:

var currentPostId= this._id;

【讨论】:

  • 这是work.tq。还有一个问题。您知道如何从其他模板(集合)获取值并创建为选择选项(下拉),表单更新中的下一个选定值。
猜你喜欢
  • 2017-08-26
  • 1970-01-01
  • 2014-05-31
  • 1970-01-01
  • 2012-06-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-09-27
相关资源
最近更新 更多