Javascript 使用aldeed autoform更新meteor

Javascript 使用aldeed autoform更新meteor,javascript,mongodb,meteor,field,Javascript,Mongodb,Meteor,Field,我在一个收藏项目(gigs)的单页上,我想在我的“展示”页面上推到该项目的数组。我的想法是,我有一个模式,弹出下面,你可以添加另一个条目 我用aldeed autoform尝试过这个,但是我没有推送到收集项目。为什么? <!-- Modal Structure --> <div id="modal1" class="modal bottom-sheet"> <div class="container"> <div class="mo

我在一个收藏项目(gigs)的单页上,我想在我的“展示”页面上推到该项目的数组。我的想法是,我有一个模式,弹出下面,你可以添加另一个条目

我用aldeed autoform尝试过这个,但是我没有推送到收集项目。为什么?

 <!-- Modal Structure -->
  <div id="modal1" class="modal bottom-sheet">
    <div class="container">
    <div class="modal-footer">
      <a href="#!" class=" modal-action modal-close waves-effect waves-green btn-flat">CLOSE</a>
    </div>
    <div class="modal-content">
      {{#autoForm collection="Gigs" id="myForm" }}

      {{#afEachArrayItem name="gear"}}

          {{> afQuickField name=this.current.item}}
          {{> afQuickField name=this.current.description}}

      {{/afEachArrayItem}}
      <button type="submit" class="btn update-gig">Add</button>
    {{/autoForm}}
    </div>

    </div>
  </div>
并在js中为表单添加了一个方法

Meteor.methods({
   addGig: function(id, gear){
     Gigs.update(id,{ $addToSet: { gear: gear } })
   }
});
并在客户端调用它尝试:

Template.Gig.events({
  'submit .update-gig': function(){
    Meteor.call('addGig', this._id, this.gear)
  }
})
简单模式

Gear = new SimpleSchema({
  item: {
    type: String,
    label: "Item",
    optional: false
  },
  description: {
    type: String,
    label: "Description",
    optional: true
  },
  user:{
    type: String,
    label: "User",
    autoValue: function() {
      return this.userId
    },
    autoform: {
      type: "hidden"
    }
  },
  createdAt: {
    type: Date,
    label: "Created At",
    autoValue: function(){
      return new Date()
    },
    autoform: {
      type: "hidden"
    }
  }
});

GigsSchema = new SimpleSchema({
  gig: {
    type: String,
    label: 'Gig Name'
  },
  location: {
    type: String,
    label: 'Location'
  },
  gear: {
    type: [Gear]
  },
  user:{
    type: String,
    label: "User",
    autoValue: function() {
      return this.userId
    },
    autoform: {
      type: "hidden"
    }
  },
  createdAt: {
    type: Date,
    label: "Created At",
    autoValue: function(){
      return new Date()
    },
    autoform: {
      type: "hidden"
    }
  }
});

更新:我有这个工作,但如果任何人有一个更简单的方法使用autoform,将不胜感激

客户端代码:

'submit .update-gig-form': function(event){

        event.preventDefault();

        var id = FlowRouter.getParam('id');
        var item = event.target.form_item.value;
        var desc = event.target.form_desc.value;

        // jquery materialize css to close modal on page
        $('#modal1').closeModal();

    Meteor.call('addGear', id, item, desc);

    //reset form
    event.target.form_item.value = '';
    event.target.form_desc.value = '';
  }
服务器代码

Meteor.methods({
   addGear: function(id, form_item, form_desc){
     console.log('yay method run');
     Gigs.update(id,{ $addToSet: { gear: {
       item: form_item,
       description: form_desc
     }}
     });
   }
});

看一看墙上的画。试着使用我已经,我已经为收集gig和数组字段Gear实现了简单的模式。好的,我已经做了很长一段时间,在页面上手动键入表单,传递值,并通过方法传递它们-效果很好。
Meteor.methods({
   addGear: function(id, form_item, form_desc){
     console.log('yay method run');
     Gigs.update(id,{ $addToSet: { gear: {
       item: form_item,
       description: form_desc
     }}
     });
   }
});