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

TypeError: maxLengthIndicator is undefined #48

Closed
dhardtke opened this issue Feb 27, 2014 · 9 comments
Closed

TypeError: maxLengthIndicator is undefined #48

dhardtke opened this issue Feb 27, 2014 · 9 comments

Comments

@dhardtke
Copy link

Sometimes I get this error and I have absolutely no clue where it is coming from.
I think it could have to do that some of my form fields are hidden, but I can not determine any pattern (I don't get it always on the same page and same code).

TypeError: maxLengthIndicator is undefined
outerWidth = maxLengthIndicator.outerWidth(),
@mimo84
Copy link
Owner

mimo84 commented Feb 27, 2014

I guess this happens if you apply this plugin to elements without the maxlength attribute defined. Can you please double check if the jQuery selector you use to apply the plugin doesn't selects inputs without the maxlength attribute?
Maybe should I raise an exception when this happens?

@dhardtke
Copy link
Author

....find("input[maxlength]").maxlength({ alwaysShow: true });

That's a part of my code, so I don't think the selector is wrong.

@mimo84
Copy link
Owner

mimo84 commented Feb 27, 2014

I see, I think what happens is that in the selection there are also hidden inputs.
If that is the case then change the selector to something like this:

$('input[maxlength]:not([type="hidden"])')

I will manage this in the internal selector of the plugin, to avoid the exception.

@dhardtke
Copy link
Author

But my input[type='hidden'] fields don't have the maxlength attribute, I don't think that's the reason for the error.

@mimo84
Copy link
Owner

mimo84 commented Mar 10, 2014

Can you please create a fiddle where to reproduce the issue?

@mimo84 mimo84 closed this as completed Mar 11, 2014
@dhardtke
Copy link
Author

Why did you close this issue?

I will try to create a fiddle which shows this problem as soon as possible, but I can not determine a pattern when this happens, it just happens sometimes and sometimes not..

@dhardtke
Copy link
Author

So I tried the un-minified version and I get an error at this line:

outerWidth = maxLengthIndicator.outerWidth(),

TypeError: maxLengthIndicator is undefined

EDIT:
Apparently, it happens if this code gets executed:

$("ul.treeview").find("input, select").attr("disabled", false);
$("ul.treeview[data-field-name]").remove();

@andreasanta
Copy link

Try putting your "maxlength()" call on $(window).load() and not on DOM Ready. Worked for me.

@enigmaticus
Copy link

have the same problem. By me it happens when I resize the window. Obviously not working so good with responsive layout. I solved it with updating to the new version 1.5.7. The problem was in 1.5.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

4 participants