Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting input as readonly breaks showOn "click" #425

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

Setting input as readonly breaks showOn "click" #425

jpgilchrist opened this issue Aug 19, 2015 · 8 comments

Comments

@jpgilchrist
Copy link

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
Copy link
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
Copy link

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
Copy link
Owner

Can you post a jsFiddle demo?

@jwee6
Copy link

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
Copy link

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
Copy link

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

@jonthornton
Copy link
Owner

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

@pronexo-argentina
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants