dimanche 28 juillet 2019

Ember form-for addon's text-field onblur not working

I tried onblur, focus-out, focusout, onfocusout, blur and focusOut throws error as it's a tagless component. None of them are working.

I'm trying to build a user form and validate the input when the user blur's from the field.

I'm using the below addon's together

Component Template File


  
  
    <p></p>
  
  
  
    <p></p>
  
  
  
    <p></p>
  
  


Component Javascript File

import Component from '@ember/component';
import { get }   from '@ember/object';
import Changeset from 'ember-changeset';
import lookupValidator from 'ember-changeset-validations';
import UserValidations from '../../validations/user';

export default Component.extend({
  init() {
    this._super(...arguments);
    this.user = new Changeset(get(this, 'model'), lookupValidator(UserValidations), UserValidations);
  },
  actions:{
    validateOnBlur(changeset, property){
      debugger
    },
    async submit(changeset){
      await changeset.validate();
      if(changeset.isValid){
        changeset.save();
      }
    }
  }
});

Validator

import {
  validatePresence,
  validateLength,
  validateFormat
} from 'ember-changeset-validations/validators';

export default {
  name: validatePresence(true),
  email: [
    validatePresence(true),
    validateFormat({ type: 'email' })
  ],
  password: [
    validatePresence(true),
    validateLength({ min: 8 })
  ]
};




Aucun commentaire:

Enregistrer un commentaire