How to use the flatpickr.setDefaults function in flatpickr

To help you get started, we’ve selected a few flatpickr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ankurk91 / vue-flatpickr-component / examples / App.vue View on Github external
import Vue from 'vue';
  import flatpickr from "flatpickr";
  // Init component
  import flatPickrComponent from '../src/index.js';
  // Need to add base css for flatpickr
  import 'flatpickr/dist/flatpickr.min.css';
  // l10n is optional
  import {Hindi as HindiLocale} from 'flatpickr/dist/l10n/hi.js';
  import {english as EnglishLocale} from 'flatpickr/dist/l10n/default.js'
  // Plugins are optional
  // https://chmln.github.io/flatpickr/plugins/
  import ConfirmDatePlugin from 'flatpickr/dist/plugins/confirmDate/confirmDate.js';
  import 'flatpickr/dist/plugins/confirmDate/confirmDate.css';

  // Override Global settings
  flatpickr.setDefaults({
    disableMobile: true,
    onClose: () => {
      console.log("close event from global config")
    }
  });

  Vue.use(flatPickrComponent);

  export default {
    name: 'app',
    data() {
      return {
        inputDisabled: false,
        form: {
          dateBasic: null,
          dateTime: null,
github ankurk91 / vue-flatpickr-component / __test__ / events.spec.js View on Github external
describe('Flatpickr events', () => {

  let wrapper;
  let onChangeStub = jest.fn();

  const globalOnChange = jest.fn();

  Flatpicker.setDefaults({
    onChange: globalOnChange
  });

  beforeEach(() => {
    wrapper = mount(Component, {
      propsData: {
        value: null,
        config: {
          onChange: onChangeStub
        }
      }
    });
  });

  afterEach(() => {
    wrapper.destroy();