Is it possible to define a object in the options of a class in Mootools?
I’m trying to access a date object to the options object of a instance of a class.
options: {
date: new Date().increment('year')
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
er, not sure what the point is of this question. it would have been so much easier to try it.
so yes, it is possible. you can pass on any object, including date – as long as it’s available at the time of definition and does not try to reference the class prototype or instance itself, which may cause problems.
keep in mind the date will get set statically on the prototype. so if you did
date: new Date()and then instantiated the class say 5 mins later w/o passing a new date via options, it will reference the date at the time of the definition of the class, not instantiation. prolly not important to you as you are after a date an year into the future.http://jsfiddle.net/qV3JM/