I tested validate plugin in html file by following its documentation, it works fine, but my project is base on require, so I removed script reference in the html then did this in require config.
var require = require || {
paths : {
jquery : "../libs/jquery/3.2.1/jquery-3.2.1.min",
validate : "../libs/vd/validate/jquery.validate.min",
},
shim : {
jquery : {
exports : "$"
},
validate : {
deps : [ "jquery" ],
exports : "validate"
}
}
};
and also in js file:
define([ "jquery", "validate"], function($, validate) {...}
it works fine. Then I tried to add localize module by adding this into config file paths:
validateLocal : "../libs/vd/validate/localization/messages_zh.min"
also shim:
validateLocal : {
deps : [ "jquery" ],
exports : "validateLocal"
}
then in js file:
define([ "jquery", "validate", "validateLocal"], function($, validate, validateLocal) {...}
not working, also tried in shim:
validateLocal : {
deps : [ "jquery", "validate" ],
exports : "validateLocal"
}
not working either.
in all this 'not working' situations I got error in console:
require.js:5 GET http://localhost:9000/jquery.validate.min.js net::ERR_ABORTED
which attracted my attention because there the validate js file address is not the location I specified. so I tried to check the network loading, I found after I add the 'validateLocal part' in require config, browser (chrome latest) will load double times of validate.min.js, but from different locations. The first one is the right one from where I specified, the second one is this error one, which of course got 403 error.
I don't know why require loads double times of this file, who triggered it and who declared this address, why http://localhost:9000/jquery.validate.min.js ?
Tried googled it and searched on stackoverflow for a whole 6 hours, please help.