Reputation: 4318
I have two js file :
validate.js
login.js
login.js needs function in validate.js, so login.js must call after validate.js. but in meteorjs i dont know how to sort it like that. because as i know all file js in client/ will be loaded. and this is the result :
login.js
validate.js
please help how to sort thid js file?
update Okay i can sort js file now, but i cant call function from validate.js this is my validate.js :
function firstValidator(){
this.isTextValidate = {
text : function(text){
return true;
},
password: function(password){
return true;
},
date: function(date){
return true;
}
}
}
and this is my login.js
var isValid = new firstValidator();
Template.cust_login.events({
'click button':function(){
login();
},
'keyup input#inputUserLogin': function () {
alert(isValid.isTextValidate.text("text"));
},
'keyup input#inputUserPassword': function () {
}
});
and it error in :
var isValid = new firstValidator();
Uncaught ReferenceError: firstValidator is not defined
why this is happend? and how to solve this, so i can use firstValidator() in another js
Upvotes: 0
Views: 93
Reputation: 7680
Meteor loads files in the same directory alphabetically. Files in deeper subdirectories are loaded first. Files in a lib/
directory are loaded before everything else. Files named like main.*
are loaded last. In your case I would put validate.js
in client/lib/
. If you want your validate file to be available on the client and the server, put it just in lib/
instead.
Upvotes: 3