stefangabos / Zebra_Form

A jQuery augmented PHP library for creating secure HTML forms and validating them easily
Other
98 stars 49 forks source link

Date object events #27

Closed pjjroux closed 8 years ago

pjjroux commented 8 years ago

Zebra datepicker only fires on: onBlur and onFocus.

onSelect, onChange, onClose doesn't fire.

stefangabos commented 8 years ago

Although it is not possible to set (easily) any of those when used from Zebra_Form, they still work. Here's how to do it:

In you PHP, after instantiating the library via

$form = new Zebra_Form('myform')

you'd set

$form->clientside_validation(array(
    'on_ready' => 'callback',
));

In your JavaScript code have, in the global scope, something like

// i am outside the "document ready" part, in the global scope!
var callback = function() {

    // don't forget to change "#your_date_element" to your element's name
    var datepicker = $('#your_date_element').data('Zebra_DatePicker');

    datepicker.update({
        onClose: function() {
            alert('close');
        },
        onChange: function() {
            alert('change');
        },
        onSelect: function() {
            alert('select');
        }
    });

}

$(document).ready(function() {
    // your other JavaScript/jQuery code
});
pjjroux commented 8 years ago

Thank you very much for the assistance