Mattvic
Mattvic

Reputation: 426

Call two functions on events

I´m trying to call two functions when closing the jQuery UI Datepicker, but I´m not sure what´s the best way to do this.

If I only have one function I can do this:

function splitArrivalDate() {
    // Some code
} 

$( '#mydatepicker' ).datepicker({
    onClose: splitArrivalDate
}); 

But what if I want to call two functions sequentially on the onClose event?

function splitArrivalDate() {
    // Some code
} 

function setDepartureDate() {             
    // Some code
} 

$( '#mydatepicker' ).datepicker({
    onClose: splitArrivalDate; setDepartureDate // Does not work
}); 

I hope someone can help me understand this. Thanks!

Upvotes: 1

Views: 794

Answers (1)

phenomnomnominal
phenomnomnominal

Reputation: 5515

You want something like this:

$( '#mydatepicker' ).datepicker({
    onClose: function () { splitArrivalDate(); setDepartureDate(); }
}); 

Upvotes: 3

Related Questions