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

Suggestion: Handle data length reductions #16

Closed
scoman81 opened this issue Feb 20, 2014 · 5 comments
Closed

Suggestion: Handle data length reductions #16

scoman81 opened this issue Feb 20, 2014 · 5 comments
Assignees
Milestone

Comments

@scoman81
Copy link

There are two common cases (actually two derivatives of the same case, that just feel different) that would be nice to see handled by this plugin:

  1. Full erase. Type some data, Shift+Home, Backspace. This case is when you've typed and then erased everything. The callback doesn't fire, and thus you can't restore state. (I'm using this to trigger a filter on a table of data, and a full erase should restore all data).
  2. with captureLength set to 3, type 3 chars, let event fire, then backspace. This case should also be able to let the user restore default state, since 2 characters are considered the same as no characters, but the callback won't fire because the input has only 2 characters.

These are really both the same case: when the data length decreases from over the captureLength setting, to under the captureLength setting.

@scoman81
Copy link
Author

Adding a 2nd OR clause covers the above cases:
if ((value.length >= options.captureLength && value.toUpperCase() != timer.text)
|| (override && value.length >= options.captureLength)
|| (value.length < options.captureLength && timer.text.length >= options.captureLength))

(Sorry, new to Git, so I apologize if there was some other way I was supposed to submit a suggestion!)

@EdwinOtten
Copy link

Thanks, this really helped me!

For others:
Replace line line 33/34 with scoman81's code:

if ((value.length >= options.captureLength && value.toUpperCase() != timer.text)
|| (override && value.length >= options.captureLength)
|| (value.length < options.captureLength && timer.text.length >= options.captureLength))

Also, you probably want to set captureLength: 1 to make it trigger when you delete the last character from the textarea.

@dennyferra
Copy link
Owner

_scoman81_ Thank you for describing the issue. I've had a few other requests for this fix but they always seemed to describe the issue in a manner that made me think they should just set the _captureLength_ to 1. With your description I was finally able to understand the issue. I'll get your fix in shortly. Thanks.

@dennyferra dennyferra self-assigned this Mar 17, 2014
@dennyferra dennyferra added this to the Version 2.3 milestone Mar 17, 2014
@kashifshamaz21
Copy link

+1 for this important fix.

@szepeviktor
Copy link

This line makes the empty state work.

|| (value.length === 0 && timer.text.length > 0)

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

5 participants