Datepicker: Allow dateFormat to be changed after init

This commit is contained in:
TJ VanToll 2013-11-20 08:37:24 -05:00 committed by Scott González
parent 13cd6c2fe5
commit ab94999105
2 changed files with 20 additions and 1 deletions

View File

@ -41,7 +41,19 @@ test( "appendTo", function() {
}); });
test( "dateFormat", function() { test( "dateFormat", function() {
expect( 0 ); expect( 2 );
var input = $( "#datepicker" ).val( "1/1/2014" ).datepicker(),
picker = input.datepicker( "widget" ),
firstDayLink = picker.find( "td[id]:first a" );
input.datepicker( "open" );
firstDayLink.trigger( "mousedown" );
equal( input.val(), "1/1/2014", "default formatting" );
input.datepicker( "option", "dateFormat", "D" );
equal( input.val(), "Wednesday, January 01, 2014", "updated formatting" );
input.datepicker( "destroy" );
}); });
test( "eachDay", function() { test( "eachDay", function() {

View File

@ -632,6 +632,13 @@ $.widget( "ui.datepicker", {
this.refresh(); this.refresh();
} }
if ( key === "dateFormat" ) {
this.date.setFormat( this.options.dateFormat );
if ( !this.inline ) {
this.element.val( this.date.format() );
}
}
if ( key === "showWeek" ) { if ( key === "showWeek" ) {
this.refresh(); this.refresh();
} }