Meteor autoform表格未定义

时间:2015-08-03 15:59:05

标签: meteor meteor-autoform

我正在尝试使用quickform进行方法更新,但每当我输入并提交时,控制台中都会显示以下错误。

Uncaught TypeError: Cannot read property 'validation' of undefined
Uncaught TypeError: Cannot read property 'autosave' of undefined
Uncaught TypeError: Cannot read property 'type' of undefined

{{#quickForm id="archiveIssue" type="method-update" meteormethod="editIssue" collection=collection doc=doc autocomplete="off"}}
  {{> afQuickField name='Notes'}}
{{/quickForm}}

检索集合的辅助函数。

Template.archiveIssue.helpers({
  doc: function () {
    return Session.get("archiveDoc");
  },
  collection: function () {
    return Collections.Issues;
  }
});

这些问题并非来自流星方法,实际上这种方法实际上并未被调用。他们在更新autoform包后开始出现 - > https://github.com/aldeed/meteor-autoform/blob/master/CHANGELOG.md

{1}}出现在键入的所有内容中。当我尝试提交时,另外两个出现。

方法

Cannot read property 'validation' of undefined

模式

if (Meteor.isServer){
  Meteor.methods({
    newIssue: function(doc) {
      check(doc, Schema.Issues);
      Collections.Issues.insert({
        User: Meteor.user()._id,
        Description: doc.Description,
        createdAt: new Date,
        Archived: {
          "Archived": false,
          "User": null,
          "Notes": null
        },
      });
    },
    editIssue: function(modifier, docId) {
      console.log('editIssue called; modifier = ' + JSON.stringify(modifier, null, 4) + '; docId = ' + docId);
      check(modifier, Schema.Issues);
      Collections.Issues.update({
          "_id": docId
        },
        modifier
      );
    },
  });
}

模板

Collections.Issues = new Mongo.Collection('issues');

Schema.Issues = new SimpleSchema({
  Description: {
    type: String,
    max: 500,
    optional: true
  },
  User: {
    type: String,
    label: "User",
    optional: true
  },
  Notes: {
    type: String,
    label: "Notes",
    optional: true
  },
  Archived: {
    type: Object,
    optional: true
  },
  "Archived.Archived": {
    type: Boolean,
    optional: true
  },
  "Archived.User": {
    type: String,
    max: 50,
    label: "Archiving User",
    optional: true
  }, 
  "Archived.Notes": {
    type: String,
    label: "Notes",
    optional: true
  }
});

Collections.Issues.attachSchema(Schema.Issues);

存档文档是从帮助程序

设置的
<template name="issues">
    <div style="width:90%">
        <h1><i class="fa fa-exclamation-triangle"> Issues</i></h1>
      <h2> Active </h2>
        {{> issueModal}}
        {{> tabular table=TabTables.Issues selector=Active_Selector class="table table-striped table-bordered table-condensed" width="100%"}}
      <h2> Archived </h2>
        {{> tabular table=TabTables.Issues_Archived selector=Archive_Selector class="table table-striped table-bordered table-condensed" width="100%"}}      
    </div>
</template>

<template name="issueModal">
    <div class="modal fade" id="insertIssueModal" role="dialog">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">New Issue</h4>
          </div>
          <div class="modal-body">
            <p>{{> insertIssue}}</p>
          </div>
        </div>
      </div>
    </div>

    <div class="addButton"><button type="button" class="btn btn-success" data-toggle="modal" data-target="#insertIssueModal"><i class="fa fa-plus-square fa-lg"> Add Issue</i></button></div>
</template>

<template name="insertIssue">
  {{#quickForm id="insertIssue" type="method" meteormethod="newIssue" collection=collection validation="keyup" fields="Description" omit="User,Archived.Archived,Archived.User,Archived.Notes" autocomplete="off"}}
  {{/quickForm}}
</template>

<template name="archiveIssueModal">
    <div class="modal fade" id="archiveIssue" role="dialog">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header" >
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title" ><i class="fa fa-archive"> Archive Issue</i></h4>
          </div>
          <div class="modal-body">
            <p>{{> archiveIssue}}</p>
          </div>
        </div>
      </div>
    </div>
    <div class="archiveButton" style="margin: auto 0;" align="center">
      <button id="archiveButton" type="button" class="btn btn-xs btn-info" data-toggle="modal" data-target="#archiveIssue"><i class="fa fa-archive"> Archive</i></button>
    </div>
</template>

<template name="archiveIssue">
  <div align="left">
    {{#quickForm id="archiveIssue" type="method-update" meteormethod="editIssue" collection=collection doc=doc autocomplete="off"}}
      {{> afQuickField name='Notes'}}
    {{/quickForm}}
  </div>
</template>

1 个答案:

答案 0 :(得分:2)

我刚刚遇到了这个问题,问题是我有另一个HTML标签,其ID与我的表格完全相同。

更改HTML标记ID或表单ID解决了问题。 :)