【问题标题】:How to fix 'dtp.setDate' error in Meteor AutoForm datetimepicker?如何修复 Meteor AutoForm datetimepicker 中的“dtp.setDate”错误?
【发布时间】:2016-04-03 21:17:54
【问题描述】:

我正在尝试使用这个 AutoForm 包,但是当我尝试他们自己的代码时,出现了这个错误。

TypeError: dtp.setDate is not a function
at null.<anonymous> (aldeed_autoform-bs-datetimepicker.js:141)
at view.js:199
at Function.Template._withTemplateInstanceFunc (template.js:457)
at view.js:197
at Object.Blaze._withCurrentView (view.js:538)
at viewAutorun (view.js:196)
at Tracker.Computation._compute (tracker.js:323)
at new Tracker.Computation (tracker.js:211)
at Object.Tracker.autorun (tracker.js:562)
at Blaze.View.autorun (view.js:209)

我所拥有的是一个只显示快速表单的模板:

<template name="test">
<h1>Autoform test</h1>
{{> quickForm collection="Tests" id="insertTest" type="insert"}}
</template>

还有一个简单的模式测试:

Tests = new Mongo.Collection("tests");

TestsSchema = new SimpleSchema({
  typeTest: {
    type: Date,
    optional: true,
    autoform: {
      afFieldInput: {
        type: "bootstrap-datetimepicker"
      }
    }
  }
});

Tests.attachSchema(TestsSchema);

我已按照this page 中的说明进行操作,并将aldeed:autoform-bs-datetimepicker 和tsega:bootstrap3-datetimepicker 添加到我的Meteor 项目中。

【问题讨论】:

    标签: javascript twitter-bootstrap meteor datetimepicker meteor-autoform


    【解决方案1】:

    这是 4.x.x 版本中的 known issue。您可以通过降级到版本 3.1.3_3 来修复此错误。

    要安装版本为 3.1.3_3 的 tsega:bootstrap3-datetimepicker 软件包,请运行以下命令:

    meteor add tsega:bootstrap3-datetimepicker@=3.1.3_3 
    

    您可能还想安装 twbs:bootstrap 软件包以获得完整的 Bootstrap 支持。

    【讨论】:

    • 这严重破坏了 datetimepicker 的 css。
    • @LeQs 真的吗?你用的是哪个版本?
    • 刚刚降级到3.1.3_3
    • @LeQs 好的,你使用 twbs:bootstrap 包吗?
    • 我设法解决了这个问题。如果他的小部件不像我的情况那样长,只需覆盖小部件宽度.bootstrap-datetimepicker-widget{ width:300px !important; }
    猜你喜欢
    • 2016-08-14
    • 2016-02-08
    • 1970-01-01
    • 2015-07-05
    • 2017-10-05
    • 2020-09-26
    • 2021-03-16
    • 2014-12-11
    • 1970-01-01
    相关资源
    最近更新 更多