jcsmorais / shortcut-buttons-flatpickr

Flatpickr's plugin that provides users an alternative way to interact with the datetime picker.
MIT License
26 stars 15 forks source link

Update CDN link in the readme to latest version #40

Open nsmeele opened 2 years ago

nsmeele commented 2 years ago

Hi!

It took me longer than I'm proud of to figure out why button.attributes.class wasn't working. Then I realized, the JS that I downloaded from the CDN link, was still old an old version. :)

So just a little heads-up, maybe update these links?

arthursioux commented 7 months ago

Here's and example of how to use the class, for novices like me. It taked a while too.

<script type="text/javascript">
    flatpickr.setDefaults({
        plugins: [
        ShortcutButtonsPlugin({
            theme: 'dark',
            button: [
                {
                    label: "Aceptar",
                      attributes: {
                          class: "btn btn-sm rounded-pill btn-light waves-effect",
                      }
                    },
                {
                      label: "Cancelar",
                      attributes: {
                          class: "btn btn-sm rounded-pill btn-light waves-effect",
                       }
                   },
                {
                      label: "Hoy",
                      attributes: {
                          class: "btn btn-sm rounded-pill btn-light waves-effect",
                       }
                }
            ],

            //label: "or",
            onClick: (index, fp) => {
                switch (index) {
                     case 0:
                        fp.close();
                        break;
                      case 1:
                          fp.close();
                        break;
                      case 2:
                        fp.close();
                        fp.setDate(new Date());
                        break;
                    }
                  }
            })
        ]
    });

</script>