使用Meteor.js进行JQuery验证

时间:2016-02-23 04:02:07

标签: jquery meteor jquery-validate

我正在尝试运行该程序包:

themeteorchef:jquery-validation  1.14.0  jQuery Validation by jzaefferer, rep...

在Meteor.js上

在我的项目中,我已经包括:

client/lib/jquery.dropotron.min.js
client/lib/jquery.min.js
client/lib/jquery.scrollgress.min.js
client/lib/skel.min.js

我的包裹清单如下:

autopublish                      1.0.4  (For prototyping only) Publish the en...
blaze-html-templates             1.0.1  Compile HTML templates into reactive ...
ecmascript                       0.1.6* Compiler plugin that supports ES2015+...
es5-shim                         4.1.14  Shims and polyfills to improve ECMAS...
insecure                         1.0.4  (For prototyping only) Allow all data...
iron:router                      1.0.12  Routing specifically designed for Me...
jquery                           1.11.4  Manipulate the DOM using CSS selectors
less                             2.5.1  Leaner CSS language
meteor-base                      1.0.1  Packages that every Meteor app needs
mobile-experience                1.0.1  Packages for a great mobile user expe...
mongo                            1.1.3  Adaptor for using MongoDB and Minimon...
nemo64:bootstrap                 3.3.5_2  Highly configurable bootstrap integ...
session                          1.1.1  Session variable
spiderable                       1.0.9  Makes the application crawlable to we...
standard-minifiers               1.0.2  Standard minifiers used with Meteor a...
themeteorchef:jquery-validation  1.14.0  jQuery Validation by jzaefferer, rep...
tracker                          1.0.9  Dependency tracker to allow reactive ...

运行时:

if (Meteor.isClient) {

    Template.inquiry.onCreated(function(){
        console.log("The 'inquiry' template was just created.");
    });

    Template.inquiry.onRendered(function(){
        $('#request-form').validate();
    });

    Template.inquiry.onDestroyed(function(){
        console.log("The 'inquiry' template was just destroyed.");
    });

}

我收到错误:

Exception from Tracker afterFlush function:
TypeError: $(...).validate is not a function
    at null.<anonymous> (thewebsite.js:10)
    at template.js:116
    at Function.Template._withTemplateInstanceFunc (template.js:457)
    at fireCallbacks (template.js:112)
    at null.<anonymous> (template.js:205)
    at view.js:107
    at Object.Blaze._withCurrentView (view.js:538)
    at view.js:106
    at Object.Tracker._runFlush (tracker.js:497)
    at onGlobalMessage (setimmediate.js:102)

1 个答案:

答案 0 :(得分:0)

您的问题是因为您在客户端/ lib中同时拥有jQuery包和另一个jQuery源。看起来其他jQuery插件可能与Validate插件冲突。

由于包含了Meteor包,因此包应该包含所有依赖项。