nazar-pc / PickMeUp

Really simple, powerful, customizable and lightweight standalone datepicker
BSD Zero Clause License
616 stars 189 forks source link

How to trigger in-build callbacks? #58

Closed Nadoedalo closed 9 years ago

Nadoedalo commented 9 years ago

For example - I have multiple calendars, one visible at a time and I want to show only one field with inputs.

This is crucial because I have different callbacks for days and month selection.

Nadoedalo commented 9 years ago

also the get_date function should return the origital Date object as second argument, as it is in callbacks.

nazar-pc commented 9 years ago

For example - I have multiple calendars, one visible at a time and I want to show only one field with inputs.

Which callbacks do you need? (try to inspect $('...').data('pickmeup-options') for methods you need)

This is crucial because I have different callbacks for days and month selection.

You can use $('...').data('pickmeup-options').view to check what are you selecting right now

also the get_date function should return the origital Date object as second argument, as it is in callbacks.

Which callbacks do you mean?

Nadoedalo commented 9 years ago

initialize code :

this.$el.find('.switch_type .period').pickmeup({
                    flat        : true,
                    mode        : 'range',
                    calendars   : 3,
                    format : 'Y-m-d',
                    separator : '‐',
                    max : new Date(),
                    min : max_date, //you see - I can't do new Date().addYear(-10) because it will be undefined
                    change : this.changeDate.bind(this),
                    locale : locale
                });

I want to manually trigger that change callback WITH all data included. Something like $('.pickmeup').pickmeup.('trigger', 'change') - and get my callback applied

nazar-pc commented 9 years ago

Try $('...').data('pickmeup-options').binded.update_date(), this is the method from which change event is called, also combination of get/set might work.