Materialize: characterCounter is not a function

Created on 8 Mar 2018  路  2Comments  路  Source: Dogfalo/materialize

Current Behavior

VM3795:1 Uncaught TypeError: $(...).characterCounter is not a function
    at <anonymous>:1:37

Your Environment

  • Version used: 1.0.0-alpha.4

Most helpful comment

Hi @acburst,

I think the docs are not up-to-date with the character counter.
The only code sample provided is using jQuery.

Could you please update the docs accordingly?
http://next.materializecss.com/text-inputs.html#character-counter

I got it working after checking the JS code with the new M.CharacterCounter.init() function.
Is this necessary? If I am not mistaken, in versions prior to 1.0 the character counter was initialized automatically if the data-length attribute was present on the input.

M.CharacterCounter.init(document.querySelectorAll('.has-character-counter'));

All 2 comments

Can you make a codepen? I can't help without seeing any code.

Hi @acburst,

I think the docs are not up-to-date with the character counter.
The only code sample provided is using jQuery.

Could you please update the docs accordingly?
http://next.materializecss.com/text-inputs.html#character-counter

I got it working after checking the JS code with the new M.CharacterCounter.init() function.
Is this necessary? If I am not mistaken, in versions prior to 1.0 the character counter was initialized automatically if the data-length attribute was present on the input.

M.CharacterCounter.init(document.querySelectorAll('.has-character-counter'));

Was this page helpful?
0 / 5 - 0 ratings