Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was looking for the same solution. I wanted a OK and Cancel button and when a date is selected, that the input field is not updated unless you click on OK.</p> <p>You need to adjust the following:</p> <ul> <li><p>add stayOpen: true to the this._defaults = { global defaults.</p></li> <li><p>in _selectDate: function(id, dateStr) { you need to adjust:</p> <pre><code>if (inst.input) inst.input.val(dateStr); </code></pre></li> </ul> <p>to</p> <pre><code> var stayOpen = this._get(inst, 'stayOpen'); if (!stayOpen &amp;&amp; inst.input) inst.input.val(dateStr); </code></pre> <p>because this updates the value of the input field when you select a date. You need to set stayOpen: true if you want to only change the date if you click ok, otherwise the datepicker will close when you select a new date. So that is why we also get the stayOpen so that if this is true, it will update the input field before closing.</p> <p>You can also use this parameter in the else to not hide the datepicker:</p> <pre><code>else if (!stayOpen) { this._hideDatepicker(); </code></pre> <ul> <li><p>I use the close button as OK button so in _generateHTML: function(inst) { you need to adjust the data-handler="hide" of that button to something else like data-handler="ok".</p></li> <li><p>In _attachHandlers: function(inst) { you can then add a new handler to the end:</p> <pre><code>, ok: function () { window['DP_jQuery_' + dpuuid].datepicker._updateInput(id, inst); } </code></pre></li> <li><p>you can then add a new function like this to update the input field and hide the datepicker:</p> <pre><code>_updateInput: function(id, inst) { if (inst.input) { inst.input.val(this._formatDate(inst)); } this._hideDatepicker(); }, </code></pre></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload