Setting input as readonly breaks showOn "click" #425

Closed
jpgilchrist opened this Issue Aug 19, 2015 · 8 comments

Projects

None yet

6 participants

@jpgilchrist

Obviously readonly would break the showOn "focus". However, you would not expect it to break showOn "click". I have seen that you have disableInputText, which I'm currently using, but I don't want the user to focus the input at all.

@jonthornton
Owner

Setting the input to readonly disables timepicker completely. This is deliberate.

Perhaps a developer wants to use the readonly attribute as intended. Maybe part of their form gets dynamically set to readonly in certain situations. If timepicker remains active despite the readonly attribute, the developer has the do the extra step of binding/unbinding timepicker every time their form toggled readonly on/off.

Setting document.ontouchstart to some value and enabling disableTouchKeyboard in the timepicker options will trick timepicker into blurring as soon as a user clicks an input. Messing with document.ontouchstart is global and may confuse other code. You might be better off forking and hardcoding _hideKeyboard() to return true.

@jwee6
jwee6 commented Jan 8, 2016

As mentioned readonly disables timepicker completely, I tried using disableTextInput however it doesn't seem to be disabling me from manually typing into the input. What may I be missing here?

  $('#reservation_start_time').timepicker({
     'disableTextInput': true
  });

Thanks

@jonthornton
Owner

Can you post a jsFiddle demo?

@jwee6
jwee6 commented Jan 9, 2016

Sorry, I was forking from an ROR gem it must have been faulty. It's working great now, thanks for your work!

@lsintampa

However, if you do disableTextInput - the user can still focus the field, delete values and end up posting invalid information. Any fix - work around to stop users from entering the field at all so they have no choice but to select a valid entry?

@matheusjardimb

tab to next field does not work if 'disableTextInput': true. Shouldn't it?

@jonthornton
Owner

@matheusjardimb indeed it should! Thanks for pointing that out.

@pronexo-odoo

This works for me

$('#myDatePicker').datepicker({
/* options */
});

$('.readonlyjm').on('focus',function(){
$(this).trigger('blur');
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment