ForgejComponent
en

jComponent 20 (frontend)

Components, plugins, data binding and everything that runs in the browser.

RecipeTags

Get started with jComponent 20

Load the jComponent bundle, set a value in the global state and show it with a ui-bind element.

jcomponentfrontendbinding

Read, change and watch the state

Use SET, GET, UPD, PUSH and WATCH to work with the global state and react when a path changes.

jcomponentfrontendstate

Write a custom jComponent

Register a reusable component with COMPONENT(), render it in make(), react to state changes in setter() and write back with set().

jcomponentfrontendcomponents

Configure a component and reconfigure it later

Give a component default options, override them in the config attribute, react in configure() and change them at runtime with reconfigure().

jcomponentfrontendcomponents

Component lifecycle: make, setter and destroy

Know when jComponent creates, updates and removes a component, and clean up timers and listeners in destroy().

jcomponentfrontendcomponents

Validate input with a component's validate()

Implement validate() in a component, read the invalid, touched and modified states, and find invalid fields with ERRORS().

jcomponentfrontendvalidationforms

Path prefixes: common, code lists, temporary state and plugin paths

The first character of a jComponent path chooses where the value lives: * the common state, # the code lists, % the temporary state, ? the plugin state and plugin|path a property of a plugin object.

jcomponentfrontendpathsstate

Load a library before a component starts

List scripts and styles as the dependencies of a component so jComponent downloads them once and starts the component afterwards.

jcomponentfrontendcomponentsdependencies

Extend components and plugins with EXTENSION

Add behavior to an existing component from outside, without editing its source, with EXTENSION().

jcomponentfrontendcomponents

Show, hide and style elements with ui-bind

Use ui-bind commands to toggle visibility, classes and HTML from the state, without writing DOM code.

jcomponentfrontendbinding

Render lists with a ui-bind template

Put a Tangular template inside ui-bind with the template command to render arrays and objects whenever the data changes.

jcomponentfrontendbindingtemplates

More ui-bind commands: attributes, values, state and formatting

Set HTML, attributes, form values, disabled state and a text format from the state with ui-bind commands.

jcomponentfrontendbinding

ui-bind reference: every command, option and attribute

All the commands of ui-bind with what each one does, the options that control when it runs, and the attributes that choose the target element.

jcomponentfrontendbindingreference

Component instance reference: properties and methods of self

The declaration of a jComponent 20 component and what its instance (self) offers: properties, value methods, DOM helpers, events, watchers and commands.

jcomponentfrontendcomponentsreference

Group state and logic in a jComponent plugin

Declare a plugin with PLUGIN() and attach it to a part of the page with ui-plugin, using ? as its own path.

jcomponentfrontendplugins

Route pages in the browser without reloading

Register client-side routes with ROUTE(), navigate with REDIRECT(), read the URL parameters and the query string from NAV, and go back in the history.

jcomponentfrontendroutingspa

Load parts of a page with ui-import

Fetch an HTML part from the server into an element with ui-import or IMPORT(), and let the part carry its own components.

jcomponentfrontendimport

Call code with commands and EXEC

Register commands with component.command() and call them with CMD(), or call a plugin method with EXEC('plugin/method').

jcomponentfrontendcommands

Send events between components with ON and EMIT

Decouple parts of the page with global events: EMIT() announces something, ON() listens, OFF() stops listening.

jcomponentfrontendevents

Store data in the browser with CACHE, PREF and COOKIES

Keep values between visits with CACHE (expiring), PREF (user preferences) and COOKIES.

jcomponentfrontendstorage

Share settings with ENV and the [key] syntax

Register values with ENV() and use them in URLs and component configuration with the [key] placeholder.

jcomponentfrontendconfig

Load data from a Total.js route with AJAX

Call a Total.js route from the page with AJAX() and put the response into the jComponent state.

jcomponentfrontendajaxrouting

Call Total.js API routes with API()

Use API(url, name, data, callback) to call the actions of a ROUTE('API ...') endpoint, validation errors included.

jcomponentfrontendajaxapi

Upload files with UPLOAD() and progress

Send a FormData to a Total.js @upload route with UPLOAD() and follow the progress.

jcomponentfrontenduploadfiles

Small helpers: GUID, HASH, parseConfig, format and group

Use the helper functions that jComponent adds: random ids, hashes, config strings, string and date formatting and grouping.

jcomponentfrontendutilities

State shortcuts: INC, TOGGLE, NUL, UPDATE, UNWATCH, WAIT, BLOCKED and CACHEPATH

Small functions that change or watch a value of the state by its path, wait until a value exists, run something only once in a period and keep a value of the state in the cache.

jcomponentfrontendstateutilities

Data helpers: QUERIFY, STRINGIFY, ENCRYPT, FN, CL, TRANSLATE, UNAUTHORIZED and Thelpers

Build query strings, write JSON without what you do not want, encode a value with a key, compile an expression, load lists of values, translate texts, check permissions and add helpers to the templates.

jcomponentfrontendutilitiestemplates

DOM helpers: ATTRD, HIDDEN, VISIBLE, WIDTH, STYLE, NODEMOVE, DIFFDOM and APPEARANCE

Read data attributes, ask if an element is shown or on the screen, add styles that you can replace, move elements in their parent, update a list without redrawing it, and set the colors and the dark mode of the page.

jcomponentfrontenddomutilities

Find and call components and plugins: FIND, COMPONENTS, SETTER, EXE, TAPI, MIDDLEWARE and ADAPT

Look for the components of the page by name or path, call a method of several components at once, call functions by name, use two API addresses with TAPI and PIPE, run middleware before a route and replace the markers of a text.

jcomponentfrontendcomponentsapi

Dispatch custom path flags with FLAGS

Execute custom flags, observe their events and distinguish them from model changes and reserved state flags.

jcomponentflagseventspaths