Since Ember doesn't support form validation out of the box (as of this writing anyway), I am looking for a way to validate forms. I came across Dockyards ember-validations and the consensus seems to be that this is the goto module for form validation in EmberJS.
I'm trying to get it to work, but I'm having some trouble getting started.
I'm not using Ember CLI as referenced in the docs, so I have downloaded a compiled ember-validations.js from http://ift.tt/1M5qXr7 and have included ember-validations.js in my apps js file.
The docs now say to pass the validations.mixin into a controller:
So I'm using:
App.MemberaddController = App.FamilyController.extend(EmberValidations.Mixin,{
needs: ["family","notifications"],
familyController: Em.computed.alias('controllers.family'),
notifications: Em.computed.alias('controllers.notifications'),
validations: {
firstname: {
presence: true,
presence : {message: 'mag niet leeg zijn'}
}
},
init: function() {
this.set('familyController.pageTitle', "Gezinslid toevoegen");
},
<etc...>
}
However in the browser I'm seeing
Uncaught ReferenceError: EmberValidations is not defined
Looking at the ember-validations.js I can see the mixin file being referenced as Ember.Validations.Mixin.
So when I pass that to my controller, I'm seeing:
Error while processing route: memberadd Cannot read property 'invoke' of undefined TypeError: Cannot read property 'invoke' of undefined
What am I doing wrong here?
Aucun commentaire:
Enregistrer un commentaire