La soluzione di Alex è stata buona, ma non ha funzionato bene se si è tentato di ridimensionare la finestra. Il problema era che jquery ui sta cercando di calcolare la posizione del widget, in modo che non rimanga mai fuori dalla vista. Il fatto è che non funziona bene con la soluzione di Alex. Ho cambiato il codice sorgente (che non è molto bello, ma solo la soluzione che ho trovato) per raggiungere il risultato. Ecco la funzione on line 3960 che ho cambiato:
/* Check positioning to remain on screen. */
_checkOffset: function(inst, offset, isFixed) {
// CHANGED This way I can add class date-right to the input to make it right aligned
var isRightAlign = inst.input.hasClass('date-right');
var dpWidth = inst.dpDiv.outerWidth();
var dpHeight = inst.dpDiv.outerHeight();
var inputWidth = inst.input ? inst.input.outerWidth() : 0;
var inputHeight = inst.input ? inst.input.outerHeight() : 0;
var viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft());
var viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
// CHANGED Alex's solution is implemented on the next line (just add || isRightAlign)
offset.left -= (this._get(inst, 'isRTL') || isRightAlign ? (dpWidth - inputWidth) : 0);
offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
offset.top -= (isFixed && offset.top == (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
// CHANGED Do not check if datepicker is outside of the viewport if it's right aligned
if(!isRightAlign){
// now check if datepicker is showing outside window viewport - move to a better place if so.
offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
Math.abs(offset.left + dpWidth - viewWidth) : 0);
}
offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
Math.abs(dpHeight + inputHeight) : 0);
return offset;
},
fonte
2012-12-24 16:07:46
la sua assurdità e un trucco per tornare alla modalità di rtl solo per allineare a destra qualcosa – mare