我有以下 config.js
require.config({
baseUrl: "/static/js",
paths: {
jquery: "src/jquery-1.7.2",
jqueryui: "src/jquery-ui-1.10.0.custom/js/jquery-ui-custom",
angular: "src/angular/1.0.4/angular",
bootstrap: "bootstrap/js/bootstrap"
},
shim: {
"jquery-validation-1.10.0/dist/jquery.validation.min" : {
deps: ["jquery"],
exports: "jquery.validation"
}
}
});
在我正在加载的一个 js 文件(名为signup.js
)中,我试图使validate
来自 jquery 验证插件的方法可用。
# File signup.js
define(["jquery"], function($) {
$('#beta_signup_form button[type=submit]').attr("disabled", "disabled");
$('#beta_signup_form').validate({
rules: {
name: {
required: true,
minlength: 4
},
email: {
required: true,
email: true
}
},
focusCleanup: true,
onkeyup: false,
errorElement: "span",
... the rest of the code ...
我在控制台中收到一个错误,上面写着Uncaught TypeError: Object [object Object] has no method 'validate'
.
如何将validate
方法传递给我的signup.js
脚本?