Rupert
Rupert

Reputation: 125

the jqueryui datepicker "create" of event don't work

In my project which uses with jQueryUI's datepicker of plugins,

but in this code, the "create" event never fires,

you can check the documentation in official site: http://jqueryui.com/demos/datepicker/#option-showOptions

$('#datepicker').datepicker({
    create: function(event, ui) {
        alert("ppp");
    }
});

Upvotes: 2

Views: 1320

Answers (2)

Vipin
Vipin

Reputation: 11

There is no event for create in date picker plugin in Jquery ui. You can use:

$('#datepicker').datepicker({ 
    onSelect: function (dateText, inst) {
        create(); 
    } 
}); 
function create() { 
    alert("ppp"); 
}

Upvotes: 1

Didier Ghys
Didier Ghys

Reputation: 30666

You won't be able to achieve this with the jQuery UI Datepicker because no such event is simply triggered.

The documentation of jQuery UI is sometimes a bit falsy. My opinion is that the authors rely on the fact that all plugins are using the Widget Factory but this is actually not the case for the datepicker !

For plugins thats uses the Widget factory, the event "create" is automatically triggered during the creation of the Widget:

_createWidget: function( options, element ) {
    // some other code
    // ...    
    this._create();
    this._trigger( "create" );
    this._init();
},

Unfortunately, neither the datepicker implements the Widget factory (this planned though) nor it triggers a "create" event explicitely (source).

Didier.

Upvotes: 1

Related Questions