Now.js Framework Documentation

Now.js Framework Documentation

TextareaElementFactory

EN 04 Sep 2026 01:40

TextareaElementFactory

TextareaElementFactory Builds <textarea> fields with optional auto-resize and a character counter. Always renders a real <textarea>, never <input type="textarea">.

Generated from source on 2026-08-21. Descriptions come from JSDoc in the file.
Re-run docs_scaffold when the code changes; hand edits are lost on regeneration

Source

  • File: Now/js/TextareaElementFactory.js (365 lines)
  • Form: ES class

Public methods (9)

static adjustHeight(element, config)

Resize a textarea to fit its content, within minRows/maxRows. Scroll position is captured and restored around the resize, since temporarily collapsing the height can otherwise jump the page.

static cleanup(instance)

Tear a textarea down: cancel any pending resize and restore its original styles.

static create(def)

Build a textarea from a field definition. Forces tagName/type to textarea regardless of what the definition says, so this factory never accidentally renders an input.

static extractCustomConfig(element, def, dataset)

Read the textarea options a single element declares. Covers data-auto-resize, data-min-rows, data-max-rows and data-char-count; anything absent falls back to def.

static setupAutoResize(instance)

Switch a textarea to grow with its content instead of being resizable. The original resize and overflow-y styles are stashed on the element so cleanup can restore them later.

static setupCounter(instance)

Add the character-count display below the textarea.

static setupElement(instance)

Prepare a textarea, clamping its size settings to sane values. minRows is at least 1, maxRows is at least minRows, and debounceDelay is at least 0 — any bad value from config or a data attribute is corrected rather than propagated.

static setupEventListeners(instance)

Bind the input handler that drives auto-resize and the counter. Resizing is debounced so a fast typist does not trigger a layout pass on every keystroke.

static updateCounters(instance)

Refresh the character counter to match the current value.

Data attributes used

data-auto-resize · data-char-count · data-enable-tab-indent · data-enter-behavior · data-word-count

Depends on

ElementManager · EventSystemManager · Utils