Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

litepicker.com/docs/events - where do I put those lines of code? #301

Open
ghost opened this issue Jun 2, 2022 · 1 comment
Open

litepicker.com/docs/events - where do I put those lines of code? #301

ghost opened this issue Jun 2, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 2, 2022

I tried to put

      setup: (picker) => {
        picker.on('before:click', (target) => {
          window.alert(1);
        });
      }

into Picker options.

var picker_options = {
  element: _start_element[0],
  elementEnd: _end_element[0],
  format: "YYYY-MM-DD",
  singleMode: false

  setup: (picker) => {
    picker.on('before:click', (target) => {
      window.alert(1);
    });
  }
}
var p = new Litepicker(picker_options);

It doesn't work. Where do I put this? Can examples be more detailed, maybe the full snippet for applying the litepicker to an input?

@rbosch
Copy link

rbosch commented Sep 27, 2022

You bind them to the instance of the initialisation code. I guess you figured it out by now, but this is for others.

var picker_options = {
  element: _start_element[0],
  elementEnd: _end_element[0],
  format: "YYYY-MM-DD",
  singleMode: false

  setup: (picker) => {
    picker.on('before:click', (target) => {
      window.alert(1);
    });
  }
}

var p = new Litepicker(picker_options);
p.on('show', () => {
        // some action after show
        alert('hello world'); 
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant