【问题标题】:Meteor Autoform doesn't update the collectionMeteor Autoform 不会更新集合
【发布时间】:2015-10-06 19:47:04
【问题描述】:

我的 update 和 update-pushArray 没有真正更新或向我的数组添加一些内容时遇到问题。

我的模板是这样的:

<template name="PersonShow">
<div class="container">
    <div class="user-data">
        <h2>{{name}}</h2>
        {{> quickForm id="PersonShow" type="update" collection="Registry" doc=this fields="isActiveEmployee"}}
    </div>
    <div class="device-data">
        {{#each device}}
        <h3><p>Device: {{type}}</p></h3>
        <h3><p>Quantity: {{quantity}}</p></h3>
        {{#autoForm id="PersonShow" type="update" collection="Registry" doc=this}}
        {{> afQuickField name="device.0.isInUse"}}
        {{> afQuickField name="comment"}}
        <button type="submit" class="btn btn-primary">Submit</button>
        {{/autoForm}}
        {{/each}}
    </div>
    <div class="add-new-device">
        {{> quickForm id="PersonShow" type="update-pushArray" collection="Registry" doc=this scope="device"}}
    </div>
</div>
</template>

还有我的收藏:

Registry = new Mongo.Collection("registry");

Registry.attachSchema(new SimpleSchema({
  name: {
    type: String,
    label: "First and lastname",
    max: 200,
    optional: false
  },
  device: {
    type: Array,
    optional: true
  },
  'device.$': {
    type: Object
  },
  'device.$.type': {
    type: String
  },
  'device.$.isInUse': {
    type: String,
    optional: true,
    autoform: {
      options: [
        {label: "Yes", value: "Yes"},
        {label: "No", value: "No"}
        ]
    }
  },
  'device.$.serialNumber': {
    type: String,
    optional: true
  },
  'device.$.quantity': {
    type: Number,
    min: 0
  },
  isActiveEmployee: {
    type: String,
    optional: false,
    autoform: {
      options: [
        {label: "Yes", value: "Yes"},
        {label: "No", value: "No"}
        ]
    }
  },
  comment: {
    type: String,
    label: "Comments",
    optional: true,
    max: 1000
  },
}));

当我按下 update/update-pushArray 时什么都没有发生,没有任何东西被发送到集合。

如果我这样做,更新工作:

{{&gt; afQuickField name="device"}} 但我只想更新数组中的一个特定字段。

对于 update-pushArray 我也想在我的数组中添加东西device

谁能看出这有什么问题?

【问题讨论】:

    标签: javascript meteor meteor-autoform


    【解决方案1】:

    问题与模板有关。当我将每个表单放入不同的模板时,问题就解决了。

    【讨论】:

    • 您能否粘贴您的路线代码,您是如何将数据从路线发送到表单的?我的意思是doc=this。我之所以问这个问题,是因为我在检索数据并将它们显示在要更新的字段中时遇到了问题。 My unsolved question
    猜你喜欢
    • 2016-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-04
    • 1970-01-01
    相关资源
    最近更新 更多