JQuery 使用 Meteor.js 验证
JQuery Validation with Meteor.js
我正在尝试 运行 包裹:
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)
您的问题是因为您在 client/lib 中同时拥有 jQuery 软件包和另一个 jQuery 源。看起来其他 jQuery 插件可能与验证插件冲突。
由于包含 Meteor 软件包,因此该软件包应包含您的所有依赖项。
我正在尝试 运行 包裹:
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)
您的问题是因为您在 client/lib 中同时拥有 jQuery 软件包和另一个 jQuery 源。看起来其他 jQuery 插件可能与验证插件冲突。
由于包含 Meteor 软件包,因此该软件包应包含您的所有依赖项。