javascript - Make Meteor Schemas accessible sitewide using global variables -
i trying grips using simpleschemas in meteor app.
i have had no problem defining them , can see validation rules working i've added autoform package , when try use schemas i've defined can't seem access object they're stored in. i'm assuming issue lack of understanding around makes variable global etc.
in file called schemas.js
inside /collections
directory have
var schemas = {}; schemas.addressdetails = new simpleschema({ address_line_1: { type: string, } ... }); schemas.contactdetails = new simpleschema({ address: { type: schemas.addressdetails } }); ...
but if try , access schemas
object within file located within /client/pages/<page>.js
using following code error when autoform tries access schema can't found.
template.admorganisationsetupstepone.helpers({ schema: function() { return schemas.contactdetails; } });
so appears had done 2 things wrong.
my schemas.js file needed ran /lib
directory executed before of other code loaded. bjørn
my second mistake had defined schemas = {};
var
prefix. calling var
limited use of schemas object meaning couldn't used within different page or script.
Comments
Post a Comment