0

我有一个我认为是简单的 SimpleSchema 的东西,我目前有两个模板。一个包含一个用于将新文档插入集合的快速表单,另一个也是一个快速表单,它应该从第一个模板更新文档。

插入表单工作正常,但是当我尝试加载更新模板时,我的控制台显示以下错误并且提交按钮不起作用。根据遇到类似问题的人的说法,该错误通常是由递归函数引起的,但我在任何地方都找不到。

Exception from Tracker recompute function:
debug.js:41 RangeError: Maximum call stack size exceeded
    at Object (native)
    at isObject (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1000:18)
    at isBasicObject (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1024:10)
    at parseObj (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1147:15)
    at http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1159:11
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:159:22)
    at parseObj (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1155:9)
    at http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1159:11
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:159:22)
    at parseObj (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1155:9)

这是我的两个模板:

<template name="newWeddingPage1">
    <div class="  col-sm-10 col-sm-offset-1">
    <div class="  col-md-6">
        <div class="well well-sm">

        {{> quickForm collection="Weddings" id="insertWeddingInfo1" omitFields="email, phone, name, price" type="insert"}}

    </div>
    </div>

    <div class="  col-md-6">
        <div class="well well-sm">
        {{#each theweddingdetails}}
        <h1 id="price">{{duration}}</h1>
        {{/each}}


    </div>
    </div>



  </div>
</template>


<template name="newWeddingPage2">
    <div class="  col-sm-10 col-sm-offset-1">
    <div class="  col-md-6">
        <div class="well well-sm">
        {{#each theweddingdetails}} 
        {{> quickForm collection="Weddings" id="updateWeddingInfo1" doc="this" omitFields="email, phone, name, price" type="update"}}
        {{/each}}

    </div>
    </div>


  </div>
</template>

和我在这里的简单模式:

Weddings.attachSchema(new SimpleSchema({

  address: {
    type: String,
    label: "Address",
    optional: true
  },
  startDate: {
    type: Date,
    label: "Date of shooting",
    optional: false,
  },
  startTime: {
    type: String,
    optional: true,
    autoform: {
      afFieldInput: {
        type: "time"
      }
    }
  },
  duration: {
    type: Number,
    label: "Duration (in hours)",
    optional: true
  },
  price: {
    type: Number,
    label: "Price",
    optional: true,
    autoform: {
      type: "hidden",
      label: false
    },
    autoValue:function(){ return 0 }
  },
  email: {
    type: String,
    optional: true,
    autoform: {
      afFieldInput: {
        type: "email"
      }
    }
  },
  phone: {
    type: Number,
    optional: true,
    autoform: {
      afFieldInput: {
        type: "tel"
      }
    }
  },
  name: {
    type: String,
    label: "Contact Person",
    optional: true
  },
  createdBy: {
    type: String,
    autoform: {
      type: "hidden",
      label: false
    },
    autoValue:function(){ return this.userId }
},
createdAt: {
    type: Date,
    autoform: {
      type: "hidden",
      label: false
    },
    autoValue:function(){ return new Date(); }
}
}));

有人知道我哪里出错了吗?

在过去的几个小时里一直在玩比特:/

4

1 回答 1

2

在您的更新表单中,您有doc="this",这意味着您只是将字符串“this”作为您的文档传递。

试试doc=this,不带引号。这样,您将传递上下文变量this作为您的文档。我假设在您的路由器或其他地方您已将适当的文档作为您的数据上下文传递,以便它可以在this

于 2015-09-18T14:50:46.900 回答