Skip to content

Commit

Permalink
primefaces#11645 DatePicker lazy inline
Browse files Browse the repository at this point in the history
  • Loading branch information
jepsar committed Mar 18, 2024
1 parent 6ad3441 commit 3f8d90b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</p:datePicker>

<p:outputLabel for="lazyEvent" value="Lazy and Event"/>
<p:datePicker pattern="yyyy-MM-dd" id="lazyEvent" value="#{datePickerMetadataView.date4}"
<p:datePicker inline="true" id="lazyEvent" value="#{datePickerMetadataView.date4}"
model="#{datePickerMetadataView.modelLazy}">
<p:ajax event="viewChange" listener="#{datePickerMetadataView.onViewChange}" update="growl"/>
</p:datePicker>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
};
}

Expand Down Expand Up @@ -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();
}
},

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3f8d90b

Please sign in to comment.