How do you prevent a jQuery UI Date Picker from giving the input focus when shown? -
the default behavior of jquery date picker gives input field focus when date picker shown. on mobile device (e.g., iphone), behavior undesirable because slides keyboard , obscures date picker.
i working around issue disabling input field when date picker shown , re-enabling when closed. works seems less ideal.
html:
<input type="text" id="start-date" class="date-input" /> <button id="start-date-calendar">go</button> javascript:
$(document).ready(function () { $(".date-input").datepicker({ numberofmonths: 2, showbuttonpanel: true, showanim: 'slidedown', showcurrentatpos: 1, stepmonths: 2, beforeshow: function (input, datepicker) { input.disabled = true; }, onclose: function (datetext, datepicker) { this.disabled = false; } }); $(".date-input").off(); $("#start-date-calendar").click(function () { $('#start-date').datepicker("show"); }); }); here working example.
is possible stop focus happening directly?
Comments
Post a Comment