aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/datepicker/datepicker_options.js14
-rw-r--r--ui/datepicker.js7
2 files changed, 20 insertions, 1 deletions
diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js
index 52ae74a74..3b69acf1a 100644
--- a/tests/unit/datepicker/datepicker_options.js
+++ b/tests/unit/datepicker/datepicker_options.js
@@ -41,7 +41,19 @@ test( "appendTo", 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() {
diff --git a/ui/datepicker.js b/ui/datepicker.js
index 3afe5afd0..abb18a44b 100644
--- a/ui/datepicker.js
+++ b/ui/datepicker.js
@@ -632,6 +632,13 @@ $.widget( "ui.datepicker", {
this.refresh();
}
+ if ( key === "dateFormat" ) {
+ this.date.setFormat( this.options.dateFormat );
+ if ( !this.inline ) {
+ this.element.val( this.date.format() );
+ }
+ }
+
if ( key === "showWeek" ) {
this.refresh();
}