contributte / live-form-validation

:no_entry: Nice client-side live form validation for Nette Forms.
https://contributte.org/packages/contributte/live-form-validation.html
BSD 3-Clause "New" or "Revised" License
59 stars 24 forks source link

How to pass custom variables with es6 module? #59

Closed martinjinda closed 5 years ago

martinjinda commented 5 years ago

I'm using form validation with webpack this is how my main.js looks like, but none of the listed options doesn't work me. Is there anyone who use it with webpack as well? Or what I do wrong?

Validation works fine, but without the custom options.

import 'jquery';
import 'bootstrap';

import LiveFormValidation from 'live-form-validation-es6';

window.LiveForm = LiveFormValidation.LiveForm;
window.Nette = LiveFormValidation.Nette;

import 'nette.ajax.js';

$(function() {

  window.Nette.init();

  LiveFormValidation.setOptions({
    messageErrorPrefix: 'test 1',
  });

  window.LiveForm.setOptions({
    messageErrorPrefix: 'test 2',
  });

  LiveFormValidation.LiveForm.setOptions({
    messageErrorPrefix: 'test 3',
  });

});
martinjinda commented 5 years ago

Oh, I got it, I had from previous set up live-form-validation in the webpack config

new webpack.ProvidePlugin({
     'window.LiveForm': 'live-form-validation'
})