【问题标题】:jquery-validation on Meteor流星上的jQuery验证
【发布时间】:2015-10-22 21:51:29
【问题描述】:

我正在根据网站尝试 jquery-validation 包 https://atmospherejs.com/themeteorchef/jquery-validation

  1. 制作测试项目。 (流星创建测试)
  2. 将代码复制并粘贴到我的文件中。 (test.js , test.html)
  3. 添加包。 (meteor add themeteorchef:jquery-validation)
  4. 运行。 (流星雨)

我在控制台中收到如下错误消息。

“未捕获的 TypeError:Template.exampleForm.rendered 不是函数”

你能告诉我为什么这些代码不起作用吗?

其实我添加了一个代码"console.log($("#validation-example"))"并在控制台中搜索'validate'方法,但是我在对象"$("#validation-example")".中找不到它

【问题讨论】:

  • 您好,您能否提供一个重现问题的最小示例(或至少为您的问题添加更多代码)?我创建了一个演示应用程序,安装了软件包,但无法重现您的问题。
  • 对不起。我没有说我在 部分的文件“test.html”中添加了一行,如下所示。

标签: jquery validation meteor


【解决方案1】:

以下是从流星 v1.1 开始使用 onRendered 的方法(而不是已弃用的 rendered 属性):

Template.exampleForm.onRendered(function () {
  // place your code here
  console.log("exampleForm is rendered");
});

出于历史目的,这里是旧版本的方式。注意我们是如何分配一个函数给它而不是调用rendered()

Template.exampleForm.rendered = function () {
  // place your code here
  console.log("exampleForm is rendered");
};

【讨论】:

    猜你喜欢
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 2014-08-20
    • 2014-12-14
    • 2016-08-07
    • 2023-04-05
    • 2019-03-04
    • 2021-10-19
    相关资源
    最近更新 更多