Replace the jquery datepicker dateFormat with momentjs parsing and format

So far the best method that I've found to do this is to override the global jquery-ui parseDate and formatDate functions like so:

$.datepicker.parseDate = function(format, value) {
    return moment(value, format).toDate();
};
$.datepicker.formatDate = function (format, value) {
    return moment(value).format(format);
};

Then this nicely allows you to use the usual syntax for attaching a datepicker to a field but the format you specify will instead refer to a momentjs format instead http://momentjs.com/docs/#/parsing/string-format/

$(".selector").datepicker({ dateFormat: "MM-DD-YYYY" });