diff --git a/primefaces-showcase/src/main/webapp/ui/input/datepicker/metadata.xhtml b/primefaces-showcase/src/main/webapp/ui/input/datepicker/metadata.xhtml
index 460cb4c997..288c5234b3 100644
--- a/primefaces-showcase/src/main/webapp/ui/input/datepicker/metadata.xhtml
+++ b/primefaces-showcase/src/main/webapp/ui/input/datepicker/metadata.xhtml
@@ -52,7 +52,7 @@
-
diff --git a/primefaces/src/main/resources/META-INF/resources/primefaces/datepicker/1-datepicker.js b/primefaces/src/main/resources/META-INF/resources/primefaces/datepicker/1-datepicker.js
index 30011f0b8c..92898ec438 100644
--- a/primefaces/src/main/resources/META-INF/resources/primefaces/datepicker/1-datepicker.js
+++ b/primefaces/src/main/resources/META-INF/resources/primefaces/datepicker/1-datepicker.js
@@ -130,11 +130,6 @@ PrimeFaces.widget.DatePicker = PrimeFaces.widget.BaseWidget.extend({
if(preShow) {
return $this.cfg.preShow.call($this, inst);
}
-
- // #7457 trigger view change if lazy model is used
- if ($this.cfg.lazyModel) {
- $this.fireViewChangeEvent($this.getViewDate());
- }
};
}
@@ -189,6 +184,11 @@ PrimeFaces.widget.DatePicker = PrimeFaces.widget.BaseWidget.extend({
//pfs metadata
this.input.data(PrimeFaces.CLIENT_ID_DATA, this.id);
+
+ // #7457 #11645 trigger view change if lazy model is used
+ if (this.cfg.lazyModel) {
+ this.updateLazyModel();
+ }
},
/**
@@ -424,6 +424,15 @@ PrimeFaces.widget.DatePicker = PrimeFaces.widget.BaseWidget.extend({
}
},
+ /**
+ * Triggers a viewChange event which updates the lazy model through an Ajax request using the current date.
+ */
+ updateLazyModel: function() {
+ if (this.cfg.lazyModel) {
+ this.fireViewChangeEvent(this.getViewDate());
+ }
+ },
+
/**
* Sets up the event listeners for when the date picker is closed.
* @private