{"id":"JamcNU1sd61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/introduction/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Introduction","summary":"What jComponent is, the ideas it is built on and what the library includes.","markdown":"---\ntitle: Introduction\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/introduction/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# Introduction\n\n> What jComponent is, the ideas it is built on and what the library includes.\n\njComponent is the client-side UI library of Total.js. You keep the data of your application in plain JavaScript objects, address that data with string paths and connect it to the page with custom HTML elements. When a value changes through the library, every element that depends on it updates itself.\n\nThere is no build step. A page needs one script and one stylesheet.\n\n## A first look\n\n```html\n<p>Hello <ui-bind path=\"common.user\" config=\"text\"></ui-bind></p>\n```\n\n```js\nSET('common.user', 'Ana');\n\n// Later, from any place in your code:\nsetTimeout(function() {\n\tSET('common.user', 'Peter');\n}, 500);\n```\n\nThe page shows `Hello Ana` and, half a second later, `Hello Peter`. The code never touches the DOM: it writes a value to the path `common.user`, and the `<ui-bind>` element that listens to this path renders it.\n\n## The building blocks\n\n| Concept | What it does | Guide |\n| --- | --- | --- |\n| Path | A string such as `app.user.name` that addresses a value in the global `window` object | [Paths](../paths/) |\n| Flag | A word such as `@change` added to a path that changes how an operation behaves | [Flags and path modifiers](../flags/) |\n| `<ui-bind>` | An element that renders a value of the model into the page | [Data binding](../data-binding/) |\n| Component | A reusable widget that reads a value from a path and can write it back | [Using components](../using-components/), [Creating components](../creating-components/) |\n| Plugin | A block of application logic with its own part of the model | [Plugins](../plugins/) |\n\n## How data flows\n\n1. Your code calls `SET()`, or a component writes a value that the user entered.\n2. The library stores the value at the path, inside a normal JavaScript object.\n3. The library notifies everything that depends on the path: components, `<ui-bind>` elements and watchers registered with `WATCH()`.\n4. Each of them updates its own part of the page.\n\nBecause the model is a plain object, you can read it at any time, for example `app.user.name` in the browser console.\n\n## What the library includes\n\nThe file `spa.min@20.js` is a single bundle with everything a page needs:\n\n- jComponent itself\n- jQuery 3.7.1, available as `$`\n- [Tangular](../tangular/), the template engine\n- [Routing](../routing/) for single-page applications, with `ROUTE()`, `REDIRECT()` and `NAV`\n\nThe file `spa.min@20.css` contains a CSS reset, a responsive grid and helper classes such as `hidden` and `invisible`.\n\n## Where to go next\n\nFollow [Getting started](../getting-started/) to build a working page with a custom component and bound data. All functions are listed in the [global functions](../../reference/globals/) reference.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcNU1sd61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/introduction/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Einführung","summary":"Was jComponent ist, auf welchen Ideen es aufbaut und was die Bibliothek enthält.","markdown":"---\ntitle: \"Einführung\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/introduction/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# Einführung\n\n> Was jComponent ist, auf welchen Ideen es aufbaut und was die Bibliothek enthält.\n\njComponent ist die clientseitige UI-Bibliothek von Total.js. Du hältst die Daten deiner Anwendung in einfachen JavaScript-Objekten, sprichst sie über Paths in Form von Strings an und verbindest sie mit eigenen HTML-Elementen mit der Seite. Ändert sich ein Wert über die Bibliothek, aktualisiert sich jedes Element, das von ihm abhängt, von selbst.\n\nEs gibt keinen Build-Schritt. Eine Seite braucht nur ein Skript und ein Stylesheet.\n\n## Ein erster Blick\n\n```html\n<p>Hello <ui-bind path=\"common.user\" config=\"text\"></ui-bind></p>\n```\n\n```js\nSET('common.user', 'Ana');\n\n// Later, from any place in your code:\nsetTimeout(function() {\n\tSET('common.user', 'Peter');\n}, 500);\n```\n\nDie Seite zeigt `Hello Ana` und eine halbe Sekunde später `Hello Peter`. Der Code greift nie auf das DOM zu: Er schreibt einen Wert in den Path `common.user`, und das Element `<ui-bind>`, das auf diesen Path hört, stellt ihn dar.\n\n## Die Bausteine\n\n| Konzept | Was es macht | Anleitung |\n| --- | --- | --- |\n| Path | Ein String wie `app.user.name`, der einen Wert im globalen Objekt `window` adressiert | [Paths](../paths/) |\n| Flag | Ein Wort wie `@change`, das an einen Path angehängt wird und das Verhalten einer Operation ändert | [Flags und Path-Modifikatoren](../flags/) |\n| `<ui-bind>` | Ein Element, das einen Wert des Modells in der Seite darstellt | [Datenbindung](../data-binding/) |\n| Komponente | Ein wiederverwendbares Widget, das einen Wert aus einem Path liest und ihn zurückschreiben kann | [Komponenten verwenden](../using-components/), [Komponenten erstellen](../creating-components/) |\n| Plugin | Ein Block Anwendungslogik mit einem eigenen Teil des Modells | [Plugins](../plugins/) |\n\n## Wie die Daten fließen\n\n1. Dein Code ruft `SET()` auf, oder eine Komponente schreibt einen Wert, den der Benutzer eingegeben hat.\n2. Die Bibliothek speichert den Wert am Path in einem normalen JavaScript-Objekt.\n3. Die Bibliothek benachrichtigt alles, was vom Path abhängt: Komponenten, `<ui-bind>`-Elemente und mit `WATCH()` registrierte Watcher.\n4. Jeder davon aktualisiert seinen eigenen Teil der Seite.\n\nDa das Modell ein einfaches Objekt ist, kannst du es jederzeit lesen, zum Beispiel `app.user.name` in der Browserkonsole.\n\n## Was die Bibliothek enthält\n\nDie Datei `spa.min@20.js` ist ein einzelnes Bundle mit allem, was eine Seite braucht:\n\n- jComponent selbst\n- jQuery 3.7.1, verfügbar als `$`\n- [Tangular](../tangular/), die Template-Engine\n- [Routing](../routing/) für Single-Page-Anwendungen, mit `ROUTE()`, `REDIRECT()` und `NAV`\n\nDie Datei `spa.min@20.css` enthält einen CSS-Reset, ein responsives Raster und Hilfsklassen wie `hidden` und `invisible`.\n\n## Wie es weitergeht\n\nFolge den [ersten Schritten](../getting-started/), um eine funktionierende Seite mit einer eigenen Komponente und gebundenen Daten zu bauen. Alle Funktionen findest du in der Referenz der [globalen Funktionen](../../reference/globals/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcNU1sd61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/introduction/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Introducción","summary":"Qué es jComponent, en qué ideas se basa y qué incluye la biblioteca.","markdown":"---\ntitle: \"Introducción\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/introduction/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# Introducción\n\n> Qué es jComponent, en qué ideas se basa y qué incluye la biblioteca.\n\njComponent es la biblioteca de interfaz de cliente de Total.js. Guardas los datos de tu aplicación en objetos JavaScript normales, accedes a ellos con paths en forma de cadena y los conectas a la página con elementos HTML personalizados. Cuando un valor cambia a través de la biblioteca, todos los elementos que dependen de él se actualizan solos.\n\nNo hay ningún paso de compilación. Una página solo necesita un script y una hoja de estilos.\n\n## Un primer vistazo\n\n```html\n<p>Hello <ui-bind path=\"common.user\" config=\"text\"></ui-bind></p>\n```\n\n```js\nSET('common.user', 'Ana');\n\n// Later, from any place in your code:\nsetTimeout(function() {\n\tSET('common.user', 'Peter');\n}, 500);\n```\n\nLa página muestra `Hello Ana` y, medio segundo después, `Hello Peter`. El código nunca toca el DOM: escribe un valor en el path `common.user`, y el elemento `<ui-bind>` que escucha ese path lo renderiza.\n\n## Las piezas básicas\n\n| Concepto | Qué hace | Guía |\n| --- | --- | --- |\n| Path | Una cadena como `app.user.name` que apunta a un valor del objeto global `window` | [Paths](../paths/) |\n| Flag | Una palabra como `@change` que se añade a un path y cambia el comportamiento de una operación | [Flags y modificadores de path](../flags/) |\n| `<ui-bind>` | Un elemento que renderiza en la página un valor del modelo | [Enlace de datos](../data-binding/) |\n| Componente | Un widget reutilizable que lee un valor de un path y puede volver a escribirlo | [Usar componentes](../using-components/), [Crear componentes](../creating-components/) |\n| Plugin | Un bloque de lógica de la aplicación con su propia parte del modelo | [Plugins](../plugins/) |\n\n## Cómo fluyen los datos\n\n1. Tu código llama a `SET()`, o un componente escribe un valor que ha introducido el usuario.\n2. La biblioteca guarda el valor en el path, dentro de un objeto JavaScript normal.\n3. La biblioteca avisa a todo lo que depende del path: componentes, elementos `<ui-bind>` y observadores registrados con `WATCH()`.\n4. Cada uno de ellos actualiza su propia parte de la página.\n\nComo el modelo es un objeto normal, puedes leerlo en cualquier momento, por ejemplo `app.user.name` en la consola del navegador.\n\n## Qué incluye la biblioteca\n\nEl archivo `spa.min@20.js` es un único paquete con todo lo que necesita una página:\n\n- El propio jComponent\n- jQuery 3.7.1, disponible como `$`\n- [Tangular](../tangular/), el motor de plantillas\n- [Enrutamiento](../routing/) para aplicaciones de una sola página, con `ROUTE()`, `REDIRECT()` y `NAV`\n\nEl archivo `spa.min@20.css` contiene un reset de CSS, una rejilla adaptable y clases auxiliares como `hidden` e `invisible`.\n\n## Por dónde seguir\n\nSigue [Primeros pasos](../getting-started/) para crear una página funcional con un componente personalizado y datos enlazados. Todas las funciones aparecen en la referencia de [funciones globales](../../reference/globals/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcNU1sd61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/introduction/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Introduction","summary":"Ce qu'est jComponent, les idées sur lesquelles il repose et ce que contient la bibliothèque.","markdown":"---\ntitle: Introduction\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/introduction/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# Introduction\n\n> Ce qu'est jComponent, les idées sur lesquelles il repose et ce que contient la bibliothèque.\n\njComponent est la bibliothèque d'interface côté client de Total.js. Tu gardes les données de ton application dans de simples objets JavaScript, tu y accèdes avec des paths sous forme de chaînes et tu les relies à la page avec des éléments HTML personnalisés. Quand une valeur change par l'intermédiaire de la bibliothèque, chaque élément qui en dépend se met à jour tout seul.\n\nIl n'y a aucune étape de build. Une page a besoin d'un seul script et d'une seule feuille de style.\n\n## Un premier aperçu\n\n```html\n<p>Hello <ui-bind path=\"common.user\" config=\"text\"></ui-bind></p>\n```\n\n```js\nSET('common.user', 'Ana');\n\n// Later, from any place in your code:\nsetTimeout(function() {\n\tSET('common.user', 'Peter');\n}, 500);\n```\n\nLa page affiche `Hello Ana` puis, une demi-seconde plus tard, `Hello Peter`. Le code ne touche jamais au DOM : il écrit une valeur dans le path `common.user`, et l'élément `<ui-bind>` qui écoute ce path l'affiche.\n\n## Les briques de base\n\n| Concept | Ce qu'il fait | Guide |\n| --- | --- | --- |\n| Path | Une chaîne comme `app.user.name` qui désigne une valeur dans l'objet global `window` | [Paths](../paths/) |\n| Flag | Un mot comme `@change` ajouté à un path, qui modifie le comportement d'une opération | [Flags et modificateurs de path](../flags/) |\n| `<ui-bind>` | Un élément qui affiche dans la page une valeur du modèle de données | [Liaison de données](../data-binding/) |\n| Composant | Un widget réutilisable qui lit une valeur depuis un path et peut l'y réécrire | [Utiliser les composants](../using-components/), [Créer des composants](../creating-components/) |\n| Plugin | Un bloc de logique applicative avec sa propre partie du modèle de données | [Plugins](../plugins/) |\n\n## Comment circulent les données\n\n1. Ton code appelle `SET()`, ou un composant écrit une valeur saisie par l'utilisateur.\n2. La bibliothèque stocke la valeur au niveau du path, dans un objet JavaScript normal.\n3. La bibliothèque prévient tout ce qui dépend du path : les composants, les éléments `<ui-bind>` et les observateurs enregistrés avec `WATCH()`.\n4. Chacun d'eux met à jour sa propre partie de la page.\n\nComme le modèle de données est un simple objet, tu peux le lire à tout moment, par exemple `app.user.name` dans la console du navigateur.\n\n## Ce que contient la bibliothèque\n\nLe fichier `spa.min@20.js` est un bundle unique qui regroupe tout ce dont une page a besoin :\n\n- jComponent lui-même\n- jQuery 3.7.1, disponible sous le nom `$`\n- [Tangular](../tangular/), le moteur de modèles\n- [Le routage](../routing/) pour les applications monopages, avec `ROUTE()`, `REDIRECT()` et `NAV`\n\nLe fichier `spa.min@20.css` contient une réinitialisation CSS, une grille responsive et des classes helper comme `hidden` et `invisible`.\n\n## Pour continuer\n\nSuis [Premiers pas](../getting-started/) pour construire une page fonctionnelle avec un composant personnalisé et des données liées. Toutes les fonctions sont répertoriées dans la référence des [fonctions globales](../../reference/globals/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcNU1sd61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/introduction/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Introduzione","summary":"Che cos'è jComponent, le idee su cui si basa e che cosa include la libreria.","markdown":"---\ntitle: Introduzione\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/introduction/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# Introduzione\n\n> Che cos'è jComponent, le idee su cui si basa e che cosa include la libreria.\n\njComponent è la libreria UI lato client di Total.js. Conservi i dati della tua applicazione in semplici oggetti JavaScript, li indirizzi con path sotto forma di stringa e li colleghi alla pagina con elementi HTML personalizzati. Quando un valore cambia tramite la libreria, ogni elemento che ne dipende si aggiorna da solo.\n\nNon serve alcuna fase di build. A una pagina bastano uno script e un foglio di stile.\n\n## Un primo sguardo\n\n```html\n<p>Hello <ui-bind path=\"common.user\" config=\"text\"></ui-bind></p>\n```\n\n```js\nSET('common.user', 'Ana');\n\n// Later, from any place in your code:\nsetTimeout(function() {\n\tSET('common.user', 'Peter');\n}, 500);\n```\n\nLa pagina mostra `Hello Ana` e, mezzo secondo dopo, `Hello Peter`. Il codice non tocca mai il DOM: scrive un valore nel path `common.user` e l'elemento `<ui-bind>` in ascolto su questo path lo visualizza.\n\n## Gli elementi fondamentali\n\n| Concetto | Che cosa fa | Guida |\n| --- | --- | --- |\n| Path | Una stringa come `app.user.name` che indirizza un valore nell'oggetto globale `window` | [Path](../paths/) |\n| Flag | Una parola come `@change` aggiunta a un path che cambia il comportamento di un'operazione | [Flag e modificatori di path](../flags/) |\n| `<ui-bind>` | Un elemento che visualizza nella pagina un valore del modello | [Associazione dei dati](../data-binding/) |\n| Componente | Un widget riutilizzabile che legge un valore da un path e può riscriverlo | [Usare i componenti](../using-components/), [Creare componenti](../creating-components/) |\n| Plugin | Un blocco di logica applicativa con una propria parte del modello | [Plugin](../plugins/) |\n\n## Come scorrono i dati\n\n1. Il tuo codice chiama `SET()`, oppure un componente scrive un valore inserito dall'utente.\n2. La libreria salva il valore nel path, all'interno di un normale oggetto JavaScript.\n3. La libreria avvisa tutto ciò che dipende dal path: componenti, elementi `<ui-bind>` e osservatori registrati con `WATCH()`.\n4. Ognuno di questi aggiorna la propria parte della pagina.\n\nPoiché il modello è un semplice oggetto, puoi leggerlo in qualsiasi momento, ad esempio `app.user.name` nella console del browser.\n\n## Che cosa include la libreria\n\nIl file `spa.min@20.js` è un unico bundle con tutto ciò che serve a una pagina:\n\n- jComponent stesso\n- jQuery 3.7.1, disponibile come `$`\n- [Tangular](../tangular/), il motore di template\n- Il [routing](../routing/) per le applicazioni a pagina singola, con `ROUTE()`, `REDIRECT()` e `NAV`\n\nIl file `spa.min@20.css` contiene un reset CSS, una griglia responsive e classi di utilità come `hidden` e `invisible`.\n\n## Come proseguire\n\nSegui [Primi passi](../getting-started/) per creare una pagina funzionante con un componente personalizzato e dati associati. Tutte le funzioni sono elencate nel riferimento delle [funzioni globali](../../reference/globals/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcNU1sd61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/introduction/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Úvod","summary":"Čo je jComponent, na akých myšlienkach stojí a čo knižnica obsahuje.","markdown":"---\ntitle: \"Úvod\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/introduction/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# Úvod\n\n> Čo je jComponent, na akých myšlienkach stojí a čo knižnica obsahuje.\n\njComponent je klientska UI knižnica Total.js. Dáta svojej aplikácie držíš v obyčajných JavaScriptových objektoch, odkazuješ na ne textovými path a so stránkou ich prepájaš vlastnými HTML elementmi. Keď sa hodnota zmení prostredníctvom knižnice, každý element, ktorý od nej závisí, sa sám aktualizuje.\n\nNepotrebuješ žiadne zostavovanie. Stránke stačí jeden skript a jeden štýl.\n\n## Prvý pohľad\n\n```html\n<p>Hello <ui-bind path=\"common.user\" config=\"text\"></ui-bind></p>\n```\n\n```js\nSET('common.user', 'Ana');\n\n// Later, from any place in your code:\nsetTimeout(function() {\n\tSET('common.user', 'Peter');\n}, 500);\n```\n\nStránka zobrazí `Hello Ana` a o pol sekundy neskôr `Hello Peter`. Kód sa vôbec nedotýka DOM: zapíše hodnotu do path `common.user` a element `<ui-bind>`, ktorý túto path počúva, ju vykreslí.\n\n## Stavebné prvky\n\n| Pojem | Čo robí | Príručka |\n| --- | --- | --- |\n| Path | Reťazec ako `app.user.name`, ktorý odkazuje na hodnotu v globálnom objekte `window` | [Paths](../paths/) |\n| Flag | Slovo ako `@change` pridané k path, ktoré mení správanie operácie | [Flagy a modifikátory path](../flags/) |\n| `<ui-bind>` | Element, ktorý vykreslí hodnotu z modelu do stránky | [Dátová väzba](../data-binding/) |\n| Komponent | Opakovane použiteľný widget, ktorý číta hodnotu z path a môže ju tam zapísať späť | [Používanie komponentov](../using-components/), [Vytváranie komponentov](../creating-components/) |\n| Plugin | Blok aplikačnej logiky s vlastnou časťou modelu | [Pluginy](../plugins/) |\n\n## Ako tečú dáta\n\n1. Tvoj kód zavolá `SET()` alebo komponent zapíše hodnotu, ktorú zadal používateľ.\n2. Knižnica uloží hodnotu na danú path do bežného JavaScriptového objektu.\n3. Knižnica upozorní všetko, čo od tejto path závisí: komponenty, elementy `<ui-bind>` a sledovače zaregistrované cez `WATCH()`.\n4. Každý z nich aktualizuje svoju časť stránky.\n\nKeďže model je obyčajný objekt, môžeš ho kedykoľvek prečítať, napríklad `app.user.name` v konzole prehliadača.\n\n## Čo knižnica obsahuje\n\nSúbor `spa.min@20.js` je jeden balík so všetkým, čo stránka potrebuje:\n\n- samotný jComponent\n- jQuery 3.7.1, dostupné ako `$`\n- [Tangular](../tangular/), šablónovací nástroj\n- [Smerovanie](../routing/) pre jednostránkové aplikácie s `ROUTE()`, `REDIRECT()` a `NAV`\n\nSúbor `spa.min@20.css` obsahuje reset CSS, responzívnu mriežku a helper triedy ako `hidden` a `invisible`.\n\n## Kam ďalej\n\nPodľa návodu [Začíname](../getting-started/) si postav funkčnú stránku s vlastným komponentom a naviazanými dátami. Všetky funkcie nájdeš v referencii [globálnych funkcií](../../reference/globals/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcNO1od61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/getting-started/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Getting started","summary":"Build a working page with bound data and a custom component, starting from an empty file.","markdown":"---\ntitle: Getting started\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/getting-started/\nupdated: 2026-11-18T18:15:21.747Z\n---\n\n# Getting started\n\n> Build a working page with bound data and a custom component, starting from an empty file.\n\nThis guide takes you from an empty file to a working page with a custom input component and data bound to it. You need a text editor and a browser.\n\n## Create the page\n\nCreate a file named `index.html` and load the library from the CDN:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n</body>\n</html>\n```\n\nAll the following code goes inside `<body>`. Open the file directly in the browser to see the result.\n\n## Show a value\n\nWrite a value to the model with `SET()` and display it with a `<ui-bind>` element:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('app.name', 'Ana');\n</script>\n```\n\nThe page shows `Hello Ana`.\n\n- `SET('app.name', 'Ana')` creates the global object `app` and stores the value in `app.name`.\n- `path` tells `<ui-bind>` which value to listen to.\n- `config=\"text\"` tells it to render the value as text.\n\nEvery later `SET('app.name', ...)` updates the heading. Read more in [Paths](../paths/) and [Data binding](../data-binding/).\n\n## Create a component\n\nA component is a reusable widget. Declare it once with `COMPONENT()` and place it on the page with `<ui-component>`. Replace the content of `<body>` with this code:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<script>\nCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.html('<label></label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.configure = function(key, value) {\n\t\tif (key === 'label')\n\t\t\tself.find('label').text(value);\n\t};\n\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n\n}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\nSET('app.name', 'Ana');\n</script>\n```\n\nType into the field and the heading follows your text. Clear the field and the heading shows `Hello stranger`, because `empty:stranger` in the `<ui-bind>` configuration sets the text for an empty value.\n\nHere is what each part of the declaration does:\n\n| Code | Purpose |\n| --- | --- |\n| `'textbox'` | The name used in `<ui-component name=\"textbox\">` |\n| `'label:Name'` | The default configuration, which the `config` attribute can override |\n| `self.make` | Runs once for each instance and creates its HTML |\n| `self.aclass(cls)` | Adds the CSS class `ui-textbox` to the element |\n| `self.autobind20()` | Writes the content of the input to the model while the user types |\n| `self.configure` | Runs for each configuration key |\n| `self.validate` | Says if the current value is valid. The library then adds or removes the class `ui-invalid` |\n| The last argument | CSS of the component, where `CLASS` stands for `ui-textbox` |\n\nThe component does not define how to show the value in the input. When a component has no `setter` of its own, the library writes the value into the first `input`, `select` or `textarea` inside the component.\n\n## Run code from a button\n\nElements with the class `exec` call the function named in their `data-exec` attribute when they are clicked. Add a button that clears the model:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n```\n\nThen add the function to the script, above the `SET()` call:\n\n```js\nFUNC.clear = function() {\n\tSET('app.name', '');\n};\n```\n\n`FUNC` is an empty global object meant for your own functions. The click changes only the model. The input, the heading and the validation state all follow.\n\n## The complete page\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n\t<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n\t<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n\t<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n\n\t<script>\n\t\tCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\t\t\tself.make = function() {\n\t\t\t\tself.aclass(cls);\n\t\t\t\tself.html('<label></label><input type=\"text\" />');\n\t\t\t\tself.autobind20();\n\t\t\t};\n\n\t\t\tself.configure = function(key, value) {\n\t\t\t\tif (key === 'label')\n\t\t\t\t\tself.find('label').text(value);\n\t\t\t};\n\n\t\t\tself.validate = function(value) {\n\t\t\t\treturn !config.required || !!value;\n\t\t\t};\n\n\t\t}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\n\t\tFUNC.clear = function() {\n\t\t\tSET('app.name', '');\n\t\t};\n\n\t\tSET('app.name', 'Ana');\n\t</script>\n\n</body>\n</html>\n```\n\n## If something does not work\n\n- **The component stays empty.** Check that the `name` attribute matches the name in `COMPONENT()`. For an unknown name, the library tries to download the component from the CDN and writes `jComponent: Downloading \"name\" component.` to the console.\n- **The value does not change on the page.** Change the model with `SET()`. A direct assignment such as `app.name = 'Ana'` does not notify anybody until you call `UPD('app.name')`.\n\n## Next steps\n\n- [Paths](../paths/) explains how to address and change data.\n- [Data binding](../data-binding/) shows everything `<ui-bind>` can do.\n- [Creating components](../creating-components/) covers the whole component API.\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:21.747Z"}
{"id":"JamcNO1od61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/getting-started/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Erste Schritte","summary":"Baue ausgehend von einer leeren Datei eine funktionierende Seite mit gebundenen Daten und einer eigenen Komponente.","markdown":"---\ntitle: Erste Schritte\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/getting-started/\nupdated: 2026-11-18T18:15:21.747Z\n---\n\n# Erste Schritte\n\n> Baue ausgehend von einer leeren Datei eine funktionierende Seite mit gebundenen Daten und einer eigenen Komponente.\n\nDiese Anleitung führt dich von einer leeren Datei zu einer funktionierenden Seite mit einer eigenen Eingabekomponente und daran gebundenen Daten. Du brauchst einen Texteditor und einen Browser.\n\n## Die Seite anlegen\n\nLege eine Datei namens `index.html` an und lade die Bibliothek aus dem CDN:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n</body>\n</html>\n```\n\nDer gesamte folgende Code kommt in den `<body>`. Öffne die Datei direkt im Browser, um das Ergebnis zu sehen.\n\n## Einen Wert anzeigen\n\nSchreibe mit `SET()` einen Wert in das Modell und zeige ihn mit einem `<ui-bind>`-Element an:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('app.name', 'Ana');\n</script>\n```\n\nDie Seite zeigt `Hello Ana`.\n\n- `SET('app.name', 'Ana')` erstellt das globale Objekt `app` und speichert den Wert in `app.name`.\n- `path` sagt `<ui-bind>`, auf welchen Wert es hören soll.\n- `config=\"text\"` sagt ihm, dass es den Wert als Text darstellen soll.\n\nJedes spätere `SET('app.name', ...)` aktualisiert die Überschrift. Mehr dazu findest du unter [Paths](../paths/) und [Datenbindung](../data-binding/).\n\n## Eine Komponente erstellen\n\nEine Komponente ist ein wiederverwendbares Widget. Du deklarierst sie einmal mit `COMPONENT()` und platzierst sie mit `<ui-component>` auf der Seite. Ersetze den Inhalt von `<body>` durch diesen Code:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<script>\nCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.html('<label></label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.configure = function(key, value) {\n\t\tif (key === 'label')\n\t\t\tself.find('label').text(value);\n\t};\n\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n\n}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\nSET('app.name', 'Ana');\n</script>\n```\n\nTippe in das Feld, und die Überschrift folgt deinem Text. Leerst du das Feld, zeigt die Überschrift `Hello stranger`, denn `empty:stranger` in der Konfiguration von `<ui-bind>` legt den Text für einen leeren Wert fest.\n\nDas macht jeder Teil der Deklaration:\n\n| Code | Zweck |\n| --- | --- |\n| `'textbox'` | Der Name, der in `<ui-component name=\"textbox\">` verwendet wird |\n| `'label:Name'` | Die Standardkonfiguration, die das Attribut `config` überschreiben kann |\n| `self.make` | Läuft einmal pro Instanz und erzeugt deren HTML |\n| `self.aclass(cls)` | Fügt dem Element die CSS-Klasse `ui-textbox` hinzu |\n| `self.autobind20()` | Schreibt den Inhalt des Eingabefelds in das Modell, während der Benutzer tippt |\n| `self.configure` | Läuft für jeden Konfigurationsschlüssel |\n| `self.validate` | Gibt an, ob der aktuelle Wert gültig ist. Die Bibliothek fügt dann die Klasse `ui-invalid` hinzu oder entfernt sie |\n| Das letzte Argument | CSS der Komponente, wobei `CLASS` für `ui-textbox` steht |\n\nDie Komponente legt nicht fest, wie der Wert im Eingabefeld angezeigt wird. Hat eine Komponente keinen eigenen `setter`, schreibt die Bibliothek den Wert in das erste `input`, `select` oder `textarea` innerhalb der Komponente.\n\n## Code über einen Button ausführen\n\nElemente mit der Klasse `exec` rufen beim Klick die Funktion auf, die in ihrem Attribut `data-exec` genannt ist. Füge einen Button hinzu, der das Modell leert:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n```\n\nErgänze dann die Funktion im Skript oberhalb des Aufrufs von `SET()`:\n\n```js\nFUNC.clear = function() {\n\tSET('app.name', '');\n};\n```\n\n`FUNC` ist ein leeres globales Objekt für deine eigenen Funktionen. Der Klick ändert nur das Modell. Eingabefeld, Überschrift und Validierungszustand folgen von selbst.\n\n## Die vollständige Seite\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n\t<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n\t<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n\t<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n\n\t<script>\n\t\tCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\t\t\tself.make = function() {\n\t\t\t\tself.aclass(cls);\n\t\t\t\tself.html('<label></label><input type=\"text\" />');\n\t\t\t\tself.autobind20();\n\t\t\t};\n\n\t\t\tself.configure = function(key, value) {\n\t\t\t\tif (key === 'label')\n\t\t\t\t\tself.find('label').text(value);\n\t\t\t};\n\n\t\t\tself.validate = function(value) {\n\t\t\t\treturn !config.required || !!value;\n\t\t\t};\n\n\t\t}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\n\t\tFUNC.clear = function() {\n\t\t\tSET('app.name', '');\n\t\t};\n\n\t\tSET('app.name', 'Ana');\n\t</script>\n\n</body>\n</html>\n```\n\n## Wenn etwas nicht funktioniert\n\n- **Die Komponente bleibt leer.** Prüfe, ob das Attribut `name` mit dem Namen in `COMPONENT()` übereinstimmt. Bei einem unbekannten Namen versucht die Bibliothek, die Komponente aus dem CDN herunterzuladen, und schreibt `jComponent: Downloading \"name\" component.` in die Konsole.\n- **Der Wert ändert sich auf der Seite nicht.** Ändere das Modell mit `SET()`. Eine direkte Zuweisung wie `app.name = 'Ana'` benachrichtigt niemanden, bis du `UPD('app.name')` aufrufst.\n\n## Nächste Schritte\n\n- [Paths](../paths/) erklärt, wie du Daten adressierst und änderst.\n- [Datenbindung](../data-binding/) zeigt alles, was `<ui-bind>` kann.\n- [Komponenten erstellen](../creating-components/) behandelt die gesamte API der Komponenten.\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:21.747Z"}
{"id":"JamcNO1od61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/getting-started/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Primeros pasos","summary":"Crea una página funcional con datos enlazados y un componente personalizado, partiendo de un archivo vacío.","markdown":"---\ntitle: Primeros pasos\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/getting-started/\nupdated: 2026-11-18T18:15:21.747Z\n---\n\n# Primeros pasos\n\n> Crea una página funcional con datos enlazados y un componente personalizado, partiendo de un archivo vacío.\n\nEsta guía te lleva de un archivo vacío a una página funcional con un componente de entrada personalizado y datos enlazados a él. Necesitas un editor de texto y un navegador.\n\n## Crea la página\n\nCrea un archivo llamado `index.html` y carga la biblioteca desde el CDN:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n</body>\n</html>\n```\n\nTodo el código que sigue va dentro de `<body>`. Abre el archivo directamente en el navegador para ver el resultado.\n\n## Muestra un valor\n\nEscribe un valor en el modelo con `SET()` y muéstralo con un elemento `<ui-bind>`:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('app.name', 'Ana');\n</script>\n```\n\nLa página muestra `Hello Ana`.\n\n- `SET('app.name', 'Ana')` crea el objeto global `app` y guarda el valor en `app.name`.\n- `path` indica a `<ui-bind>` qué valor debe escuchar.\n- `config=\"text\"` le indica que renderice el valor como texto.\n\nCada `SET('app.name', ...)` posterior actualiza el encabezado. Lee más en [Paths](../paths/) y [Enlace de datos](../data-binding/).\n\n## Crea un componente\n\nUn componente es un widget reutilizable. Decláralo una vez con `COMPONENT()` y colócalo en la página con `<ui-component>`. Sustituye el contenido de `<body>` por este código:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<script>\nCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.html('<label></label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.configure = function(key, value) {\n\t\tif (key === 'label')\n\t\t\tself.find('label').text(value);\n\t};\n\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n\n}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\nSET('app.name', 'Ana');\n</script>\n```\n\nEscribe en el campo y el encabezado seguirá tu texto. Si vacías el campo, el encabezado muestra `Hello stranger`, porque `empty:stranger` en la configuración de `<ui-bind>` define el texto para un valor vacío.\n\nEsto es lo que hace cada parte de la declaración:\n\n| Código | Finalidad |\n| --- | --- |\n| `'textbox'` | El nombre que se usa en `<ui-component name=\"textbox\">` |\n| `'label:Name'` | La configuración predeterminada, que el atributo `config` puede sobrescribir |\n| `self.make` | Se ejecuta una vez por cada instancia y crea su HTML |\n| `self.aclass(cls)` | Añade la clase CSS `ui-textbox` al elemento |\n| `self.autobind20()` | Escribe el contenido del campo en el modelo mientras el usuario teclea |\n| `self.configure` | Se ejecuta para cada clave de configuración |\n| `self.validate` | Indica si el valor actual es válido. Después, la biblioteca añade o quita la clase `ui-invalid` |\n| El último argumento | El CSS del componente, donde `CLASS` representa `ui-textbox` |\n\nEl componente no define cómo mostrar el valor en el campo. Cuando un componente no tiene un `setter` propio, la biblioteca escribe el valor en el primer `input`, `select` o `textarea` que haya dentro del componente.\n\n## Ejecuta código desde un botón\n\nLos elementos con la clase `exec` llaman, al hacer clic en ellos, a la función indicada en su atributo `data-exec`. Añade un botón que vacíe el modelo:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n```\n\nDespués añade la función al script, encima de la llamada a `SET()`:\n\n```js\nFUNC.clear = function() {\n\tSET('app.name', '');\n};\n```\n\n`FUNC` es un objeto global vacío pensado para tus propias funciones. El clic solo cambia el modelo. El campo, el encabezado y el estado de validación se actualizan solos.\n\n## La página completa\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n\t<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n\t<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n\t<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n\n\t<script>\n\t\tCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\t\t\tself.make = function() {\n\t\t\t\tself.aclass(cls);\n\t\t\t\tself.html('<label></label><input type=\"text\" />');\n\t\t\t\tself.autobind20();\n\t\t\t};\n\n\t\t\tself.configure = function(key, value) {\n\t\t\t\tif (key === 'label')\n\t\t\t\t\tself.find('label').text(value);\n\t\t\t};\n\n\t\t\tself.validate = function(value) {\n\t\t\t\treturn !config.required || !!value;\n\t\t\t};\n\n\t\t}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\n\t\tFUNC.clear = function() {\n\t\t\tSET('app.name', '');\n\t\t};\n\n\t\tSET('app.name', 'Ana');\n\t</script>\n\n</body>\n</html>\n```\n\n## Si algo no funciona\n\n- **El componente se queda vacío.** Comprueba que el atributo `name` coincide con el nombre de `COMPONENT()`. Si el nombre es desconocido, la biblioteca intenta descargar el componente desde el CDN y escribe `jComponent: Downloading \"name\" component.` en la consola.\n- **El valor no cambia en la página.** Cambia el modelo con `SET()`. Una asignación directa como `app.name = 'Ana'` no avisa a nadie hasta que llamas a `UPD('app.name')`.\n\n## Siguientes pasos\n\n- [Paths](../paths/) explica cómo acceder a los datos y cambiarlos.\n- [Enlace de datos](../data-binding/) muestra todo lo que puede hacer `<ui-bind>`.\n- [Crear componentes](../creating-components/) cubre toda la API de componentes.\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:21.747Z"}
{"id":"JamcNO1od61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/getting-started/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Premiers pas","summary":"Construis une page fonctionnelle avec des données liées et un composant personnalisé, en partant d'un fichier vide.","markdown":"---\ntitle: Premiers pas\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/getting-started/\nupdated: 2026-11-18T18:15:21.747Z\n---\n\n# Premiers pas\n\n> Construis une page fonctionnelle avec des données liées et un composant personnalisé, en partant d'un fichier vide.\n\nCe guide t'emmène d'un fichier vide à une page fonctionnelle, avec un composant de saisie personnalisé et des données qui lui sont liées. Il te faut un éditeur de texte et un navigateur.\n\n## Crée la page\n\nCrée un fichier nommé `index.html` et charge la bibliothèque depuis le CDN :\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n</body>\n</html>\n```\n\nTout le code qui suit se place dans `<body>`. Ouvre directement le fichier dans le navigateur pour voir le résultat.\n\n## Affiche une valeur\n\nÉcris une valeur dans le modèle de données avec `SET()` et affiche-la avec un élément `<ui-bind>` :\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('app.name', 'Ana');\n</script>\n```\n\nLa page affiche `Hello Ana`.\n\n- `SET('app.name', 'Ana')` crée l'objet global `app` et stocke la valeur dans `app.name`.\n- `path` indique à `<ui-bind>` quelle valeur écouter.\n- `config=\"text\"` lui indique d'afficher la valeur sous forme de texte.\n\nChaque appel ultérieur à `SET('app.name', ...)` met à jour le titre. Pour en savoir plus, lis [Paths](../paths/) et [Liaison de données](../data-binding/).\n\n## Crée un composant\n\nUn composant est un widget réutilisable. Déclare-le une seule fois avec `COMPONENT()` et place-le sur la page avec `<ui-component>`. Remplace le contenu de `<body>` par ce code :\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<script>\nCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.html('<label></label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.configure = function(key, value) {\n\t\tif (key === 'label')\n\t\t\tself.find('label').text(value);\n\t};\n\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n\n}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\nSET('app.name', 'Ana');\n</script>\n```\n\nÉcris dans le champ et le titre suit ton texte. Vide le champ et le titre affiche `Hello stranger`, car `empty:stranger` dans la configuration de `<ui-bind>` définit le texte à afficher pour une valeur vide.\n\nVoici le rôle de chaque partie de la déclaration :\n\n| Code | Rôle |\n| --- | --- |\n| `'textbox'` | Le nom utilisé dans `<ui-component name=\"textbox\">` |\n| `'label:Name'` | La configuration par défaut, que l'attribut `config` peut remplacer |\n| `self.make` | S'exécute une fois pour chaque instance et crée son HTML |\n| `self.aclass(cls)` | Ajoute la classe CSS `ui-textbox` à l'élément |\n| `self.autobind20()` | Écrit le contenu du champ dans le modèle de données pendant la saisie |\n| `self.configure` | S'exécute pour chaque clé de configuration |\n| `self.validate` | Indique si la valeur actuelle est valide. La bibliothèque ajoute ou retire ensuite la classe `ui-invalid` |\n| Le dernier argument | Le CSS du composant, où `CLASS` représente `ui-textbox` |\n\nLe composant ne définit pas comment afficher la valeur dans le champ. Quand un composant n'a pas de `setter` propre, la bibliothèque écrit la valeur dans le premier `input`, `select` ou `textarea` qu'il contient.\n\n## Exécute du code depuis un bouton\n\nLes éléments dotés de la classe `exec` appellent, au clic, la fonction nommée dans leur attribut `data-exec`. Ajoute un bouton qui vide le modèle de données :\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n```\n\nAjoute ensuite la fonction au script, au-dessus de l'appel à `SET()` :\n\n```js\nFUNC.clear = function() {\n\tSET('app.name', '');\n};\n```\n\n`FUNC` est un objet global vide destiné à tes propres fonctions. Le clic ne modifie que le modèle de données. Le champ, le titre et l'état de validation suivent tous.\n\n## La page complète\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n\t<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n\t<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n\t<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n\n\t<script>\n\t\tCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\t\t\tself.make = function() {\n\t\t\t\tself.aclass(cls);\n\t\t\t\tself.html('<label></label><input type=\"text\" />');\n\t\t\t\tself.autobind20();\n\t\t\t};\n\n\t\t\tself.configure = function(key, value) {\n\t\t\t\tif (key === 'label')\n\t\t\t\t\tself.find('label').text(value);\n\t\t\t};\n\n\t\t\tself.validate = function(value) {\n\t\t\t\treturn !config.required || !!value;\n\t\t\t};\n\n\t\t}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\n\t\tFUNC.clear = function() {\n\t\t\tSET('app.name', '');\n\t\t};\n\n\t\tSET('app.name', 'Ana');\n\t</script>\n\n</body>\n</html>\n```\n\n## Si quelque chose ne fonctionne pas\n\n- **Le composant reste vide.** Vérifie que l'attribut `name` correspond au nom indiqué dans `COMPONENT()`. Pour un nom inconnu, la bibliothèque essaie de télécharger le composant depuis le CDN et écrit `jComponent: Downloading \"name\" component.` dans la console.\n- **La valeur ne change pas sur la page.** Modifie le modèle de données avec `SET()`. Une affectation directe comme `app.name = 'Ana'` ne prévient personne tant que tu n'appelles pas `UPD('app.name')`.\n\n## Étapes suivantes\n\n- [Paths](../paths/) explique comment désigner et modifier les données.\n- [Liaison de données](../data-binding/) montre tout ce que `<ui-bind>` sait faire.\n- [Créer des composants](../creating-components/) couvre toute l'API des composants.\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:21.747Z"}
{"id":"JamcNO1od61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/getting-started/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Primi passi","summary":"Crea una pagina funzionante con dati associati e un componente personalizzato, partendo da un file vuoto.","markdown":"---\ntitle: Primi passi\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/getting-started/\nupdated: 2026-11-18T18:15:21.747Z\n---\n\n# Primi passi\n\n> Crea una pagina funzionante con dati associati e un componente personalizzato, partendo da un file vuoto.\n\nQuesta guida ti porta da un file vuoto a una pagina funzionante con un componente di input personalizzato e dati associati. Ti servono un editor di testo e un browser.\n\n## Crea la pagina\n\nCrea un file chiamato `index.html` e carica la libreria dal CDN:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n</body>\n</html>\n```\n\nTutto il codice che segue va dentro `<body>`. Apri il file direttamente nel browser per vedere il risultato.\n\n## Mostra un valore\n\nScrivi un valore nel modello con `SET()` e visualizzalo con un elemento `<ui-bind>`:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('app.name', 'Ana');\n</script>\n```\n\nLa pagina mostra `Hello Ana`.\n\n- `SET('app.name', 'Ana')` crea l'oggetto globale `app` e salva il valore in `app.name`.\n- `path` indica a `<ui-bind>` quale valore ascoltare.\n- `config=\"text\"` gli indica di visualizzare il valore come testo.\n\nOgni successiva chiamata `SET('app.name', ...)` aggiorna l'intestazione. Approfondisci in [Path](../paths/) e [Associazione dei dati](../data-binding/).\n\n## Crea un componente\n\nUn componente è un widget riutilizzabile. Lo dichiari una sola volta con `COMPONENT()` e lo inserisci nella pagina con `<ui-component>`. Sostituisci il contenuto di `<body>` con questo codice:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<script>\nCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.html('<label></label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.configure = function(key, value) {\n\t\tif (key === 'label')\n\t\t\tself.find('label').text(value);\n\t};\n\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n\n}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\nSET('app.name', 'Ana');\n</script>\n```\n\nScrivi nel campo e l'intestazione segue il tuo testo. Se svuoti il campo, l'intestazione mostra `Hello stranger`, perché `empty:stranger` nella configurazione di `<ui-bind>` imposta il testo per un valore vuoto.\n\nEcco che cosa fa ogni parte della dichiarazione:\n\n| Codice | Scopo |\n| --- | --- |\n| `'textbox'` | Il nome usato in `<ui-component name=\"textbox\">` |\n| `'label:Name'` | La configurazione predefinita, che l'attributo `config` può sovrascrivere |\n| `self.make` | Viene eseguito una volta per ogni istanza e ne crea l'HTML |\n| `self.aclass(cls)` | Aggiunge la classe CSS `ui-textbox` all'elemento |\n| `self.autobind20()` | Scrive il contenuto dell'input nel modello mentre l'utente digita |\n| `self.configure` | Viene eseguito per ogni chiave di configurazione |\n| `self.validate` | Indica se il valore corrente è valido. La libreria aggiunge o rimuove quindi la classe `ui-invalid` |\n| L'ultimo argomento | Il CSS del componente, dove `CLASS` sta per `ui-textbox` |\n\nIl componente non definisce come mostrare il valore nell'input. Quando un componente non ha un proprio `setter`, la libreria scrive il valore nel primo `input`, `select` o `textarea` al suo interno.\n\n## Esegui codice da un pulsante\n\nGli elementi con la classe `exec` chiamano, al clic, la funzione indicata nel loro attributo `data-exec`. Aggiungi un pulsante che svuota il modello:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n```\n\nPoi aggiungi la funzione allo script, sopra la chiamata `SET()`:\n\n```js\nFUNC.clear = function() {\n\tSET('app.name', '');\n};\n```\n\n`FUNC` è un oggetto globale vuoto pensato per le tue funzioni. Il clic modifica solo il modello. L'input, l'intestazione e lo stato di validazione si adeguano di conseguenza.\n\n## La pagina completa\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n\t<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n\t<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n\t<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n\n\t<script>\n\t\tCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\t\t\tself.make = function() {\n\t\t\t\tself.aclass(cls);\n\t\t\t\tself.html('<label></label><input type=\"text\" />');\n\t\t\t\tself.autobind20();\n\t\t\t};\n\n\t\t\tself.configure = function(key, value) {\n\t\t\t\tif (key === 'label')\n\t\t\t\t\tself.find('label').text(value);\n\t\t\t};\n\n\t\t\tself.validate = function(value) {\n\t\t\t\treturn !config.required || !!value;\n\t\t\t};\n\n\t\t}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\n\t\tFUNC.clear = function() {\n\t\t\tSET('app.name', '');\n\t\t};\n\n\t\tSET('app.name', 'Ana');\n\t</script>\n\n</body>\n</html>\n```\n\n## Se qualcosa non funziona\n\n- **Il componente resta vuoto.** Controlla che l'attributo `name` corrisponda al nome in `COMPONENT()`. Con un nome sconosciuto, la libreria prova a scaricare il componente dal CDN e scrive `jComponent: Downloading \"name\" component.` nella console.\n- **Il valore non cambia nella pagina.** Modifica il modello con `SET()`. Un'assegnazione diretta come `app.name = 'Ana'` non avvisa nessuno finché non chiami `UPD('app.name')`.\n\n## Passi successivi\n\n- [Path](../paths/) spiega come indirizzare e modificare i dati.\n- [Associazione dei dati](../data-binding/) mostra tutto ciò che `<ui-bind>` può fare.\n- [Creare componenti](../creating-components/) tratta l'intera API dei componenti.\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:21.747Z"}
{"id":"JamcNO1od61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/getting-started/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Začíname","summary":"Postav funkčnú stránku s naviazanými dátami a vlastným komponentom, začni od prázdneho súboru.","markdown":"---\ntitle: \"Začíname\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/getting-started/\nupdated: 2026-11-18T18:15:21.747Z\n---\n\n# Začíname\n\n> Postav funkčnú stránku s naviazanými dátami a vlastným komponentom, začni od prázdneho súboru.\n\nTáto príručka ťa prevedie od prázdneho súboru až k funkčnej stránke s vlastným vstupným komponentom a dátami, ktoré sú naň naviazané. Potrebuješ textový editor a prehliadač.\n\n## Vytvor stránku\n\nVytvor súbor s názvom `index.html` a načítaj knižnicu z CDN:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n</body>\n</html>\n```\n\nVšetok ďalší kód patrí do `<body>`. Výsledok uvidíš, keď súbor otvoríš priamo v prehliadači.\n\n## Zobraz hodnotu\n\nZapíš hodnotu do modelu pomocou `SET()` a zobraz ju elementom `<ui-bind>`:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text\"></ui-bind></h1>\n\n<script>\n\tSET('app.name', 'Ana');\n</script>\n```\n\nStránka zobrazí `Hello Ana`.\n\n- `SET('app.name', 'Ana')` vytvorí globálny objekt `app` a uloží hodnotu do `app.name`.\n- `path` určuje, ktorú hodnotu má `<ui-bind>` počúvať.\n- `config=\"text\"` mu hovorí, aby hodnotu vykreslil ako text.\n\nKaždé ďalšie volanie `SET('app.name', ...)` aktualizuje nadpis. Viac sa dočítaš v častiach [Paths](../paths/) a [Dátová väzba](../data-binding/).\n\n## Vytvor komponent\n\nKomponent je opakovane použiteľný widget. Raz ho deklaruješ pomocou `COMPONENT()` a na stránku ho umiestniš elementom `<ui-component>`. Nahraď obsah `<body>` týmto kódom:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<script>\nCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.html('<label></label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.configure = function(key, value) {\n\t\tif (key === 'label')\n\t\t\tself.find('label').text(value);\n\t};\n\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n\n}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\nSET('app.name', 'Ana');\n</script>\n```\n\nPíš do poľa a nadpis bude sledovať tvoj text. Keď pole vyprázdniš, nadpis zobrazí `Hello stranger`, pretože `empty:stranger` v konfigurácii `<ui-bind>` určuje text pre prázdnu hodnotu.\n\nToto robí každá časť deklarácie:\n\n| Kód | Účel |\n| --- | --- |\n| `'textbox'` | Názov použitý v `<ui-component name=\"textbox\">` |\n| `'label:Name'` | Predvolená konfigurácia, ktorú môže prepísať atribút `config` |\n| `self.make` | Spustí sa raz pre každú inštanciu a vytvorí jej HTML |\n| `self.aclass(cls)` | Pridá elementu CSS triedu `ui-textbox` |\n| `self.autobind20()` | Počas písania zapisuje obsah vstupného poľa do modelu |\n| `self.configure` | Spustí sa pre každý konfiguračný kľúč |\n| `self.validate` | Určí, či je aktuálna hodnota platná. Knižnica potom pridá alebo odstráni triedu `ui-invalid` |\n| Posledný argument | CSS komponentu, v ktorom `CLASS` zastupuje `ui-textbox` |\n\nKomponent neurčuje, ako sa má hodnota zobraziť vo vstupnom poli. Keď komponent nemá vlastný `setter`, knižnica zapíše hodnotu do prvého prvku `input`, `select` alebo `textarea` vo vnútri komponentu.\n\n## Spusti kód tlačidlom\n\nElementy s triedou `exec` po kliknutí zavolajú funkciu uvedenú v atribúte `data-exec`. Pridaj tlačidlo, ktoré vyčistí model:\n\n```html\n<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n```\n\nPotom pridaj funkciu do skriptu nad volanie `SET()`:\n\n```js\nFUNC.clear = function() {\n\tSET('app.name', '');\n};\n```\n\n`FUNC` je prázdny globálny objekt určený pre tvoje vlastné funkcie. Kliknutie zmení iba model. Vstupné pole, nadpis aj stav validácie sa prispôsobia.\n\n## Celá stránka\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n\t<meta charset=\"utf-8\" />\n\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n\t<title>My first page</title>\n\t<link rel=\"stylesheet\" href=\"https://cdn.componentator.com/spa.min@20.css\" />\n\t<script src=\"https://cdn.componentator.com/spa.min@20.js\"></script>\n</head>\n<body>\n\n\t<h1>Hello <ui-bind path=\"app.name\" config=\"text;empty:stranger\"></ui-bind></h1>\n\n\t<ui-component name=\"textbox\" path=\"app.name\" config=\"label:Your name;required:true\"></ui-component>\n\n\t<button class=\"exec\" data-exec=\"FUNC.clear\">Clear</button>\n\n\t<script>\n\t\tCOMPONENT('textbox', 'label:Name', function(self, config, cls) {\n\n\t\t\tself.make = function() {\n\t\t\t\tself.aclass(cls);\n\t\t\t\tself.html('<label></label><input type=\"text\" />');\n\t\t\t\tself.autobind20();\n\t\t\t};\n\n\t\t\tself.configure = function(key, value) {\n\t\t\t\tif (key === 'label')\n\t\t\t\t\tself.find('label').text(value);\n\t\t\t};\n\n\t\t\tself.validate = function(value) {\n\t\t\t\treturn !config.required || !!value;\n\t\t\t};\n\n\t\t}, null, '.CLASS label { display: block; font-weight: bold; } .CLASS.ui-invalid input { border-color: red; }');\n\n\t\tFUNC.clear = function() {\n\t\t\tSET('app.name', '');\n\t\t};\n\n\t\tSET('app.name', 'Ana');\n\t</script>\n\n</body>\n</html>\n```\n\n## Ak niečo nefunguje\n\n- **Komponent zostáva prázdny.** Skontroluj, či sa atribút `name` zhoduje s názvom v `COMPONENT()`. Pri neznámom názve sa knižnica pokúsi stiahnuť komponent z CDN a do konzoly zapíše `jComponent: Downloading \"name\" component.`.\n- **Hodnota sa na stránke nemení.** Model meň pomocou `SET()`. Priame priradenie, napríklad `app.name = 'Ana'`, nikoho neupozorní, kým nezavoláš `UPD('app.name')`.\n\n## Ďalšie kroky\n\n- [Paths](../paths/) vysvetľuje, ako odkazovať na dáta a ako ich meniť.\n- [Dátová väzba](../data-binding/) ukazuje všetko, čo `<ui-bind>` dokáže.\n- [Vytváranie komponentov](../creating-components/) pokrýva celé API komponentov.\n","entries":[],"license":"MIT","updated":"2026-11-18T18:15:21.747Z"}
{"id":"JanEc21ew61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/migrating-from-v19/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Migrating from jComponent 19","summary":"Replace every removed or changed jComponent 19 API with its jComponent 20 equivalent, including the changes that fail without an error.","markdown":"---\ntitle: Migrating from jComponent 19\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/migrating-from-v19/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# Migrating from jComponent 19\n\n> Replace every removed or changed jComponent 19 API with its jComponent 20 equivalent, including the changes that fail without an error.\n\nThis guide moves an application from jComponent 19 to jComponent 20.015. It shows the replacement for each function, attribute and setting that was removed or changed, and it marks the changes that give no error in the browser console, because those are the ones a quick test misses.\n\n## Update the CDN files\n\nReplace both files. The bundle still contains jQuery, Tangular and the routing functions, so nothing else has to be loaded.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `https://cdn.componentator.com/spa.min@19.js` | `https://cdn.componentator.com/spa.min@20.js` |\n| `https://cdn.componentator.com/spa.min@19.css` | `https://cdn.componentator.com/spa.min@20.css` |\n\n## Recommended order of work\n\n1. Replace the CDN files and open the application with the browser console visible.\n2. Change the markup first: `data---`, `data-bind` and `data-scope` elements are ignored, so nothing else can be tested until they are converted.\n3. Search the code for the patterns in [Changes that fail silently](#changes-that-fail-silently) and fix them. The console does not point to them.\n4. Fix the errors the console reports, such as `VALID is not defined` or `$(...).scope is not a function`.\n5. Port the forms, then test every form by hand: empty, invalid, valid and after a reset.\n6. Test the screens that load data, because AJAX callbacks receive fewer arguments.\n\n## Changes that fail silently\n\nEach of these runs without an error in 20.015 and does the wrong thing. Search your code for the left column.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `RESET('form.*');` | `RESET('form');` |\n| `GET('form @modified')` | `COMPONENTS('form @modified')` |\n| `return value; // a non-empty string means valid` | `return !!value;` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<ui-plugin path=\"address\">` | `<ui-plugin path=\"?.address\">` |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n\nA `PLUGIN()` declaration without a `<ui-plugin>` element also stops running. See [Scopes and plugins](#scopes-and-plugins).\n\n## Forms and validation\n\n`VALID()`, `CAN()`, `DISABLED()`, `INVALID()`, `CHANGE()`, `MODIFIED()` and `DEFAULT()` were removed. Read the state of a form with `COMPONENTS()` and `ERRORS()`, and change it with flags. [Forms and validation](../forms/) describes the new way of working.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `VALID('form.*')` | `COMPONENTS('form @invalid').length === 0` |\n| `CAN('form.*')` | `can('form')` (the function below) |\n| `DISABLED('form.*')` | `!can('form')` |\n| `ERRORS('form.*')` | `ERRORS('form @touched', list => console.log(list.length))` |\n| `CHANGE('form.*');` | `UPD('form @change');` |\n| `CHANGE('form.*', false);` | `RESET('form');` |\n| `MODIFIED('form.*')` | `COMPONENTS('form @modified').map(com => com.path.toString())` |\n| `DEFAULT('filter.*');` | `SET('filter @default', {});` |\n| `INVALID('form.name');` | `COMPONENTS('form.name').forEach(com => com.reconfigure({ touched: 1, invalid: true }));` |\n| `RESET('form.*');` | `RESET('form');` |\n\n`CAN()` has no direct replacement, so keep a small function in your application:\n\n```js\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n```\n\n**`ERRORS()` takes a callback.** Without one it throws `r is not a function`. In 19 it returned the fields that were touched and invalid. In 20 it passes every invalid field, so add the `@touched` flag to keep the old result:\n\n```js\nERRORS('form @touched', list => console.log(list.length)); // 0\nSET('form.name @change', '');\nERRORS('form @touched', list => console.log(list.map(com => com.path.toString()))); // [\"form.name\"]\n```\n\n**Paths no longer take `.*`.** It does not match anything, and no error is shown. `ERRORS()` then reports a broken form as valid:\n\n```js\nERRORS('form.*', list => console.log(list.length)); // 0\nERRORS('form', list => console.log(list.length)); // 1\n```\n\n**`GET('form @modified')` returns the whole model** in 20. Collect the changed fields yourself:\n\n```js\nSET('form.city @change', 'Prague');\n\nvar changed = {};\nCOMPONENTS('form @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n**The result of `self.validate` is read differently.** Any truthy value was valid in 19. In 20 a non-empty string is an error message, so a validator that returns the value marks a filled field as invalid. A number such as `value.length` is invalid too. Return a boolean:\n\n```js\nself.validate = function(value) {\n\treturn !!value;\n};\n```\n\n```js\nself.validate = function(value) {\n\treturn value.length > 0;\n};\n```\n\n`self.validate` also lost its second argument, `init`. Keep your own flag when the first run needs different treatment:\n\n```js\nCOMPONENT('field', function(self, config) {\n\tvar init = true;\n\tself.validate = function(value) {\n\t\tconsole.log(init);\n\t\tinit = false;\n\t\treturn true;\n\t};\n});\n```\n\n### Binding an input\n\nThe `data-jc-bind` attribute is ignored, so the input does not write to the model. Call `self.autobind20()` once the HTML exists:\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n```\n\nThe global `FORMATTER()` and `PARSER()` were removed. Register them on the component:\n\n```js\nself.formatter(function(path, value) {\n\treturn value ? value.toUpperCase() : value;\n});\n```\n\n```js\nself.parser(function(path, value) {\n\treturn value ? value.toLowerCase() : value;\n});\n```\n\n## Watchers and paths\n\nThe arguments of a watcher changed order, and the code keeps running with the wrong values. [Paths](../paths/) describes watchers in 20.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `self.watch('user.name', function(path, value, type) {` | `self.watch('user.name', function(value, flags, path) {` |\n| `exports.watch('count', function(value, path, type) {` | `exports.watch('count', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `WATCHONCE('user.name', function(path, value) {` | `UNWATCH('user.name', once);` inside the callback |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nA watcher on a parent path also runs for the paths under it, so `WATCH('user', ...)` replaces the wildcard.\n\n## Writing to the model\n\nThe third argument of `SET()` was removed. A delay or a reset flag passed there is ignored, and the value is written at once.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `PUSH('cart.items', 'tea');` on a missing path | `SET('cart.items', ['tea']);` |\n| `NOTIFY('user.name');` | `UPD('user.name');` |\n| `EXT('user', { age: 30 });` | `SET('user', Object.assign(GET('user'), { age: 30 }));` |\n| `MAKE(function(obj) {` | A plain object |\n| `EVALUATE('user.age', 'value >= 18')` | `FN('value => value >= 18')(GET('user.age'))` |\n| `REMOVECACHE('token');` | `CACHE('token', null, '1 day');` |\n| `CL_INIT('colors', function(next) {` | `CLINIT('colors', function(next) {` |\n\n`PUSH()` to a path that does not exist notifies no watcher, so create the array with `SET()`.\n\nThe third argument of `CACHEPATH()` is now a default value, and the values saved by jComponent 19 are not read:\n\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n```\n\n## Calling components and functions\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `RECONFIGURE('box', 'size:2');` | `SETTER('box/reconfigure', 'size:2');` |\n| `RETURN('box/name')` | `FIND('box').name` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `EXEC(true, 'FUNC.start', 'now');` | `EXEC('FUNC.start @important', 'now');` |\n| `AEXEC('FUNC.save', 1)` | `() => EXEC('FUNC.save', 1)` |\n| `ADD('box__user.name', '#panel');` | `$('#panel').append('<ui-component name=\"box\" path=\"user.name\"></ui-component>');` |\n\n## Markup attributes\n\nThe attribute forms are ignored without an error, and the elements stay empty. Use the custom elements described in [Using components](../using-components/) and [Data binding](../data-binding/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<span id=\"name\" data-bind=\"user.name__text\"></span>` | `<ui-bind id=\"name\" path=\"user.name\" config=\"text\"></ui-bind>` |\n| `<div id=\"box\" data-scope=\"panel\">` | `<ui-plugin id=\"box\" path=\"panel\">` |\n\n## Scopes and plugins\n\nThere is no scope object in 20. A `<ui-plugin>` element is the scope, and `$(selector).plugin()` returns the instance. An element with `?` paths outside a `<ui-plugin>` is not rendered. [Plugins](../plugins/) describes the plugin object.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `var scope = $('#panel').scope();` | `var plugin = $('#panel').plugin();` |\n| `console.log(scope.path); // invoice` | `console.log(plugin.path.toString()); // invoice` |\n| `scope.watch('number', function(path, value) {` | `plugin.watch('number', function(value, flags, path) {` |\n| `<ui-plugin path=\"address\">` nested in a plugin | `<ui-plugin path=\"?.address\">` |\n| `<ui-plugin path=\"!shared\">` | `<ui-plugin path=\"shared\">` |\n| `<ui-plugin path=\"login\" default=\"{ user: 'guest' }\">` | `exports.set('user', 'guest');` in the plugin |\n| `function loginready(path, element) {` | `function loginready(element) {` |\n| `config=\"text:?/format\"` | `config=\"text:PLUGINS.contact.format(value)\"` |\n\nA nested `<ui-plugin>` no longer extends the path of its parent. Write `?` in the path to get the old result, otherwise the plugin reads a global path of the same name:\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-plugin path=\"?.address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n```\n\n**A plugin needs its element.** In 19 `PLUGIN()` created the instance on its own. In 20 the callback runs only when a `<ui-plugin>` element with that path exists, so a plugin without one never starts:\n\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n```\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `exports.extend('filter', { page: 2 });` | `exports.set('filter', Object.assign(exports.get('filter'), { page: 2 }));` |\n| `PLUGINS.orders.reset();` | `RESET(PLUGINS.orders.path.toString());` |\n| `exports.api('/api/ orders_list', { page: 1 }, function() {` | `API('/api/', 'orders_list', { page: 1 }, function() {` |\n| `console.log(exports.modified); // {\"city\":\"Prague\"}` | The code below |\n\n`exports.modified` returns the whole model and clears the state of the components. Collect the changed fields first:\n\n```js\nvar changed = {};\nCOMPONENTS(exports.path + ' @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nRESET(exports.path.toString());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n## ui-bind commands\n\nSeveral commands of `<ui-bind>` were removed, and most of them are skipped without an error. The expression of a command is plain JavaScript, so a call inside it replaces most of them. The [ui-bind reference](../../reference/ui-bind/) lists the commands of 20.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `config=\"text;currency:eur\"` | `config=\"text:value.currency('eur')\"` |\n| `config=\"text;default:'none'\"` | `config=\"text:value == null ? 'none' : value\"` |\n| `config=\"text;helper:pluralize('no items','# item','# items','# items')\"` | `config=\"text:value.pluralize('no items','# item','# items','# items')\"` |\n| `config=\"text;selector:b\"` | `config=\"text\" child=\"b\"` |\n| `config=\"checked input\"` | `config=\"checked\"` |\n| `config=\"init:FUNC.start;text\"` | `config=\"exec:FUNC.start;text\"` |\n| `config=\"click:FUNC.open\"` | `<button id=\"a\" class=\"exec\" data-exec=\"FUNC.open\">Open</button>` |\n| `config=\"setter:'box/show',value\"` | `config=\"exec:FUNC.show\"` |\n| `config=\"config:'size:' + value\"` | `<ui-component name=\"box\" config=\"=size:ui.size\"></ui-component>` |\n\n**The value `false` renders as empty** with the `text` command. Convert the value to a string:\n\n```html\n<ui-bind id=\"a\" path=\"order.count\" config=\"text:value + ''\"></ui-bind>\n```\n\n## Components\n\nThe `path` of a component is now an object. Comparing it with a string gives `false`, and string methods such as `split()` do not exist on it, so convert it first. The third argument of `self.setter` is an object with flags in place of a number. [Creating components](../creating-components/) describes the delegates.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `self.path === 'form.name'` | `self.path.toString() === 'form.name'` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `type === 0` | `flags.init` |\n| `self.notify();` | `self.upd();` |\n| `self.faicon('home')` | `self.icon('home')` |\n| `self.scopepath('user.age')` | `self.makepath('user.age')` |\n| `self.inc(2);` | `self.set(self.get() + 2);` |\n| `self.extend({ b: 2 });` | `self.set(Object.assign(self.get(), { b: 2 }));` |\n| `self.dirty()` | `!config.touched` |\n| `self.dirty(false);` | `self.touch();` |\n| `self.invalid();` | `self.reconfigure({ touched: 1, invalid: true });` |\n| `self.skip();` before `self.set(2);` | `self.rewrite(2);` |\n| `self.main()` | `self.element.parent().component()` |\n| `self.exec('show', 1)` | `self.element.SETTER('*/show', 1)` |\n| `self.data('page', 2);` | A variable inside the component |\n\nThe arguments of `self.state(type, what)` have different values in 20. Read the state from `config`:\n\n```js\nself.state = function() {\n\tif (config.touched && config.modified && !changed) {\n\t\tchanged = true;\n\t\tconsole.log('changed');\n\t}\n};\n```\n\n`self.bindchanges()` was removed. Compare the value in the setter:\n\n```js\nvar last;\nself.setter = function(value) {\n\tif (value !== last) {\n\t\tlast = value;\n\t\tconsole.log(value);\n\t}\n};\n```\n\n## Macros and virtual bindings\n\n`MACRO()`, the `macro` command, `VBIND()`, `VBINDARRAY()` and the `vbindarray` command were removed. Rewrite a macro as a component, and rewrite a virtual binding as a `template` command with [Tangular](../tangular/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `MACRO('clicks', function(self, element) {` | `COMPONENT('clicks', function(self) {` |\n| `config=\"macro:clicks\"` | `<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>` |\n| `VBIND('<div><b data-bind=\".name__text\"></b></div>')` | `config=\"template\"` |\n| `VBINDARRAY('<li data-bind=\".name__text\"></li>', '#list')` | `config=\"template\"` |\n| `config=\"vbindarray\"` | `config=\"template\"` |\n\n```html\n<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>\n```\n\n```js\nCOMPONENT('clicks', function(self) {\n\tself.make = function() {\n\t\tself.event('click', () => self.set((self.get() || 0) + 1));\n\t};\n\tself.setter = function(value) {\n\t\tself.text('Clicked ' + (value || 0));\n\t};\n});\n```\n\nA list that used `VBINDARRAY()` becomes a template:\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"rows\" config=\"template\">\n\t\t<script type=\"text/html\">{{ foreach m in value }}<li>{{ m.name }}</li>{{ end }}</script>\n\t</ui-bind>\n</ul>\n```\n\n## The M object\n\n`M` still exists and is the same object as `jComponent` and `MAIN`. `M.version`, `M.components` and `M.binders` work as before. The methods that changed the model were removed or take different arguments, so use the global functions.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `M.set('user.name', 'Ann');` | `SET('user.name', 'Ann');` |\n| `M.inc('user.age', 2);` | `INC('user.age', 2);` |\n| `M.push('user.tags', 'new');` | `PUSH('user.tags', 'new');` |\n\n## AJAX and APIs\n\nThe callback of `AJAX()` receives only the response, and `AJAX()` no longer returns a Promise. The [Global functions](../../reference/globals/) reference describes `AJAX()`.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n| `AJAX('GET /orders/').then(function(response) {` | `new Promise(resolve => AJAX('GET /orders/', resolve)).then(function(response) {` |\n| `AJAX('GET /orders/ error', () => console.log('callback'));` | `AJAX('GET /orders/ ERROR', () => console.log('callback'));` |\n| `AJAX('GET /orders/ {\"X-Token\":\"abc\"}', function() {` | `ON('request', opt => opt.headers['X-Token'] = 'abc');` |\n| `AJAXCONFIG('secure', function(options) {` | `ON('request', function(options) {` |\n| `AJAXCACHE('GET /orders/', null, NOOP, '1 minute');` | `AJAX('GET /orders/ <1 minute>', NOOP);` |\n| `AJAX('GET /orders/', null, 'orders', 100);` | `setTimeout(() => AJAX('GET /orders/', 'orders'), 100);` |\n| `API('/api/ users_save', { name: 'Ann' }, function() {` | `API('/api/', 'users_save', { name: 'Ann' }, function() {` |\n| `DAPI('users_save', { name: 'Ann' }, function() {` | `TAPI('users_save', { name: 'Ann' }, function() {` |\n\nTo read the status code of a response, listen to the `response` event ahead of the request:\n\n```js\nvar status = 0;\n\nON('response', opt => status = opt.status);\n\nAJAX('GET /orders/', function(response) {\n\tconsole.log(response.error, status); // denied 403\n});\n```\n\n## Settings\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `DEF.validators.email` | `DEF.regexp.email` |\n| `DEF.pathcommon` | `DEF.path.common` |\n| `DEF.pathcl` | `DEF.path.cl` |\n| `DEF.environment` | `DEF.env` |\n| `DEF.languagehtml = 'sk';` | `DEF.language = 'sk';` |\n\nThese settings no longer exist: `ajaxcredentials`, `ajaxcredentialshtml`, `ajaxerrors`, `customelements`, `delay`, `delaybinder`, `delaykeypress`, `delaypref`, `delayrepeat`, `delaywatcher`, `fallbackcache`, `importcache`, `jsoncompress`, `jsonconverter`, `jsondate`, `keypress`, `makeurl`, `monitor`, `prefixcssmacros`, `repeatfocus`, `scope`, `secret` and `versioncomponents`. The [DEF](../../reference/def/) reference lists the settings of 20.\n\n## Events\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `ON('destroy', name => console.log('removed', name));` | `self.destroy = () => console.log('removed', self.name);` |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nThe `exec` event is no longer emitted. `WW` and `WH` are not set until the library starts, so read them inside `ON('ready', ...)`. The [Events](../../reference/events/) reference lists the events of 20.\n\n## jQuery helpers\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `$('#panel').components()` | `$('#panel').COMPONENTS()` |\n| `$('#panel').FIND('box')` | `$('#panel').COMPONENTS().findItem('name', 'box')` |\n| `$('#panel').RECONFIGURE('box', 'size:2');` | `$('#panel').SETTER('box/reconfigure', 'size:2');` |\n| `$('#panel').EMIT('hello', 1);` | `EMIT('hello', 1);` |\n\n## String, number, date and array helpers\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `'Hello {name}'.arg({ name: 'Ann' })` | `'Hello {name}'.args({ name: 'Ann' })` |\n| `'{{ name }}'.render({ name: 'Ann' })` | `Tangular.render('{{ name }}', { name: 'Ann' })` |\n| `'<b>Ann</b>'.removeTags()` | `'<b>Ann</b>'.replace(/<[^>]*>/g, '')` |\n| `'a=1&b=2'.parseEncoded()` | `Object.fromEntries(new URLSearchParams('a=1&b=2'))` |\n| `new Date(2026, 0, 5).toNumber()` | `+new Date(2026, 0, 5).format('yyyyMMdd')` |\n| `new Date(2026, 0, 5).parseDate()` | `new Date(2026, 0, 5)` |\n| `(5).between({ 1: 'low', 10: 'high' })` | `value < 10 ? 'low' : 'high'` |\n| `tasks.async(() => console.log('done'));` | `tasks.wait((task, next) => task(next), () => console.log('done'));` |\n\n`String.parseConfig()` no longer accepts a callback, and it ignores one without an error. Loop over the returned object:\n\n```js\nvar config = 'size:2;open:true'.parseConfig();\n\nfor (var key in config)\n\tconsole.log(key, config[key]);\n```\n\n## Functions without a replacement\n\nThese global functions were removed, and 20.015 has no direct equivalent.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WAPI`, `WAPI_INIT`, `AJAXCACHEREVIEW` | No replacement |\n| `DEBUG`, `STOPDEBUG` | No replacement |\n| `QUEUE`, `REPEAT`, `WORKFLOW` | No replacement |\n| `PLUGINABLE`, `VERSION`, `IMPORTCACHE` | No replacement |\n| `CLEARCACHE`, `REWRITE`, `REWRITE2`, `NOTMODIFIED`, `BIND`, `OPT` | No replacement |\n\n## A complete form\n\nThis form has two required fields and a button that is enabled once the form is valid. Both versions behave the same: the first save reports the two invalid paths, and a save with filled fields returns the model.\n\nBefore, in jComponent 19:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.validators.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" data-jc-bind />');\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nWATCH('form.*', function(path, value, type) {\n\t$('#save').prop('disabled', DISABLED('form.*'));\n});\n\nfunction save() {\n\n\tCHANGE('form.*');\n\n\tif (!VALID('form.*')) {\n\t\tconsole.log(ERRORS('form.*').map(com => com.path));\n\t\treturn;\n\t}\n\n\tconsole.log(GET('form @reset'));\n}\n</script>\n```\n\nAfter, in jComponent 20:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.regexp.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n\nWATCH('form', function(value, flags, path) {\n\t$('#save').prop('disabled', !can('form'));\n});\n\nfunction save() {\n\n\tUPD('form @change');\n\n\tERRORS('form', function(list) {\n\n\t\tif (list.length) {\n\t\t\tconsole.log(list.map(com => com.path.toString()));\n\t\t\treturn;\n\t\t}\n\n\t\tconsole.log(GET('form @reset'));\n\t});\n}\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JanEc21ew61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/migrating-from-v19/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Migration von jComponent 19","summary":"Ersetze jede entfernte oder geänderte API von jComponent 19 durch ihre Entsprechung in jComponent 20, auch bei den Änderungen, die ohne Fehlermeldung fehlschlagen.","markdown":"---\ntitle: Migration von jComponent 19\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/migrating-from-v19/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# Migration von jComponent 19\n\n> Ersetze jede entfernte oder geänderte API von jComponent 19 durch ihre Entsprechung in jComponent 20, auch bei den Änderungen, die ohne Fehlermeldung fehlschlagen.\n\nDiese Anleitung bringt eine Anwendung von jComponent 19 auf jComponent 20.015. Du findest hier den Ersatz für jede entfernte oder geänderte Funktion, jedes Attribut und jede Einstellung. Markiert sind außerdem die Änderungen, die in der Browser-Konsole keinen Fehler erzeugen, denn genau diese übersieht ein schneller Test.\n\n## Die CDN-Dateien aktualisieren\n\nErsetze beide Dateien. Das Bundle enthält weiterhin jQuery, Tangular und die Routing-Funktionen, du musst also nichts weiter laden.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `https://cdn.componentator.com/spa.min@19.js` | `https://cdn.componentator.com/spa.min@20.js` |\n| `https://cdn.componentator.com/spa.min@19.css` | `https://cdn.componentator.com/spa.min@20.css` |\n\n## Empfohlene Reihenfolge\n\n1. Ersetze die CDN-Dateien und öffne die Anwendung mit sichtbarer Browser-Konsole.\n2. Ändere zuerst das Markup: Elemente mit `data---`, `data-bind` und `data-scope` werden ignoriert, du kannst also nichts anderes testen, bis sie umgestellt sind.\n3. Durchsuche den Code nach den Mustern aus [Änderungen, die still fehlschlagen](#changes-that-fail-silently) und korrigiere sie. Die Konsole weist nicht auf sie hin.\n4. Behebe die Fehler, die die Konsole meldet, etwa `VALID is not defined` oder `$(...).scope is not a function`.\n5. Portiere die Formulare und teste dann jedes Formular von Hand: leer, ungültig, gültig und nach einem Zurücksetzen.\n6. Teste die Ansichten, die Daten laden, denn AJAX-Callbacks erhalten weniger Argumente.\n\n## Änderungen, die still fehlschlagen\n\nJede dieser Stellen läuft in 20.015 ohne Fehler und tut das Falsche. Durchsuche deinen Code nach der linken Spalte.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `RESET('form.*');` | `RESET('form');` |\n| `GET('form @modified')` | `COMPONENTS('form @modified')` |\n| `return value; // a non-empty string means valid` | `return !!value;` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<ui-plugin path=\"address\">` | `<ui-plugin path=\"?.address\">` |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n\nAuch eine `PLUGIN()`-Deklaration ohne `<ui-plugin>`-Element wird nicht mehr ausgeführt. Siehe [Scopes und Plugins](#scopes-and-plugins).\n\n## Formulare und Validierung\n\n`VALID()`, `CAN()`, `DISABLED()`, `INVALID()`, `CHANGE()`, `MODIFIED()` und `DEFAULT()` wurden entfernt. Lies den Zustand eines Formulars mit `COMPONENTS()` und `ERRORS()` aus und ändere ihn mit Flags. [Formulare und Validierung](../forms/) beschreibt die neue Arbeitsweise.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `VALID('form.*')` | `COMPONENTS('form @invalid').length === 0` |\n| `CAN('form.*')` | `can('form')` (die Funktion unten) |\n| `DISABLED('form.*')` | `!can('form')` |\n| `ERRORS('form.*')` | `ERRORS('form @touched', list => console.log(list.length))` |\n| `CHANGE('form.*');` | `UPD('form @change');` |\n| `CHANGE('form.*', false);` | `RESET('form');` |\n| `MODIFIED('form.*')` | `COMPONENTS('form @modified').map(com => com.path.toString())` |\n| `DEFAULT('filter.*');` | `SET('filter @default', {});` |\n| `INVALID('form.name');` | `COMPONENTS('form.name').forEach(com => com.reconfigure({ touched: 1, invalid: true }));` |\n| `RESET('form.*');` | `RESET('form');` |\n\nFür `CAN()` gibt es keinen direkten Ersatz, behalte also eine kleine Funktion in deiner Anwendung:\n\n```js\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n```\n\n**`ERRORS()` erwartet einen Callback.** Ohne Callback wirft die Funktion `r is not a function`. In 19 lieferte sie die Felder, die berührt und ungültig waren. In 20 übergibt sie jedes ungültige Feld, ergänze also das Flag `@touched`, um das alte Ergebnis zu behalten:\n\n```js\nERRORS('form @touched', list => console.log(list.length)); // 0\nSET('form.name @change', '');\nERRORS('form @touched', list => console.log(list.map(com => com.path.toString()))); // [\"form.name\"]\n```\n\n**Paths akzeptieren kein `.*` mehr.** Es passt auf nichts, und es erscheint kein Fehler. `ERRORS()` meldet ein fehlerhaftes Formular dann als gültig:\n\n```js\nERRORS('form.*', list => console.log(list.length)); // 0\nERRORS('form', list => console.log(list.length)); // 1\n```\n\n**`GET('form @modified')` liefert in 20 das ganze Modell.** Sammle die geänderten Felder selbst:\n\n```js\nSET('form.city @change', 'Prague');\n\nvar changed = {};\nCOMPONENTS('form @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n**Das Ergebnis von `self.validate` wird anders ausgewertet.** In 19 galt jeder truthy Wert als gültig. In 20 ist ein nicht leerer String eine Fehlermeldung, ein Validator, der den Wert zurückgibt, markiert ein ausgefülltes Feld also als ungültig. Auch eine Zahl wie `value.length` ist ungültig. Gib einen booleschen Wert zurück:\n\n```js\nself.validate = function(value) {\n\treturn !!value;\n};\n```\n\n```js\nself.validate = function(value) {\n\treturn value.length > 0;\n};\n```\n\n`self.validate` hat außerdem sein zweites Argument `init` verloren. Führe ein eigenes Flag, wenn der erste Durchlauf anders behandelt werden muss:\n\n```js\nCOMPONENT('field', function(self, config) {\n\tvar init = true;\n\tself.validate = function(value) {\n\t\tconsole.log(init);\n\t\tinit = false;\n\t\treturn true;\n\t};\n});\n```\n\n### Bindung eines Eingabefelds\n\nDas Attribut `data-jc-bind` wird ignoriert, das Eingabefeld schreibt also nicht in das Modell. Rufe `self.autobind20()` auf, sobald das HTML existiert:\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n```\n\nDie globalen Funktionen `FORMATTER()` und `PARSER()` wurden entfernt. Registriere sie an der Komponente:\n\n```js\nself.formatter(function(path, value) {\n\treturn value ? value.toUpperCase() : value;\n});\n```\n\n```js\nself.parser(function(path, value) {\n\treturn value ? value.toLowerCase() : value;\n});\n```\n\n## Watcher und Paths\n\nDie Argumente eines Watchers haben ihre Reihenfolge geändert, und der Code läuft mit den falschen Werten weiter. [Paths](../paths/) beschreibt die Watcher in 20.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `self.watch('user.name', function(path, value, type) {` | `self.watch('user.name', function(value, flags, path) {` |\n| `exports.watch('count', function(value, path, type) {` | `exports.watch('count', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `WATCHONCE('user.name', function(path, value) {` | `UNWATCH('user.name', once);` im Callback |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nEin Watcher auf einem übergeordneten Path läuft auch für die Paths darunter, `WATCH('user', ...)` ersetzt also den Platzhalter.\n\n## In das Modell schreiben\n\nDas dritte Argument von `SET()` wurde entfernt. Eine dort übergebene Verzögerung oder ein Reset-Flag wird ignoriert, und der Wert wird sofort geschrieben.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `PUSH('cart.items', 'tea');` auf einem fehlenden Path | `SET('cart.items', ['tea']);` |\n| `NOTIFY('user.name');` | `UPD('user.name');` |\n| `EXT('user', { age: 30 });` | `SET('user', Object.assign(GET('user'), { age: 30 }));` |\n| `MAKE(function(obj) {` | Ein einfaches Objekt |\n| `EVALUATE('user.age', 'value >= 18')` | `FN('value => value >= 18')(GET('user.age'))` |\n| `REMOVECACHE('token');` | `CACHE('token', null, '1 day');` |\n| `CL_INIT('colors', function(next) {` | `CLINIT('colors', function(next) {` |\n\n`PUSH()` auf einen Path, der nicht existiert, benachrichtigt keinen Watcher, lege das Array also mit `SET()` an.\n\nDas dritte Argument von `CACHEPATH()` ist jetzt ein Standardwert, und die von jComponent 19 gespeicherten Werte werden nicht gelesen:\n\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n```\n\n## Komponenten und Funktionen aufrufen\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `RECONFIGURE('box', 'size:2');` | `SETTER('box/reconfigure', 'size:2');` |\n| `RETURN('box/name')` | `FIND('box').name` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `EXEC(true, 'FUNC.start', 'now');` | `EXEC('FUNC.start @important', 'now');` |\n| `AEXEC('FUNC.save', 1)` | `() => EXEC('FUNC.save', 1)` |\n| `ADD('box__user.name', '#panel');` | `$('#panel').append('<ui-component name=\"box\" path=\"user.name\"></ui-component>');` |\n\n## Markup-Attribute\n\nDie Attributformen werden ohne Fehler ignoriert, und die Elemente bleiben leer. Verwende die Custom Elements, die in [Komponenten verwenden](../using-components/) und [Datenbindung](../data-binding/) beschrieben sind.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<span id=\"name\" data-bind=\"user.name__text\"></span>` | `<ui-bind id=\"name\" path=\"user.name\" config=\"text\"></ui-bind>` |\n| `<div id=\"box\" data-scope=\"panel\">` | `<ui-plugin id=\"box\" path=\"panel\">` |\n\n## Scopes und Plugins\n\nIn 20 gibt es kein Scope-Objekt. Ein `<ui-plugin>`-Element ist der Scope, und `$(selector).plugin()` gibt die Instanz zurück. Ein Element mit `?`-Paths außerhalb eines `<ui-plugin>` wird nicht gerendert. [Plugins](../plugins/) beschreibt das Plugin-Objekt.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `var scope = $('#panel').scope();` | `var plugin = $('#panel').plugin();` |\n| `console.log(scope.path); // invoice` | `console.log(plugin.path.toString()); // invoice` |\n| `scope.watch('number', function(path, value) {` | `plugin.watch('number', function(value, flags, path) {` |\n| `<ui-plugin path=\"address\">` verschachtelt in einem Plugin | `<ui-plugin path=\"?.address\">` |\n| `<ui-plugin path=\"!shared\">` | `<ui-plugin path=\"shared\">` |\n| `<ui-plugin path=\"login\" default=\"{ user: 'guest' }\">` | `exports.set('user', 'guest');` im Plugin |\n| `function loginready(path, element) {` | `function loginready(element) {` |\n| `config=\"text:?/format\"` | `config=\"text:PLUGINS.contact.format(value)\"` |\n\nEin verschachteltes `<ui-plugin>` erweitert den Path seines übergeordneten Plugins nicht mehr. Schreibe `?` in den Path, um das alte Ergebnis zu erhalten, sonst liest das Plugin einen globalen Path mit demselben Namen:\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-plugin path=\"?.address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n```\n\n**Ein Plugin braucht sein Element.** In 19 erzeugte `PLUGIN()` die Instanz von selbst. In 20 läuft der Callback nur, wenn ein `<ui-plugin>`-Element mit diesem Path existiert, ein Plugin ohne Element startet also nie:\n\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n```\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `exports.extend('filter', { page: 2 });` | `exports.set('filter', Object.assign(exports.get('filter'), { page: 2 }));` |\n| `PLUGINS.orders.reset();` | `RESET(PLUGINS.orders.path.toString());` |\n| `exports.api('/api/ orders_list', { page: 1 }, function() {` | `API('/api/', 'orders_list', { page: 1 }, function() {` |\n| `console.log(exports.modified); // {\"city\":\"Prague\"}` | Der Code unten |\n\n`exports.modified` gibt das gesamte Modell zurück und setzt den Zustand der Komponenten zurück. Sammle die geänderten Felder vorher:\n\n```js\nvar changed = {};\nCOMPONENTS(exports.path + ' @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nRESET(exports.path.toString());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n## ui-bind-Befehle\n\nMehrere Befehle von `<ui-bind>` wurden entfernt, und die meisten davon werden ohne Fehler übersprungen. Der Ausdruck eines Befehls ist reines JavaScript, daher ersetzt ein Aufruf darin die meisten von ihnen. Die [ui-bind-Referenz](../../reference/ui-bind/) listet die Befehle von 20 auf.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `config=\"text;currency:eur\"` | `config=\"text:value.currency('eur')\"` |\n| `config=\"text;default:'none'\"` | `config=\"text:value == null ? 'none' : value\"` |\n| `config=\"text;helper:pluralize('no items','# item','# items','# items')\"` | `config=\"text:value.pluralize('no items','# item','# items','# items')\"` |\n| `config=\"text;selector:b\"` | `config=\"text\" child=\"b\"` |\n| `config=\"checked input\"` | `config=\"checked\"` |\n| `config=\"init:FUNC.start;text\"` | `config=\"exec:FUNC.start;text\"` |\n| `config=\"click:FUNC.open\"` | `<button id=\"a\" class=\"exec\" data-exec=\"FUNC.open\">Open</button>` |\n| `config=\"setter:'box/show',value\"` | `config=\"exec:FUNC.show\"` |\n| `config=\"config:'size:' + value\"` | `<ui-component name=\"box\" config=\"=size:ui.size\"></ui-component>` |\n\n**Der Wert `false` wird leer dargestellt**, wenn du den Befehl `text` verwendest. Wandle den Wert in einen String um:\n\n```html\n<ui-bind id=\"a\" path=\"order.count\" config=\"text:value + ''\"></ui-bind>\n```\n\n## Komponenten\n\nDer `path` einer Komponente ist jetzt ein Objekt. Ein Vergleich mit einem String ergibt `false`, und String-Methoden wie `split()` gibt es darauf nicht, wandle ihn also zuerst um. Das dritte Argument von `self.setter` ist statt einer Zahl ein Objekt mit Flags. [Komponenten erstellen](../creating-components/) beschreibt die Delegates.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `self.path === 'form.name'` | `self.path.toString() === 'form.name'` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `type === 0` | `flags.init` |\n| `self.notify();` | `self.upd();` |\n| `self.faicon('home')` | `self.icon('home')` |\n| `self.scopepath('user.age')` | `self.makepath('user.age')` |\n| `self.inc(2);` | `self.set(self.get() + 2);` |\n| `self.extend({ b: 2 });` | `self.set(Object.assign(self.get(), { b: 2 }));` |\n| `self.dirty()` | `!config.touched` |\n| `self.dirty(false);` | `self.touch();` |\n| `self.invalid();` | `self.reconfigure({ touched: 1, invalid: true });` |\n| `self.skip();` vor `self.set(2);` | `self.rewrite(2);` |\n| `self.main()` | `self.element.parent().component()` |\n| `self.exec('show', 1)` | `self.element.SETTER('*/show', 1)` |\n| `self.data('page', 2);` | Eine Variable innerhalb der Komponente |\n\nDie Argumente von `self.state(type, what)` haben in 20 andere Werte. Lies den Zustand aus `config`:\n\n```js\nself.state = function() {\n\tif (config.touched && config.modified && !changed) {\n\t\tchanged = true;\n\t\tconsole.log('changed');\n\t}\n};\n```\n\n`self.bindchanges()` wurde entfernt. Vergleiche den Wert im Setter:\n\n```js\nvar last;\nself.setter = function(value) {\n\tif (value !== last) {\n\t\tlast = value;\n\t\tconsole.log(value);\n\t}\n};\n```\n\n## Macros und virtuelle Bindungen\n\n`MACRO()`, der Befehl `macro`, `VBIND()`, `VBINDARRAY()` und der Befehl `vbindarray` wurden entfernt. Schreibe ein Macro als Komponente neu und eine virtuelle Bindung als `template`-Befehl mit [Tangular](../tangular/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `MACRO('clicks', function(self, element) {` | `COMPONENT('clicks', function(self) {` |\n| `config=\"macro:clicks\"` | `<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>` |\n| `VBIND('<div><b data-bind=\".name__text\"></b></div>')` | `config=\"template\"` |\n| `VBINDARRAY('<li data-bind=\".name__text\"></li>', '#list')` | `config=\"template\"` |\n| `config=\"vbindarray\"` | `config=\"template\"` |\n\n```html\n<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>\n```\n\n```js\nCOMPONENT('clicks', function(self) {\n\tself.make = function() {\n\t\tself.event('click', () => self.set((self.get() || 0) + 1));\n\t};\n\tself.setter = function(value) {\n\t\tself.text('Clicked ' + (value || 0));\n\t};\n});\n```\n\nEine Liste, die `VBINDARRAY()` verwendet hat, wird zu einem Template:\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"rows\" config=\"template\">\n\t\t<script type=\"text/html\">{{ foreach m in value }}<li>{{ m.name }}</li>{{ end }}</script>\n\t</ui-bind>\n</ul>\n```\n\n## Das M-Objekt\n\n`M` gibt es weiterhin, und es ist dasselbe Objekt wie `jComponent` und `MAIN`. `M.version`, `M.components` und `M.binders` funktionieren wie bisher. Die Methoden, die das Modell geändert haben, wurden entfernt oder erwarten andere Argumente, verwende also die globalen Funktionen.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `M.set('user.name', 'Ann');` | `SET('user.name', 'Ann');` |\n| `M.inc('user.age', 2);` | `INC('user.age', 2);` |\n| `M.push('user.tags', 'new');` | `PUSH('user.tags', 'new');` |\n\n## AJAX und APIs\n\nDer Callback von `AJAX()` erhält nur noch die Antwort, und `AJAX()` gibt kein Promise mehr zurück. Die Referenz [Globale Funktionen](../../reference/globals/) beschreibt `AJAX()`.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n| `AJAX('GET /orders/').then(function(response) {` | `new Promise(resolve => AJAX('GET /orders/', resolve)).then(function(response) {` |\n| `AJAX('GET /orders/ error', () => console.log('callback'));` | `AJAX('GET /orders/ ERROR', () => console.log('callback'));` |\n| `AJAX('GET /orders/ {\"X-Token\":\"abc\"}', function() {` | `ON('request', opt => opt.headers['X-Token'] = 'abc');` |\n| `AJAXCONFIG('secure', function(options) {` | `ON('request', function(options) {` |\n| `AJAXCACHE('GET /orders/', null, NOOP, '1 minute');` | `AJAX('GET /orders/ <1 minute>', NOOP);` |\n| `AJAX('GET /orders/', null, 'orders', 100);` | `setTimeout(() => AJAX('GET /orders/', 'orders'), 100);` |\n| `API('/api/ users_save', { name: 'Ann' }, function() {` | `API('/api/', 'users_save', { name: 'Ann' }, function() {` |\n| `DAPI('users_save', { name: 'Ann' }, function() {` | `TAPI('users_save', { name: 'Ann' }, function() {` |\n\nUm den Statuscode einer Antwort zu lesen, registriere dich vor der Anfrage auf das Ereignis `response`:\n\n```js\nvar status = 0;\n\nON('response', opt => status = opt.status);\n\nAJAX('GET /orders/', function(response) {\n\tconsole.log(response.error, status); // denied 403\n});\n```\n\n## Einstellungen\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `DEF.validators.email` | `DEF.regexp.email` |\n| `DEF.pathcommon` | `DEF.path.common` |\n| `DEF.pathcl` | `DEF.path.cl` |\n| `DEF.environment` | `DEF.env` |\n| `DEF.languagehtml = 'sk';` | `DEF.language = 'sk';` |\n\nDiese Einstellungen gibt es nicht mehr: `ajaxcredentials`, `ajaxcredentialshtml`, `ajaxerrors`, `customelements`, `delay`, `delaybinder`, `delaykeypress`, `delaypref`, `delayrepeat`, `delaywatcher`, `fallbackcache`, `importcache`, `jsoncompress`, `jsonconverter`, `jsondate`, `keypress`, `makeurl`, `monitor`, `prefixcssmacros`, `repeatfocus`, `scope`, `secret` und `versioncomponents`. Die Referenz [DEF](../../reference/def/) listet die Einstellungen von 20 auf.\n\n## Ereignisse\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `ON('destroy', name => console.log('removed', name));` | `self.destroy = () => console.log('removed', self.name);` |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nDas Ereignis `exec` wird nicht mehr ausgelöst. `WW` und `WH` werden erst gesetzt, wenn die Bibliothek startet, lies sie also innerhalb von `ON('ready', ...)`. Die Referenz [Ereignisse](../../reference/events/) listet die Ereignisse von 20 auf.\n\n## jQuery-Helper\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `$('#panel').components()` | `$('#panel').COMPONENTS()` |\n| `$('#panel').FIND('box')` | `$('#panel').COMPONENTS().findItem('name', 'box')` |\n| `$('#panel').RECONFIGURE('box', 'size:2');` | `$('#panel').SETTER('box/reconfigure', 'size:2');` |\n| `$('#panel').EMIT('hello', 1);` | `EMIT('hello', 1);` |\n\n## Helper für Strings, Zahlen, Datumswerte und Arrays\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `'Hello {name}'.arg({ name: 'Ann' })` | `'Hello {name}'.args({ name: 'Ann' })` |\n| `'{{ name }}'.render({ name: 'Ann' })` | `Tangular.render('{{ name }}', { name: 'Ann' })` |\n| `'<b>Ann</b>'.removeTags()` | `'<b>Ann</b>'.replace(/<[^>]*>/g, '')` |\n| `'a=1&b=2'.parseEncoded()` | `Object.fromEntries(new URLSearchParams('a=1&b=2'))` |\n| `new Date(2026, 0, 5).toNumber()` | `+new Date(2026, 0, 5).format('yyyyMMdd')` |\n| `new Date(2026, 0, 5).parseDate()` | `new Date(2026, 0, 5)` |\n| `(5).between({ 1: 'low', 10: 'high' })` | `value < 10 ? 'low' : 'high'` |\n| `tasks.async(() => console.log('done'));` | `tasks.wait((task, next) => task(next), () => console.log('done'));` |\n\n`String.parseConfig()` akzeptiert keinen Callback mehr und ignoriert ihn ohne Fehler. Durchlaufe stattdessen das zurückgegebene Objekt:\n\n```js\nvar config = 'size:2;open:true'.parseConfig();\n\nfor (var key in config)\n\tconsole.log(key, config[key]);\n```\n\n## Funktionen ohne Ersatz\n\nDiese globalen Funktionen wurden entfernt, und 20.015 hat keine direkte Entsprechung.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WAPI`, `WAPI_INIT`, `AJAXCACHEREVIEW` | Kein Ersatz |\n| `DEBUG`, `STOPDEBUG` | Kein Ersatz |\n| `QUEUE`, `REPEAT`, `WORKFLOW` | Kein Ersatz |\n| `PLUGINABLE`, `VERSION`, `IMPORTCACHE` | Kein Ersatz |\n| `CLEARCACHE`, `REWRITE`, `REWRITE2`, `NOTMODIFIED`, `BIND`, `OPT` | Kein Ersatz |\n\n## Ein vollständiges Formular\n\nDieses Formular hat zwei Pflichtfelder und eine Schaltfläche, die aktiviert wird, sobald das Formular gültig ist. Beide Versionen verhalten sich gleich: Das erste Speichern meldet die beiden ungültigen Paths, und ein Speichern mit ausgefüllten Feldern gibt das Modell zurück.\n\nVorher, in jComponent 19:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.validators.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" data-jc-bind />');\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nWATCH('form.*', function(path, value, type) {\n\t$('#save').prop('disabled', DISABLED('form.*'));\n});\n\nfunction save() {\n\n\tCHANGE('form.*');\n\n\tif (!VALID('form.*')) {\n\t\tconsole.log(ERRORS('form.*').map(com => com.path));\n\t\treturn;\n\t}\n\n\tconsole.log(GET('form @reset'));\n}\n</script>\n```\n\nNachher, in jComponent 20:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.regexp.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n\nWATCH('form', function(value, flags, path) {\n\t$('#save').prop('disabled', !can('form'));\n});\n\nfunction save() {\n\n\tUPD('form @change');\n\n\tERRORS('form', function(list) {\n\n\t\tif (list.length) {\n\t\t\tconsole.log(list.map(com => com.path.toString()));\n\t\t\treturn;\n\t\t}\n\n\t\tconsole.log(GET('form @reset'));\n\t});\n}\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JanEc21ew61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/migrating-from-v19/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Migrar desde jComponent 19","summary":"Sustituye cada API eliminada o modificada de jComponent 19 por su equivalente en jComponent 20, incluidos los cambios que fallan sin dar ningún error.","markdown":"---\ntitle: Migrar desde jComponent 19\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/migrating-from-v19/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# Migrar desde jComponent 19\n\n> Sustituye cada API eliminada o modificada de jComponent 19 por su equivalente en jComponent 20, incluidos los cambios que fallan sin dar ningún error.\n\nEsta guía lleva una aplicación de jComponent 19 a jComponent 20.015. Muestra el sustituto de cada función, atributo y ajuste que se ha eliminado o modificado, y señala los cambios que no dan ningún error en la consola del navegador, porque son los que se escapan en una prueba rápida.\n\n## Actualiza los archivos del CDN\n\nSustituye los dos archivos. El paquete sigue incluyendo jQuery, Tangular y las funciones de enrutamiento, así que no hace falta cargar nada más.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `https://cdn.componentator.com/spa.min@19.js` | `https://cdn.componentator.com/spa.min@20.js` |\n| `https://cdn.componentator.com/spa.min@19.css` | `https://cdn.componentator.com/spa.min@20.css` |\n\n## Orden de trabajo recomendado\n\n1. Sustituye los archivos del CDN y abre la aplicación con la consola del navegador visible.\n2. Cambia primero el marcado: los elementos `data---`, `data-bind` y `data-scope` se ignoran, así que no puedes probar nada más hasta convertirlos.\n3. Busca en el código los patrones de [Cambios que fallan en silencio](#changes-that-fail-silently) y corrígelos. La consola no te los señala.\n4. Corrige los errores que indica la consola, como `VALID is not defined` o `$(...).scope is not a function`.\n5. Adapta los formularios y prueba cada uno a mano: vacío, no válido, válido y después de un reinicio.\n6. Prueba las pantallas que cargan datos, porque los callbacks de AJAX reciben menos argumentos.\n\n## Cambios que fallan en silencio\n\nCada uno de estos casos se ejecuta sin errores en 20.015 y hace algo incorrecto. Busca en tu código lo que aparece en la columna izquierda.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `RESET('form.*');` | `RESET('form');` |\n| `GET('form @modified')` | `COMPONENTS('form @modified')` |\n| `return value; // a non-empty string means valid` | `return !!value;` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<ui-plugin path=\"address\">` | `<ui-plugin path=\"?.address\">` |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n\nUna declaración `PLUGIN()` sin un elemento `<ui-plugin>` también deja de ejecutarse. Consulta [Scopes y plugins](#scopes-and-plugins).\n\n## Formularios y validación\n\n`VALID()`, `CAN()`, `DISABLED()`, `INVALID()`, `CHANGE()`, `MODIFIED()` y `DEFAULT()` se han eliminado. Lee el estado de un formulario con `COMPONENTS()` y `ERRORS()`, y cámbialo con flags. [Formularios y validación](../forms/) describe la nueva forma de trabajar.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `VALID('form.*')` | `COMPONENTS('form @invalid').length === 0` |\n| `CAN('form.*')` | `can('form')` (la función de más abajo) |\n| `DISABLED('form.*')` | `!can('form')` |\n| `ERRORS('form.*')` | `ERRORS('form @touched', list => console.log(list.length))` |\n| `CHANGE('form.*');` | `UPD('form @change');` |\n| `CHANGE('form.*', false);` | `RESET('form');` |\n| `MODIFIED('form.*')` | `COMPONENTS('form @modified').map(com => com.path.toString())` |\n| `DEFAULT('filter.*');` | `SET('filter @default', {});` |\n| `INVALID('form.name');` | `COMPONENTS('form.name').forEach(com => com.reconfigure({ touched: 1, invalid: true }));` |\n| `RESET('form.*');` | `RESET('form');` |\n\n`CAN()` no tiene un sustituto directo, así que mantén una pequeña función en tu aplicación:\n\n```js\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n```\n\n**`ERRORS()` recibe un callback.** Sin él lanza `r is not a function`. En 19 devolvía los campos tocados y no válidos. En 20 pasa todos los campos no válidos, así que añade el flag `@touched` para conservar el resultado anterior:\n\n```js\nERRORS('form @touched', list => console.log(list.length)); // 0\nSET('form.name @change', '');\nERRORS('form @touched', list => console.log(list.map(com => com.path.toString()))); // [\"form.name\"]\n```\n\n**Los paths ya no admiten `.*`.** No coincide con nada y no se muestra ningún error. `ERRORS()` indica entonces que un formulario roto es válido:\n\n```js\nERRORS('form.*', list => console.log(list.length)); // 0\nERRORS('form', list => console.log(list.length)); // 1\n```\n\n**`GET('form @modified')` devuelve el modelo completo** en 20. Recoge tú mismo los campos modificados:\n\n```js\nSET('form.city @change', 'Prague');\n\nvar changed = {};\nCOMPONENTS('form @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n**El resultado de `self.validate` se interpreta de otra manera.** En 19, cualquier valor truthy era válido. En 20, una cadena no vacía es un mensaje de error, así que un validador que devuelve el valor marca como no válido un campo relleno. Un número como `value.length` tampoco es válido. Devuelve un booleano:\n\n```js\nself.validate = function(value) {\n\treturn !!value;\n};\n```\n\n```js\nself.validate = function(value) {\n\treturn value.length > 0;\n};\n```\n\n`self.validate` también ha perdido su segundo argumento, `init`. Mantén tu propio flag cuando la primera ejecución necesite un tratamiento distinto:\n\n```js\nCOMPONENT('field', function(self, config) {\n\tvar init = true;\n\tself.validate = function(value) {\n\t\tconsole.log(init);\n\t\tinit = false;\n\t\treturn true;\n\t};\n});\n```\n\n### Enlazar un input\n\nEl atributo `data-jc-bind` se ignora, así que el input no escribe en el modelo. Llama a `self.autobind20()` una vez que exista el HTML:\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n```\n\nLas funciones globales `FORMATTER()` y `PARSER()` se han eliminado. Regístralas en el componente:\n\n```js\nself.formatter(function(path, value) {\n\treturn value ? value.toUpperCase() : value;\n});\n```\n\n```js\nself.parser(function(path, value) {\n\treturn value ? value.toLowerCase() : value;\n});\n```\n\n## Observadores y paths\n\nLos argumentos de un observador han cambiado de orden, y el código sigue ejecutándose con los valores equivocados. [Paths](../paths/) describe los observadores en 20.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `self.watch('user.name', function(path, value, type) {` | `self.watch('user.name', function(value, flags, path) {` |\n| `exports.watch('count', function(value, path, type) {` | `exports.watch('count', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `WATCHONCE('user.name', function(path, value) {` | `UNWATCH('user.name', once);` dentro del callback |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nUn observador en un path padre también se ejecuta para los paths que hay debajo, así que `WATCH('user', ...)` sustituye al comodín.\n\n## Escribir en el modelo\n\nEl tercer argumento de `SET()` se ha eliminado. Un retardo o un flag de reinicio pasado ahí se ignora, y el valor se escribe de inmediato.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `PUSH('cart.items', 'tea');` en un path inexistente | `SET('cart.items', ['tea']);` |\n| `NOTIFY('user.name');` | `UPD('user.name');` |\n| `EXT('user', { age: 30 });` | `SET('user', Object.assign(GET('user'), { age: 30 }));` |\n| `MAKE(function(obj) {` | Un objeto simple |\n| `EVALUATE('user.age', 'value >= 18')` | `FN('value => value >= 18')(GET('user.age'))` |\n| `REMOVECACHE('token');` | `CACHE('token', null, '1 day');` |\n| `CL_INIT('colors', function(next) {` | `CLINIT('colors', function(next) {` |\n\n`PUSH()` sobre un path que no existe no notifica a ningún observador, así que crea el array con `SET()`.\n\nEl tercer argumento de `CACHEPATH()` ahora es un valor predeterminado, y los valores guardados por jComponent 19 no se leen:\n\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n```\n\n## Llamar a componentes y funciones\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `RECONFIGURE('box', 'size:2');` | `SETTER('box/reconfigure', 'size:2');` |\n| `RETURN('box/name')` | `FIND('box').name` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `EXEC(true, 'FUNC.start', 'now');` | `EXEC('FUNC.start @important', 'now');` |\n| `AEXEC('FUNC.save', 1)` | `() => EXEC('FUNC.save', 1)` |\n| `ADD('box__user.name', '#panel');` | `$('#panel').append('<ui-component name=\"box\" path=\"user.name\"></ui-component>');` |\n\n## Atributos de marcado\n\nLas formas con atributos se ignoran sin dar error, y los elementos quedan vacíos. Usa los elementos personalizados descritos en [Uso de componentes](../using-components/) y [Enlace de datos](../data-binding/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<span id=\"name\" data-bind=\"user.name__text\"></span>` | `<ui-bind id=\"name\" path=\"user.name\" config=\"text\"></ui-bind>` |\n| `<div id=\"box\" data-scope=\"panel\">` | `<ui-plugin id=\"box\" path=\"panel\">` |\n\n## Scopes y plugins\n\nEn 20 no hay objeto scope. Un elemento `<ui-plugin>` es el scope, y `$(selector).plugin()` devuelve la instancia. Un elemento con paths `?` fuera de un `<ui-plugin>` no se renderiza. [Plugins](../plugins/) describe el objeto plugin.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `var scope = $('#panel').scope();` | `var plugin = $('#panel').plugin();` |\n| `console.log(scope.path); // invoice` | `console.log(plugin.path.toString()); // invoice` |\n| `scope.watch('number', function(path, value) {` | `plugin.watch('number', function(value, flags, path) {` |\n| `<ui-plugin path=\"address\">` anidado en un plugin | `<ui-plugin path=\"?.address\">` |\n| `<ui-plugin path=\"!shared\">` | `<ui-plugin path=\"shared\">` |\n| `<ui-plugin path=\"login\" default=\"{ user: 'guest' }\">` | `exports.set('user', 'guest');` en el plugin |\n| `function loginready(path, element) {` | `function loginready(element) {` |\n| `config=\"text:?/format\"` | `config=\"text:PLUGINS.contact.format(value)\"` |\n\nUn `<ui-plugin>` anidado ya no amplía el path de su padre. Escribe `?` en el path para obtener el resultado anterior; si no, el plugin lee un path global con el mismo nombre:\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-plugin path=\"?.address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n```\n\n**Un plugin necesita su elemento.** En 19, `PLUGIN()` creaba la instancia por sí solo. En 20, el callback solo se ejecuta cuando existe un elemento `<ui-plugin>` con ese path, así que un plugin sin elemento nunca arranca:\n\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n```\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `exports.extend('filter', { page: 2 });` | `exports.set('filter', Object.assign(exports.get('filter'), { page: 2 }));` |\n| `PLUGINS.orders.reset();` | `RESET(PLUGINS.orders.path.toString());` |\n| `exports.api('/api/ orders_list', { page: 1 }, function() {` | `API('/api/', 'orders_list', { page: 1 }, function() {` |\n| `console.log(exports.modified); // {\"city\":\"Prague\"}` | El código de más abajo |\n\n`exports.modified` devuelve el modelo completo y borra el estado de los componentes. Recoge antes los campos modificados:\n\n```js\nvar changed = {};\nCOMPONENTS(exports.path + ' @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nRESET(exports.path.toString());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n## Comandos de ui-bind\n\nSe han eliminado varios comandos de `<ui-bind>`, y la mayoría se omiten sin dar error. La expresión de un comando es JavaScript normal, así que una llamada dentro de ella sustituye a casi todos. La [referencia de ui-bind](../../reference/ui-bind/) enumera los comandos de 20.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `config=\"text;currency:eur\"` | `config=\"text:value.currency('eur')\"` |\n| `config=\"text;default:'none'\"` | `config=\"text:value == null ? 'none' : value\"` |\n| `config=\"text;helper:pluralize('no items','# item','# items','# items')\"` | `config=\"text:value.pluralize('no items','# item','# items','# items')\"` |\n| `config=\"text;selector:b\"` | `config=\"text\" child=\"b\"` |\n| `config=\"checked input\"` | `config=\"checked\"` |\n| `config=\"init:FUNC.start;text\"` | `config=\"exec:FUNC.start;text\"` |\n| `config=\"click:FUNC.open\"` | `<button id=\"a\" class=\"exec\" data-exec=\"FUNC.open\">Open</button>` |\n| `config=\"setter:'box/show',value\"` | `config=\"exec:FUNC.show\"` |\n| `config=\"config:'size:' + value\"` | `<ui-component name=\"box\" config=\"=size:ui.size\"></ui-component>` |\n\n**El valor `false` se renderiza vacío** con el comando `text`. Convierte el valor en una cadena:\n\n```html\n<ui-bind id=\"a\" path=\"order.count\" config=\"text:value + ''\"></ui-bind>\n```\n\n## Componentes\n\nEl `path` de un componente ahora es un objeto. Compararlo con una cadena da `false`, y no tiene métodos de cadena como `split()`, así que conviértelo primero. El tercer argumento de `self.setter` es un objeto con flags en lugar de un número. [Creación de componentes](../creating-components/) describe los delegates.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `self.path === 'form.name'` | `self.path.toString() === 'form.name'` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `type === 0` | `flags.init` |\n| `self.notify();` | `self.upd();` |\n| `self.faicon('home')` | `self.icon('home')` |\n| `self.scopepath('user.age')` | `self.makepath('user.age')` |\n| `self.inc(2);` | `self.set(self.get() + 2);` |\n| `self.extend({ b: 2 });` | `self.set(Object.assign(self.get(), { b: 2 }));` |\n| `self.dirty()` | `!config.touched` |\n| `self.dirty(false);` | `self.touch();` |\n| `self.invalid();` | `self.reconfigure({ touched: 1, invalid: true });` |\n| `self.skip();` antes de `self.set(2);` | `self.rewrite(2);` |\n| `self.main()` | `self.element.parent().component()` |\n| `self.exec('show', 1)` | `self.element.SETTER('*/show', 1)` |\n| `self.data('page', 2);` | Una variable dentro del componente |\n\nLos argumentos de `self.state(type, what)` tienen valores distintos en 20. Lee el estado desde `config`:\n\n```js\nself.state = function() {\n\tif (config.touched && config.modified && !changed) {\n\t\tchanged = true;\n\t\tconsole.log('changed');\n\t}\n};\n```\n\n`self.bindchanges()` se ha eliminado. Compara el valor en el setter:\n\n```js\nvar last;\nself.setter = function(value) {\n\tif (value !== last) {\n\t\tlast = value;\n\t\tconsole.log(value);\n\t}\n};\n```\n\n## Macros y enlaces virtuales\n\n`MACRO()`, el comando `macro`, `VBIND()`, `VBINDARRAY()` y el comando `vbindarray` se han eliminado. Reescribe cada macro como un componente y cada enlace virtual como un comando `template` con [Tangular](../tangular/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `MACRO('clicks', function(self, element) {` | `COMPONENT('clicks', function(self) {` |\n| `config=\"macro:clicks\"` | `<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>` |\n| `VBIND('<div><b data-bind=\".name__text\"></b></div>')` | `config=\"template\"` |\n| `VBINDARRAY('<li data-bind=\".name__text\"></li>', '#list')` | `config=\"template\"` |\n| `config=\"vbindarray\"` | `config=\"template\"` |\n\n```html\n<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>\n```\n\n```js\nCOMPONENT('clicks', function(self) {\n\tself.make = function() {\n\t\tself.event('click', () => self.set((self.get() || 0) + 1));\n\t};\n\tself.setter = function(value) {\n\t\tself.text('Clicked ' + (value || 0));\n\t};\n});\n```\n\nUna lista que usaba `VBINDARRAY()` se convierte en una plantilla:\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"rows\" config=\"template\">\n\t\t<script type=\"text/html\">{{ foreach m in value }}<li>{{ m.name }}</li>{{ end }}</script>\n\t</ui-bind>\n</ul>\n```\n\n## El objeto M\n\n`M` sigue existiendo y es el mismo objeto que `jComponent` y `MAIN`. `M.version`, `M.components` y `M.binders` funcionan como antes. Los métodos que modificaban el modelo se han eliminado o reciben otros argumentos, así que usa las funciones globales.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `M.set('user.name', 'Ann');` | `SET('user.name', 'Ann');` |\n| `M.inc('user.age', 2);` | `INC('user.age', 2);` |\n| `M.push('user.tags', 'new');` | `PUSH('user.tags', 'new');` |\n\n## AJAX y API\n\nEl callback de `AJAX()` solo recibe la respuesta, y `AJAX()` ya no devuelve una Promise. La referencia de [Funciones globales](../../reference/globals/) describe `AJAX()`.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n| `AJAX('GET /orders/').then(function(response) {` | `new Promise(resolve => AJAX('GET /orders/', resolve)).then(function(response) {` |\n| `AJAX('GET /orders/ error', () => console.log('callback'));` | `AJAX('GET /orders/ ERROR', () => console.log('callback'));` |\n| `AJAX('GET /orders/ {\"X-Token\":\"abc\"}', function() {` | `ON('request', opt => opt.headers['X-Token'] = 'abc');` |\n| `AJAXCONFIG('secure', function(options) {` | `ON('request', function(options) {` |\n| `AJAXCACHE('GET /orders/', null, NOOP, '1 minute');` | `AJAX('GET /orders/ <1 minute>', NOOP);` |\n| `AJAX('GET /orders/', null, 'orders', 100);` | `setTimeout(() => AJAX('GET /orders/', 'orders'), 100);` |\n| `API('/api/ users_save', { name: 'Ann' }, function() {` | `API('/api/', 'users_save', { name: 'Ann' }, function() {` |\n| `DAPI('users_save', { name: 'Ann' }, function() {` | `TAPI('users_save', { name: 'Ann' }, function() {` |\n\nPara leer el código de estado de una respuesta, escucha el evento `response` antes de la petición:\n\n```js\nvar status = 0;\n\nON('response', opt => status = opt.status);\n\nAJAX('GET /orders/', function(response) {\n\tconsole.log(response.error, status); // denied 403\n});\n```\n\n## Ajustes\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `DEF.validators.email` | `DEF.regexp.email` |\n| `DEF.pathcommon` | `DEF.path.common` |\n| `DEF.pathcl` | `DEF.path.cl` |\n| `DEF.environment` | `DEF.env` |\n| `DEF.languagehtml = 'sk';` | `DEF.language = 'sk';` |\n\nEstos ajustes ya no existen: `ajaxcredentials`, `ajaxcredentialshtml`, `ajaxerrors`, `customelements`, `delay`, `delaybinder`, `delaykeypress`, `delaypref`, `delayrepeat`, `delaywatcher`, `fallbackcache`, `importcache`, `jsoncompress`, `jsonconverter`, `jsondate`, `keypress`, `makeurl`, `monitor`, `prefixcssmacros`, `repeatfocus`, `scope`, `secret` y `versioncomponents`. La referencia de [DEF](../../reference/def/) enumera los ajustes de 20.\n\n## Eventos\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `ON('destroy', name => console.log('removed', name));` | `self.destroy = () => console.log('removed', self.name);` |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nEl evento `exec` ya no se emite. `WW` y `WH` no se establecen hasta que arranca la biblioteca, así que léelos dentro de `ON('ready', ...)`. La referencia de [Eventos](../../reference/events/) enumera los eventos de 20.\n\n## Helpers de jQuery\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `$('#panel').components()` | `$('#panel').COMPONENTS()` |\n| `$('#panel').FIND('box')` | `$('#panel').COMPONENTS().findItem('name', 'box')` |\n| `$('#panel').RECONFIGURE('box', 'size:2');` | `$('#panel').SETTER('box/reconfigure', 'size:2');` |\n| `$('#panel').EMIT('hello', 1);` | `EMIT('hello', 1);` |\n\n## Helpers de cadenas, números, fechas y arrays\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `'Hello {name}'.arg({ name: 'Ann' })` | `'Hello {name}'.args({ name: 'Ann' })` |\n| `'{{ name }}'.render({ name: 'Ann' })` | `Tangular.render('{{ name }}', { name: 'Ann' })` |\n| `'<b>Ann</b>'.removeTags()` | `'<b>Ann</b>'.replace(/<[^>]*>/g, '')` |\n| `'a=1&b=2'.parseEncoded()` | `Object.fromEntries(new URLSearchParams('a=1&b=2'))` |\n| `new Date(2026, 0, 5).toNumber()` | `+new Date(2026, 0, 5).format('yyyyMMdd')` |\n| `new Date(2026, 0, 5).parseDate()` | `new Date(2026, 0, 5)` |\n| `(5).between({ 1: 'low', 10: 'high' })` | `value < 10 ? 'low' : 'high'` |\n| `tasks.async(() => console.log('done'));` | `tasks.wait((task, next) => task(next), () => console.log('done'));` |\n\n`String.parseConfig()` ya no acepta un callback y, si le pasas uno, lo ignora sin dar error. Recorre el objeto devuelto:\n\n```js\nvar config = 'size:2;open:true'.parseConfig();\n\nfor (var key in config)\n\tconsole.log(key, config[key]);\n```\n\n## Funciones sin sustituto\n\nEstas funciones globales se han eliminado y 20.015 no tiene un equivalente directo.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WAPI`, `WAPI_INIT`, `AJAXCACHEREVIEW` | Sin sustituto |\n| `DEBUG`, `STOPDEBUG` | Sin sustituto |\n| `QUEUE`, `REPEAT`, `WORKFLOW` | Sin sustituto |\n| `PLUGINABLE`, `VERSION`, `IMPORTCACHE` | Sin sustituto |\n| `CLEARCACHE`, `REWRITE`, `REWRITE2`, `NOTMODIFIED`, `BIND`, `OPT` | Sin sustituto |\n\n## Un formulario completo\n\nEste formulario tiene dos campos obligatorios y un botón que se activa cuando el formulario es válido. Las dos versiones se comportan igual: el primer guardado indica los dos paths no válidos, y un guardado con los campos rellenos devuelve el modelo.\n\nAntes, en jComponent 19:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.validators.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" data-jc-bind />');\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nWATCH('form.*', function(path, value, type) {\n\t$('#save').prop('disabled', DISABLED('form.*'));\n});\n\nfunction save() {\n\n\tCHANGE('form.*');\n\n\tif (!VALID('form.*')) {\n\t\tconsole.log(ERRORS('form.*').map(com => com.path));\n\t\treturn;\n\t}\n\n\tconsole.log(GET('form @reset'));\n}\n</script>\n```\n\nDespués, en jComponent 20:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.regexp.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n\nWATCH('form', function(value, flags, path) {\n\t$('#save').prop('disabled', !can('form'));\n});\n\nfunction save() {\n\n\tUPD('form @change');\n\n\tERRORS('form', function(list) {\n\n\t\tif (list.length) {\n\t\t\tconsole.log(list.map(com => com.path.toString()));\n\t\t\treturn;\n\t\t}\n\n\t\tconsole.log(GET('form @reset'));\n\t});\n}\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JanEc21ew61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/migrating-from-v19/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Migrer depuis jComponent 19","summary":"Remplace chaque API de jComponent 19 supprimée ou modifiée par son équivalent dans jComponent 20, y compris les changements qui échouent sans erreur.","markdown":"---\ntitle: Migrer depuis jComponent 19\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/migrating-from-v19/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# Migrer depuis jComponent 19\n\n> Remplace chaque API de jComponent 19 supprimée ou modifiée par son équivalent dans jComponent 20, y compris les changements qui échouent sans erreur.\n\nCe guide fait passer une application de jComponent 19 à jComponent 20.015. Il montre le remplacement de chaque fonction, attribut et paramètre supprimé ou modifié, et signale les changements qui ne produisent aucune erreur dans la console du navigateur, car ce sont ceux qu'un test rapide laisse passer.\n\n## Mettre à jour les fichiers du CDN\n\nRemplace les deux fichiers. Le bundle contient toujours jQuery, Tangular et les fonctions de routage : tu n'as donc rien d'autre à charger.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `https://cdn.componentator.com/spa.min@19.js` | `https://cdn.componentator.com/spa.min@20.js` |\n| `https://cdn.componentator.com/spa.min@19.css` | `https://cdn.componentator.com/spa.min@20.css` |\n\n## Ordre de travail recommandé\n\n1. Remplace les fichiers du CDN et ouvre l'application avec la console du navigateur visible.\n2. Change d'abord le balisage : les éléments `data---`, `data-bind` et `data-scope` sont ignorés, donc tu ne peux rien tester d'autre tant qu'ils ne sont pas convertis.\n3. Cherche dans le code les motifs de [Changements qui échouent silencieusement](#changes-that-fail-silently) et corrige-les. La console ne te les signale pas.\n4. Corrige les erreurs signalées par la console, comme `VALID is not defined` ou `$(...).scope is not a function`.\n5. Porte les formulaires, puis teste chaque formulaire à la main : vide, invalide, valide et après une réinitialisation.\n6. Teste les écrans qui chargent des données, car les callbacks AJAX reçoivent moins d'arguments.\n\n## Changements qui échouent silencieusement\n\nChacun de ces cas s'exécute sans erreur en 20.015 et produit un mauvais résultat. Cherche dans ton code ce qui figure dans la colonne de gauche.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `RESET('form.*');` | `RESET('form');` |\n| `GET('form @modified')` | `COMPONENTS('form @modified')` |\n| `return value; // a non-empty string means valid` | `return !!value;` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<ui-plugin path=\"address\">` | `<ui-plugin path=\"?.address\">` |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n\nUne déclaration `PLUGIN()` sans élément `<ui-plugin>` cesse elle aussi de s'exécuter. Consulte [Scopes et plugins](#scopes-and-plugins).\n\n## Formulaires et validation\n\n`VALID()`, `CAN()`, `DISABLED()`, `INVALID()`, `CHANGE()`, `MODIFIED()` et `DEFAULT()` ont été supprimées. Lis l'état d'un formulaire avec `COMPONENTS()` et `ERRORS()`, et modifie-le avec des flags. [Formulaires et validation](../forms/) décrit la nouvelle façon de travailler.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `VALID('form.*')` | `COMPONENTS('form @invalid').length === 0` |\n| `CAN('form.*')` | `can('form')` (la fonction ci-dessous) |\n| `DISABLED('form.*')` | `!can('form')` |\n| `ERRORS('form.*')` | `ERRORS('form @touched', list => console.log(list.length))` |\n| `CHANGE('form.*');` | `UPD('form @change');` |\n| `CHANGE('form.*', false);` | `RESET('form');` |\n| `MODIFIED('form.*')` | `COMPONENTS('form @modified').map(com => com.path.toString())` |\n| `DEFAULT('filter.*');` | `SET('filter @default', {});` |\n| `INVALID('form.name');` | `COMPONENTS('form.name').forEach(com => com.reconfigure({ touched: 1, invalid: true }));` |\n| `RESET('form.*');` | `RESET('form');` |\n\n`CAN()` n'a pas de remplacement direct : garde donc une petite fonction dans ton application :\n\n```js\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n```\n\n**`ERRORS()` prend un callback.** Sans callback, elle lève `r is not a function`. En 19, elle renvoyait les champs touchés et invalides. En 20, elle transmet tous les champs invalides : ajoute donc le flag `@touched` pour conserver l'ancien résultat :\n\n```js\nERRORS('form @touched', list => console.log(list.length)); // 0\nSET('form.name @change', '');\nERRORS('form @touched', list => console.log(list.map(com => com.path.toString()))); // [\"form.name\"]\n```\n\n**Les paths n'acceptent plus `.*`.** Cette forme ne correspond à rien, et aucune erreur ne s'affiche. `ERRORS()` signale alors un formulaire incorrect comme valide :\n\n```js\nERRORS('form.*', list => console.log(list.length)); // 0\nERRORS('form', list => console.log(list.length)); // 1\n```\n\n**`GET('form @modified')` renvoie tout le modèle de données** en 20. Récupère toi-même les champs modifiés :\n\n```js\nSET('form.city @change', 'Prague');\n\nvar changed = {};\nCOMPONENTS('form @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n**Le résultat de `self.validate` est interprété différemment.** En 19, toute valeur évaluée comme vraie était valide. En 20, une chaîne non vide est un message d'erreur : un validateur qui renvoie la valeur marque donc un champ rempli comme invalide. Un nombre comme `value.length` est lui aussi invalide. Renvoie un booléen :\n\n```js\nself.validate = function(value) {\n\treturn !!value;\n};\n```\n\n```js\nself.validate = function(value) {\n\treturn value.length > 0;\n};\n```\n\n`self.validate` a aussi perdu son second argument, `init`. Garde ton propre flag lorsque la première exécution demande un traitement différent :\n\n```js\nCOMPONENT('field', function(self, config) {\n\tvar init = true;\n\tself.validate = function(value) {\n\t\tconsole.log(init);\n\t\tinit = false;\n\t\treturn true;\n\t};\n});\n```\n\n### Liaison d'un champ de saisie\n\nL'attribut `data-jc-bind` est ignoré : le champ de saisie n'écrit donc pas dans le modèle de données. Appelle `self.autobind20()` une fois le HTML en place :\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n```\n\nLes fonctions globales `FORMATTER()` et `PARSER()` ont été supprimées. Enregistre-les sur le composant :\n\n```js\nself.formatter(function(path, value) {\n\treturn value ? value.toUpperCase() : value;\n});\n```\n\n```js\nself.parser(function(path, value) {\n\treturn value ? value.toLowerCase() : value;\n});\n```\n\n## Observateurs et paths\n\nLes arguments d'un observateur ont changé d'ordre, et le code continue de s'exécuter avec de mauvaises valeurs. [Paths](../paths/) décrit les observateurs en 20.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `self.watch('user.name', function(path, value, type) {` | `self.watch('user.name', function(value, flags, path) {` |\n| `exports.watch('count', function(value, path, type) {` | `exports.watch('count', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `WATCHONCE('user.name', function(path, value) {` | `UNWATCH('user.name', once);` dans le callback |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nUn observateur placé sur un path parent s'exécute aussi pour les paths situés en dessous : `WATCH('user', ...)` remplace donc le caractère générique.\n\n## Écrire dans le modèle de données\n\nLe troisième argument de `SET()` a été supprimé. Un délai ou un flag de réinitialisation passé à cet endroit est ignoré, et la valeur est écrite immédiatement.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `PUSH('cart.items', 'tea');` sur un path absent | `SET('cart.items', ['tea']);` |\n| `NOTIFY('user.name');` | `UPD('user.name');` |\n| `EXT('user', { age: 30 });` | `SET('user', Object.assign(GET('user'), { age: 30 }));` |\n| `MAKE(function(obj) {` | Un objet simple |\n| `EVALUATE('user.age', 'value >= 18')` | `FN('value => value >= 18')(GET('user.age'))` |\n| `REMOVECACHE('token');` | `CACHE('token', null, '1 day');` |\n| `CL_INIT('colors', function(next) {` | `CLINIT('colors', function(next) {` |\n\n`PUSH()` vers un path qui n'existe pas ne notifie aucun observateur : crée donc le tableau avec `SET()`.\n\nLe troisième argument de `CACHEPATH()` est désormais une valeur par défaut, et les valeurs enregistrées par jComponent 19 ne sont pas lues :\n\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n```\n\n## Appeler des composants et des fonctions\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `RECONFIGURE('box', 'size:2');` | `SETTER('box/reconfigure', 'size:2');` |\n| `RETURN('box/name')` | `FIND('box').name` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `EXEC(true, 'FUNC.start', 'now');` | `EXEC('FUNC.start @important', 'now');` |\n| `AEXEC('FUNC.save', 1)` | `() => EXEC('FUNC.save', 1)` |\n| `ADD('box__user.name', '#panel');` | `$('#panel').append('<ui-component name=\"box\" path=\"user.name\"></ui-component>');` |\n\n## Attributs de balisage\n\nLes formes sous forme d'attribut sont ignorées sans erreur, et les éléments restent vides. Utilise les éléments personnalisés décrits dans [Utiliser les composants](../using-components/) et [Liaison de données](../data-binding/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<span id=\"name\" data-bind=\"user.name__text\"></span>` | `<ui-bind id=\"name\" path=\"user.name\" config=\"text\"></ui-bind>` |\n| `<div id=\"box\" data-scope=\"panel\">` | `<ui-plugin id=\"box\" path=\"panel\">` |\n\n## Scopes et plugins\n\nIl n'y a pas d'objet scope en 20. Un élément `<ui-plugin>` constitue le scope, et `$(selector).plugin()` renvoie l'instance. Un élément avec des paths `?` en dehors d'un `<ui-plugin>` n'est pas rendu. [Plugins](../plugins/) décrit l'objet plugin.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `var scope = $('#panel').scope();` | `var plugin = $('#panel').plugin();` |\n| `console.log(scope.path); // invoice` | `console.log(plugin.path.toString()); // invoice` |\n| `scope.watch('number', function(path, value) {` | `plugin.watch('number', function(value, flags, path) {` |\n| `<ui-plugin path=\"address\">` imbriqué dans un plugin | `<ui-plugin path=\"?.address\">` |\n| `<ui-plugin path=\"!shared\">` | `<ui-plugin path=\"shared\">` |\n| `<ui-plugin path=\"login\" default=\"{ user: 'guest' }\">` | `exports.set('user', 'guest');` dans le plugin |\n| `function loginready(path, element) {` | `function loginready(element) {` |\n| `config=\"text:?/format\"` | `config=\"text:PLUGINS.contact.format(value)\"` |\n\nUn `<ui-plugin>` imbriqué ne prolonge plus le path de son parent. Écris `?` dans le path pour obtenir l'ancien résultat, sinon le plugin lit un path global du même nom :\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-plugin path=\"?.address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n```\n\n**Un plugin a besoin de son élément.** En 19, `PLUGIN()` créait l'instance tout seul. En 20, le callback ne s'exécute que s'il existe un élément `<ui-plugin>` avec ce path : un plugin sans élément ne démarre donc jamais :\n\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n```\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `exports.extend('filter', { page: 2 });` | `exports.set('filter', Object.assign(exports.get('filter'), { page: 2 }));` |\n| `PLUGINS.orders.reset();` | `RESET(PLUGINS.orders.path.toString());` |\n| `exports.api('/api/ orders_list', { page: 1 }, function() {` | `API('/api/', 'orders_list', { page: 1 }, function() {` |\n| `console.log(exports.modified); // {\"city\":\"Prague\"}` | Le code ci-dessous |\n\n`exports.modified` renvoie tout le modèle de données et réinitialise l'état des composants. Récupère d'abord les champs modifiés :\n\n```js\nvar changed = {};\nCOMPONENTS(exports.path + ' @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nRESET(exports.path.toString());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n## Commandes de ui-bind\n\nPlusieurs commandes de `<ui-bind>` ont été supprimées, et la plupart sont ignorées sans erreur. L'expression d'une commande est du JavaScript simple : un appel à l'intérieur remplace donc la plupart d'entre elles. La [référence de ui-bind](../../reference/ui-bind/) liste les commandes de la version 20.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `config=\"text;currency:eur\"` | `config=\"text:value.currency('eur')\"` |\n| `config=\"text;default:'none'\"` | `config=\"text:value == null ? 'none' : value\"` |\n| `config=\"text;helper:pluralize('no items','# item','# items','# items')\"` | `config=\"text:value.pluralize('no items','# item','# items','# items')\"` |\n| `config=\"text;selector:b\"` | `config=\"text\" child=\"b\"` |\n| `config=\"checked input\"` | `config=\"checked\"` |\n| `config=\"init:FUNC.start;text\"` | `config=\"exec:FUNC.start;text\"` |\n| `config=\"click:FUNC.open\"` | `<button id=\"a\" class=\"exec\" data-exec=\"FUNC.open\">Open</button>` |\n| `config=\"setter:'box/show',value\"` | `config=\"exec:FUNC.show\"` |\n| `config=\"config:'size:' + value\"` | `<ui-component name=\"box\" config=\"=size:ui.size\"></ui-component>` |\n\n**La valeur `false` s'affiche vide** avec la commande `text`. Convertis la valeur en chaîne :\n\n```html\n<ui-bind id=\"a\" path=\"order.count\" config=\"text:value + ''\"></ui-bind>\n```\n\n## Composants\n\nLe `path` d'un composant est désormais un objet. Le comparer à une chaîne donne `false`, et les méthodes de chaîne comme `split()` n'y existent pas : convertis-le donc d'abord. Le troisième argument de `self.setter` est un objet contenant des flags au lieu d'un nombre. [Créer des composants](../creating-components/) décrit les delegates.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `self.path === 'form.name'` | `self.path.toString() === 'form.name'` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `type === 0` | `flags.init` |\n| `self.notify();` | `self.upd();` |\n| `self.faicon('home')` | `self.icon('home')` |\n| `self.scopepath('user.age')` | `self.makepath('user.age')` |\n| `self.inc(2);` | `self.set(self.get() + 2);` |\n| `self.extend({ b: 2 });` | `self.set(Object.assign(self.get(), { b: 2 }));` |\n| `self.dirty()` | `!config.touched` |\n| `self.dirty(false);` | `self.touch();` |\n| `self.invalid();` | `self.reconfigure({ touched: 1, invalid: true });` |\n| `self.skip();` avant `self.set(2);` | `self.rewrite(2);` |\n| `self.main()` | `self.element.parent().component()` |\n| `self.exec('show', 1)` | `self.element.SETTER('*/show', 1)` |\n| `self.data('page', 2);` | Une variable dans le composant |\n\nLes arguments de `self.state(type, what)` ont des valeurs différentes en 20. Lis l'état depuis `config` :\n\n```js\nself.state = function() {\n\tif (config.touched && config.modified && !changed) {\n\t\tchanged = true;\n\t\tconsole.log('changed');\n\t}\n};\n```\n\n`self.bindchanges()` a été supprimée. Compare la valeur dans le setter :\n\n```js\nvar last;\nself.setter = function(value) {\n\tif (value !== last) {\n\t\tlast = value;\n\t\tconsole.log(value);\n\t}\n};\n```\n\n## Macros et liaisons virtuelles\n\n`MACRO()`, la commande `macro`, `VBIND()`, `VBINDARRAY()` et la commande `vbindarray` ont été supprimées. Réécris une macro sous forme de composant, et une liaison virtuelle sous forme de commande `template` avec [Tangular](../tangular/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `MACRO('clicks', function(self, element) {` | `COMPONENT('clicks', function(self) {` |\n| `config=\"macro:clicks\"` | `<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>` |\n| `VBIND('<div><b data-bind=\".name__text\"></b></div>')` | `config=\"template\"` |\n| `VBINDARRAY('<li data-bind=\".name__text\"></li>', '#list')` | `config=\"template\"` |\n| `config=\"vbindarray\"` | `config=\"template\"` |\n\n```html\n<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>\n```\n\n```js\nCOMPONENT('clicks', function(self) {\n\tself.make = function() {\n\t\tself.event('click', () => self.set((self.get() || 0) + 1));\n\t};\n\tself.setter = function(value) {\n\t\tself.text('Clicked ' + (value || 0));\n\t};\n});\n```\n\nUne liste qui utilisait `VBINDARRAY()` devient un modèle :\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"rows\" config=\"template\">\n\t\t<script type=\"text/html\">{{ foreach m in value }}<li>{{ m.name }}</li>{{ end }}</script>\n\t</ui-bind>\n</ul>\n```\n\n## L'objet M\n\n`M` existe toujours et reste le même objet que `jComponent` et `MAIN`. `M.version`, `M.components` et `M.binders` fonctionnent comme avant. Les méthodes qui modifiaient le modèle de données ont été supprimées ou prennent d'autres arguments : utilise donc les fonctions globales.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `M.set('user.name', 'Ann');` | `SET('user.name', 'Ann');` |\n| `M.inc('user.age', 2);` | `INC('user.age', 2);` |\n| `M.push('user.tags', 'new');` | `PUSH('user.tags', 'new');` |\n\n## AJAX et API\n\nLe callback d'`AJAX()` ne reçoit que la réponse, et `AJAX()` ne renvoie plus de Promise. La référence [Fonctions globales](../../reference/globals/) décrit `AJAX()`.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n| `AJAX('GET /orders/').then(function(response) {` | `new Promise(resolve => AJAX('GET /orders/', resolve)).then(function(response) {` |\n| `AJAX('GET /orders/ error', () => console.log('callback'));` | `AJAX('GET /orders/ ERROR', () => console.log('callback'));` |\n| `AJAX('GET /orders/ {\"X-Token\":\"abc\"}', function() {` | `ON('request', opt => opt.headers['X-Token'] = 'abc');` |\n| `AJAXCONFIG('secure', function(options) {` | `ON('request', function(options) {` |\n| `AJAXCACHE('GET /orders/', null, NOOP, '1 minute');` | `AJAX('GET /orders/ <1 minute>', NOOP);` |\n| `AJAX('GET /orders/', null, 'orders', 100);` | `setTimeout(() => AJAX('GET /orders/', 'orders'), 100);` |\n| `API('/api/ users_save', { name: 'Ann' }, function() {` | `API('/api/', 'users_save', { name: 'Ann' }, function() {` |\n| `DAPI('users_save', { name: 'Ann' }, function() {` | `TAPI('users_save', { name: 'Ann' }, function() {` |\n\nPour lire le code de statut d'une réponse, écoute l'événement `response` avant la requête :\n\n```js\nvar status = 0;\n\nON('response', opt => status = opt.status);\n\nAJAX('GET /orders/', function(response) {\n\tconsole.log(response.error, status); // denied 403\n});\n```\n\n## Paramètres\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `DEF.validators.email` | `DEF.regexp.email` |\n| `DEF.pathcommon` | `DEF.path.common` |\n| `DEF.pathcl` | `DEF.path.cl` |\n| `DEF.environment` | `DEF.env` |\n| `DEF.languagehtml = 'sk';` | `DEF.language = 'sk';` |\n\nCes paramètres n'existent plus : `ajaxcredentials`, `ajaxcredentialshtml`, `ajaxerrors`, `customelements`, `delay`, `delaybinder`, `delaykeypress`, `delaypref`, `delayrepeat`, `delaywatcher`, `fallbackcache`, `importcache`, `jsoncompress`, `jsonconverter`, `jsondate`, `keypress`, `makeurl`, `monitor`, `prefixcssmacros`, `repeatfocus`, `scope`, `secret` et `versioncomponents`. La référence [DEF](../../reference/def/) liste les paramètres de la version 20.\n\n## Événements\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `ON('destroy', name => console.log('removed', name));` | `self.destroy = () => console.log('removed', self.name);` |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nL'événement `exec` n'est plus émis. `WW` et `WH` ne sont pas définis tant que la bibliothèque n'a pas démarré : lis-les donc dans `ON('ready', ...)`. La référence [Événements](../../reference/events/) liste les événements de la version 20.\n\n## Helpers jQuery\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `$('#panel').components()` | `$('#panel').COMPONENTS()` |\n| `$('#panel').FIND('box')` | `$('#panel').COMPONENTS().findItem('name', 'box')` |\n| `$('#panel').RECONFIGURE('box', 'size:2');` | `$('#panel').SETTER('box/reconfigure', 'size:2');` |\n| `$('#panel').EMIT('hello', 1);` | `EMIT('hello', 1);` |\n\n## Helpers de chaînes, de nombres, de dates et de tableaux\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `'Hello {name}'.arg({ name: 'Ann' })` | `'Hello {name}'.args({ name: 'Ann' })` |\n| `'{{ name }}'.render({ name: 'Ann' })` | `Tangular.render('{{ name }}', { name: 'Ann' })` |\n| `'<b>Ann</b>'.removeTags()` | `'<b>Ann</b>'.replace(/<[^>]*>/g, '')` |\n| `'a=1&b=2'.parseEncoded()` | `Object.fromEntries(new URLSearchParams('a=1&b=2'))` |\n| `new Date(2026, 0, 5).toNumber()` | `+new Date(2026, 0, 5).format('yyyyMMdd')` |\n| `new Date(2026, 0, 5).parseDate()` | `new Date(2026, 0, 5)` |\n| `(5).between({ 1: 'low', 10: 'high' })` | `value < 10 ? 'low' : 'high'` |\n| `tasks.async(() => console.log('done'));` | `tasks.wait((task, next) => task(next), () => console.log('done'));` |\n\n`String.parseConfig()` n'accepte plus de callback et l'ignore sans erreur. Parcours l'objet renvoyé avec une boucle :\n\n```js\nvar config = 'size:2;open:true'.parseConfig();\n\nfor (var key in config)\n\tconsole.log(key, config[key]);\n```\n\n## Fonctions sans remplacement\n\nCes fonctions globales ont été supprimées, et 20.015 n'a pas d'équivalent direct.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WAPI`, `WAPI_INIT`, `AJAXCACHEREVIEW` | Aucun remplacement |\n| `DEBUG`, `STOPDEBUG` | Aucun remplacement |\n| `QUEUE`, `REPEAT`, `WORKFLOW` | Aucun remplacement |\n| `PLUGINABLE`, `VERSION`, `IMPORTCACHE` | Aucun remplacement |\n| `CLEARCACHE`, `REWRITE`, `REWRITE2`, `NOTMODIFIED`, `BIND`, `OPT` | Aucun remplacement |\n\n## Un formulaire complet\n\nCe formulaire comporte deux champs obligatoires et un bouton activé dès que le formulaire est valide. Les deux versions se comportent de la même manière : le premier enregistrement signale les deux paths invalides, et un enregistrement avec les champs remplis renvoie le modèle de données.\n\nAvant, avec jComponent 19 :\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.validators.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" data-jc-bind />');\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nWATCH('form.*', function(path, value, type) {\n\t$('#save').prop('disabled', DISABLED('form.*'));\n});\n\nfunction save() {\n\n\tCHANGE('form.*');\n\n\tif (!VALID('form.*')) {\n\t\tconsole.log(ERRORS('form.*').map(com => com.path));\n\t\treturn;\n\t}\n\n\tconsole.log(GET('form @reset'));\n}\n</script>\n```\n\nAprès, avec jComponent 20 :\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.regexp.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n\nWATCH('form', function(value, flags, path) {\n\t$('#save').prop('disabled', !can('form'));\n});\n\nfunction save() {\n\n\tUPD('form @change');\n\n\tERRORS('form', function(list) {\n\n\t\tif (list.length) {\n\t\t\tconsole.log(list.map(com => com.path.toString()));\n\t\t\treturn;\n\t\t}\n\n\t\tconsole.log(GET('form @reset'));\n\t});\n}\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JanEc21ew61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/migrating-from-v19/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Migrazione da jComponent 19","summary":"Sostituisci ogni API di jComponent 19 rimossa o modificata con il suo equivalente in jComponent 20, comprese le modifiche che falliscono senza errori.","markdown":"---\ntitle: Migrazione da jComponent 19\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/migrating-from-v19/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# Migrazione da jComponent 19\n\n> Sostituisci ogni API di jComponent 19 rimossa o modificata con il suo equivalente in jComponent 20, comprese le modifiche che falliscono senza errori.\n\nQuesta guida porta un'applicazione da jComponent 19 a jComponent 20.015. Mostra il sostituto di ogni funzione, attributo e impostazione rimossi o modificati e segnala le modifiche che non producono errori nella console del browser, perché sono quelle che un test rapido non rileva.\n\n## Aggiorna i file della CDN\n\nSostituisci entrambi i file. Il bundle contiene ancora jQuery, Tangular e le funzioni di routing, quindi non serve caricare altro.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `https://cdn.componentator.com/spa.min@19.js` | `https://cdn.componentator.com/spa.min@20.js` |\n| `https://cdn.componentator.com/spa.min@19.css` | `https://cdn.componentator.com/spa.min@20.css` |\n\n## Ordine di lavoro consigliato\n\n1. Sostituisci i file della CDN e apri l'applicazione con la console del browser visibile.\n2. Modifica prima il markup: gli elementi `data---`, `data-bind` e `data-scope` vengono ignorati, quindi non puoi testare nient'altro finché non li converti.\n3. Cerca nel codice i pattern di [Modifiche che falliscono in silenzio](#changes-that-fail-silently) e correggili. La console non li segnala.\n4. Correggi gli errori riportati dalla console, come `VALID is not defined` o `$(...).scope is not a function`.\n5. Adatta i form, poi prova a mano ogni form: vuoto, non valido, valido e dopo un reset.\n6. Prova le schermate che caricano dati, perché le callback AJAX ricevono meno argomenti.\n\n## Modifiche che falliscono in silenzio\n\nCiascuno di questi casi viene eseguito senza errori in 20.015, ma fa la cosa sbagliata. Cerca nel tuo codice quanto riportato nella colonna di sinistra.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `RESET('form.*');` | `RESET('form');` |\n| `GET('form @modified')` | `COMPONENTS('form @modified')` |\n| `return value; // a non-empty string means valid` | `return !!value;` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<ui-plugin path=\"address\">` | `<ui-plugin path=\"?.address\">` |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n\nAnche una dichiarazione `PLUGIN()` senza un elemento `<ui-plugin>` smette di funzionare. Vedi [Scope e plugin](#scopes-and-plugins).\n\n## Form e validazione\n\n`VALID()`, `CAN()`, `DISABLED()`, `INVALID()`, `CHANGE()`, `MODIFIED()` e `DEFAULT()` sono state rimosse. Leggi lo stato di un form con `COMPONENTS()` e `ERRORS()` e modificalo con i flag. [Form e validazione](../forms/) descrive il nuovo modo di lavorare.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `VALID('form.*')` | `COMPONENTS('form @invalid').length === 0` |\n| `CAN('form.*')` | `can('form')` (la funzione qui sotto) |\n| `DISABLED('form.*')` | `!can('form')` |\n| `ERRORS('form.*')` | `ERRORS('form @touched', list => console.log(list.length))` |\n| `CHANGE('form.*');` | `UPD('form @change');` |\n| `CHANGE('form.*', false);` | `RESET('form');` |\n| `MODIFIED('form.*')` | `COMPONENTS('form @modified').map(com => com.path.toString())` |\n| `DEFAULT('filter.*');` | `SET('filter @default', {});` |\n| `INVALID('form.name');` | `COMPONENTS('form.name').forEach(com => com.reconfigure({ touched: 1, invalid: true }));` |\n| `RESET('form.*');` | `RESET('form');` |\n\n`CAN()` non ha un sostituto diretto, quindi tieni una piccola funzione nella tua applicazione:\n\n```js\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n```\n\n**`ERRORS()` richiede una callback.** Senza, genera l'errore `r is not a function`. Nella 19 restituiva i campi toccati e non validi. Nella 20 passa tutti i campi non validi, quindi aggiungi il flag `@touched` per ottenere il risultato di prima:\n\n```js\nERRORS('form @touched', list => console.log(list.length)); // 0\nSET('form.name @change', '');\nERRORS('form @touched', list => console.log(list.map(com => com.path.toString()))); // [\"form.name\"]\n```\n\n**I path non accettano più `.*`.** Non corrisponde a nulla e non viene mostrato alcun errore. `ERRORS()` segnala quindi come valido un form con errori:\n\n```js\nERRORS('form.*', list => console.log(list.length)); // 0\nERRORS('form', list => console.log(list.length)); // 1\n```\n\n**`GET('form @modified')` restituisce l'intero modello** nella 20. Raccogli tu stesso i campi modificati:\n\n```js\nSET('form.city @change', 'Prague');\n\nvar changed = {};\nCOMPONENTS('form @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n**Il risultato di `self.validate` viene interpretato in modo diverso.** Nella 19 qualsiasi valore truthy era valido. Nella 20 una stringa non vuota è un messaggio di errore, quindi un validatore che restituisce il valore segna come non valido un campo compilato. Anche un numero come `value.length` non è valido. Restituisci un booleano:\n\n```js\nself.validate = function(value) {\n\treturn !!value;\n};\n```\n\n```js\nself.validate = function(value) {\n\treturn value.length > 0;\n};\n```\n\n`self.validate` ha perso anche il secondo argomento, `init`. Se la prima esecuzione richiede un trattamento diverso, usa un tuo flag:\n\n```js\nCOMPONENT('field', function(self, config) {\n\tvar init = true;\n\tself.validate = function(value) {\n\t\tconsole.log(init);\n\t\tinit = false;\n\t\treturn true;\n\t};\n});\n```\n\n### Associare un input\n\nL'attributo `data-jc-bind` viene ignorato, quindi l'input non scrive nel modello. Chiama `self.autobind20()` quando l'HTML esiste già:\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n```\n\nLe funzioni globali `FORMATTER()` e `PARSER()` sono state rimosse. Registrale sul componente:\n\n```js\nself.formatter(function(path, value) {\n\treturn value ? value.toUpperCase() : value;\n});\n```\n\n```js\nself.parser(function(path, value) {\n\treturn value ? value.toLowerCase() : value;\n});\n```\n\n## Osservatori e path\n\nGli argomenti di un osservatore hanno cambiato ordine e il codice continua a funzionare con i valori sbagliati. [Path](../paths/) descrive gli osservatori nella 20.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `self.watch('user.name', function(path, value, type) {` | `self.watch('user.name', function(value, flags, path) {` |\n| `exports.watch('count', function(value, path, type) {` | `exports.watch('count', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `WATCHONCE('user.name', function(path, value) {` | `UNWATCH('user.name', once);` dentro la callback |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nUn osservatore su un path padre viene eseguito anche per i path sottostanti, quindi `WATCH('user', ...)` sostituisce il carattere jolly.\n\n## Scrivere nel modello\n\nIl terzo argomento di `SET()` è stato rimosso. Un ritardo o un flag di reset passato in quella posizione viene ignorato e il valore viene scritto subito.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `PUSH('cart.items', 'tea');` su un path inesistente | `SET('cart.items', ['tea']);` |\n| `NOTIFY('user.name');` | `UPD('user.name');` |\n| `EXT('user', { age: 30 });` | `SET('user', Object.assign(GET('user'), { age: 30 }));` |\n| `MAKE(function(obj) {` | Un oggetto semplice |\n| `EVALUATE('user.age', 'value >= 18')` | `FN('value => value >= 18')(GET('user.age'))` |\n| `REMOVECACHE('token');` | `CACHE('token', null, '1 day');` |\n| `CL_INIT('colors', function(next) {` | `CLINIT('colors', function(next) {` |\n\n`PUSH()` su un path che non esiste non notifica alcun osservatore, quindi crea l'array con `SET()`.\n\nIl terzo argomento di `CACHEPATH()` ora è un valore predefinito e i valori salvati da jComponent 19 non vengono letti:\n\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n```\n\n## Chiamare componenti e funzioni\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `RECONFIGURE('box', 'size:2');` | `SETTER('box/reconfigure', 'size:2');` |\n| `RETURN('box/name')` | `FIND('box').name` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `EXEC(true, 'FUNC.start', 'now');` | `EXEC('FUNC.start @important', 'now');` |\n| `AEXEC('FUNC.save', 1)` | `() => EXEC('FUNC.save', 1)` |\n| `ADD('box__user.name', '#panel');` | `$('#panel').append('<ui-component name=\"box\" path=\"user.name\"></ui-component>');` |\n\n## Attributi del markup\n\nLe forme con attributi vengono ignorate senza errori e gli elementi restano vuoti. Usa gli elementi personalizzati descritti in [Usare i componenti](../using-components/) e [Associazione dei dati](../data-binding/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<span id=\"name\" data-bind=\"user.name__text\"></span>` | `<ui-bind id=\"name\" path=\"user.name\" config=\"text\"></ui-bind>` |\n| `<div id=\"box\" data-scope=\"panel\">` | `<ui-plugin id=\"box\" path=\"panel\">` |\n\n## Scope e plugin\n\nNella 20 non esiste un oggetto scope. L'elemento `<ui-plugin>` è lo scope e `$(selector).plugin()` restituisce l'istanza. Un elemento con path `?` al di fuori di un `<ui-plugin>` non viene renderizzato. [Plugin](../plugins/) descrive l'oggetto plugin.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `var scope = $('#panel').scope();` | `var plugin = $('#panel').plugin();` |\n| `console.log(scope.path); // invoice` | `console.log(plugin.path.toString()); // invoice` |\n| `scope.watch('number', function(path, value) {` | `plugin.watch('number', function(value, flags, path) {` |\n| `<ui-plugin path=\"address\">` annidato in un plugin | `<ui-plugin path=\"?.address\">` |\n| `<ui-plugin path=\"!shared\">` | `<ui-plugin path=\"shared\">` |\n| `<ui-plugin path=\"login\" default=\"{ user: 'guest' }\">` | `exports.set('user', 'guest');` nel plugin |\n| `function loginready(path, element) {` | `function loginready(element) {` |\n| `config=\"text:?/format\"` | `config=\"text:PLUGINS.contact.format(value)\"` |\n\nUn `<ui-plugin>` annidato non estende più il path del suo genitore. Scrivi `?` nel path per ottenere il risultato di prima, altrimenti il plugin legge un path globale con lo stesso nome:\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-plugin path=\"?.address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n```\n\n**Un plugin ha bisogno del suo elemento.** Nella 19 `PLUGIN()` creava l'istanza da solo. Nella 20 la callback viene eseguita solo se esiste un elemento `<ui-plugin>` con quel path, quindi un plugin senza elemento non si avvia mai:\n\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n```\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `exports.extend('filter', { page: 2 });` | `exports.set('filter', Object.assign(exports.get('filter'), { page: 2 }));` |\n| `PLUGINS.orders.reset();` | `RESET(PLUGINS.orders.path.toString());` |\n| `exports.api('/api/ orders_list', { page: 1 }, function() {` | `API('/api/', 'orders_list', { page: 1 }, function() {` |\n| `console.log(exports.modified); // {\"city\":\"Prague\"}` | Il codice qui sotto |\n\n`exports.modified` restituisce l'intero modello e azzera lo stato dei componenti. Raccogli prima i campi modificati:\n\n```js\nvar changed = {};\nCOMPONENTS(exports.path + ' @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nRESET(exports.path.toString());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n## Comandi di ui-bind\n\nDiversi comandi di `<ui-bind>` sono stati rimossi e la maggior parte viene saltata senza errori. L'espressione di un comando è semplice JavaScript, quindi una chiamata al suo interno sostituisce la maggior parte di essi. Il [riferimento di ui-bind](../../reference/ui-bind/) elenca i comandi della 20.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `config=\"text;currency:eur\"` | `config=\"text:value.currency('eur')\"` |\n| `config=\"text;default:'none'\"` | `config=\"text:value == null ? 'none' : value\"` |\n| `config=\"text;helper:pluralize('no items','# item','# items','# items')\"` | `config=\"text:value.pluralize('no items','# item','# items','# items')\"` |\n| `config=\"text;selector:b\"` | `config=\"text\" child=\"b\"` |\n| `config=\"checked input\"` | `config=\"checked\"` |\n| `config=\"init:FUNC.start;text\"` | `config=\"exec:FUNC.start;text\"` |\n| `config=\"click:FUNC.open\"` | `<button id=\"a\" class=\"exec\" data-exec=\"FUNC.open\">Open</button>` |\n| `config=\"setter:'box/show',value\"` | `config=\"exec:FUNC.show\"` |\n| `config=\"config:'size:' + value\"` | `<ui-component name=\"box\" config=\"=size:ui.size\"></ui-component>` |\n\n**Il valore `false` viene visualizzato come vuoto** con il comando `text`. Converti il valore in stringa:\n\n```html\n<ui-bind id=\"a\" path=\"order.count\" config=\"text:value + ''\"></ui-bind>\n```\n\n## Componenti\n\nIl `path` di un componente ora è un oggetto. Confrontarlo con una stringa dà `false` e i metodi delle stringhe come `split()` non esistono su di esso, quindi convertilo prima. Il terzo argomento di `self.setter` è un oggetto con i flag al posto di un numero. [Creare componenti](../creating-components/) descrive i delegate.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `self.path === 'form.name'` | `self.path.toString() === 'form.name'` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `type === 0` | `flags.init` |\n| `self.notify();` | `self.upd();` |\n| `self.faicon('home')` | `self.icon('home')` |\n| `self.scopepath('user.age')` | `self.makepath('user.age')` |\n| `self.inc(2);` | `self.set(self.get() + 2);` |\n| `self.extend({ b: 2 });` | `self.set(Object.assign(self.get(), { b: 2 }));` |\n| `self.dirty()` | `!config.touched` |\n| `self.dirty(false);` | `self.touch();` |\n| `self.invalid();` | `self.reconfigure({ touched: 1, invalid: true });` |\n| `self.skip();` prima di `self.set(2);` | `self.rewrite(2);` |\n| `self.main()` | `self.element.parent().component()` |\n| `self.exec('show', 1)` | `self.element.SETTER('*/show', 1)` |\n| `self.data('page', 2);` | Una variabile dentro il componente |\n\nNella 20 gli argomenti di `self.state(type, what)` hanno valori diversi. Leggi lo stato da `config`:\n\n```js\nself.state = function() {\n\tif (config.touched && config.modified && !changed) {\n\t\tchanged = true;\n\t\tconsole.log('changed');\n\t}\n};\n```\n\n`self.bindchanges()` è stato rimosso. Confronta il valore nel setter:\n\n```js\nvar last;\nself.setter = function(value) {\n\tif (value !== last) {\n\t\tlast = value;\n\t\tconsole.log(value);\n\t}\n};\n```\n\n## Macro e associazioni virtuali\n\n`MACRO()`, il comando `macro`, `VBIND()`, `VBINDARRAY()` e il comando `vbindarray` sono stati rimossi. Riscrivi una macro come componente e un'associazione virtuale come comando `template` con [Tangular](../tangular/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `MACRO('clicks', function(self, element) {` | `COMPONENT('clicks', function(self) {` |\n| `config=\"macro:clicks\"` | `<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>` |\n| `VBIND('<div><b data-bind=\".name__text\"></b></div>')` | `config=\"template\"` |\n| `VBINDARRAY('<li data-bind=\".name__text\"></li>', '#list')` | `config=\"template\"` |\n| `config=\"vbindarray\"` | `config=\"template\"` |\n\n```html\n<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>\n```\n\n```js\nCOMPONENT('clicks', function(self) {\n\tself.make = function() {\n\t\tself.event('click', () => self.set((self.get() || 0) + 1));\n\t};\n\tself.setter = function(value) {\n\t\tself.text('Clicked ' + (value || 0));\n\t};\n});\n```\n\nUn elenco che usava `VBINDARRAY()` diventa un template:\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"rows\" config=\"template\">\n\t\t<script type=\"text/html\">{{ foreach m in value }}<li>{{ m.name }}</li>{{ end }}</script>\n\t</ui-bind>\n</ul>\n```\n\n## L'oggetto M\n\n`M` esiste ancora ed è lo stesso oggetto di `jComponent` e `MAIN`. `M.version`, `M.components` e `M.binders` funzionano come prima. I metodi che modificavano il modello sono stati rimossi o accettano argomenti diversi, quindi usa le funzioni globali.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `M.set('user.name', 'Ann');` | `SET('user.name', 'Ann');` |\n| `M.inc('user.age', 2);` | `INC('user.age', 2);` |\n| `M.push('user.tags', 'new');` | `PUSH('user.tags', 'new');` |\n\n## AJAX e API\n\nLa callback di `AJAX()` riceve solo la risposta e `AJAX()` non restituisce più una Promise. Il riferimento [Funzioni globali](../../reference/globals/) descrive `AJAX()`.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n| `AJAX('GET /orders/').then(function(response) {` | `new Promise(resolve => AJAX('GET /orders/', resolve)).then(function(response) {` |\n| `AJAX('GET /orders/ error', () => console.log('callback'));` | `AJAX('GET /orders/ ERROR', () => console.log('callback'));` |\n| `AJAX('GET /orders/ {\"X-Token\":\"abc\"}', function() {` | `ON('request', opt => opt.headers['X-Token'] = 'abc');` |\n| `AJAXCONFIG('secure', function(options) {` | `ON('request', function(options) {` |\n| `AJAXCACHE('GET /orders/', null, NOOP, '1 minute');` | `AJAX('GET /orders/ <1 minute>', NOOP);` |\n| `AJAX('GET /orders/', null, 'orders', 100);` | `setTimeout(() => AJAX('GET /orders/', 'orders'), 100);` |\n| `API('/api/ users_save', { name: 'Ann' }, function() {` | `API('/api/', 'users_save', { name: 'Ann' }, function() {` |\n| `DAPI('users_save', { name: 'Ann' }, function() {` | `TAPI('users_save', { name: 'Ann' }, function() {` |\n\nPer leggere il codice di stato di una risposta, ascolta l'evento `response` prima della richiesta:\n\n```js\nvar status = 0;\n\nON('response', opt => status = opt.status);\n\nAJAX('GET /orders/', function(response) {\n\tconsole.log(response.error, status); // denied 403\n});\n```\n\n## Impostazioni\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `DEF.validators.email` | `DEF.regexp.email` |\n| `DEF.pathcommon` | `DEF.path.common` |\n| `DEF.pathcl` | `DEF.path.cl` |\n| `DEF.environment` | `DEF.env` |\n| `DEF.languagehtml = 'sk';` | `DEF.language = 'sk';` |\n\nQueste impostazioni non esistono più: `ajaxcredentials`, `ajaxcredentialshtml`, `ajaxerrors`, `customelements`, `delay`, `delaybinder`, `delaykeypress`, `delaypref`, `delayrepeat`, `delaywatcher`, `fallbackcache`, `importcache`, `jsoncompress`, `jsonconverter`, `jsondate`, `keypress`, `makeurl`, `monitor`, `prefixcssmacros`, `repeatfocus`, `scope`, `secret` e `versioncomponents`. Il riferimento [DEF](../../reference/def/) elenca le impostazioni della 20.\n\n## Eventi\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `ON('destroy', name => console.log('removed', name));` | `self.destroy = () => console.log('removed', self.name);` |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nL'evento `exec` non viene più emesso. `WW` e `WH` non sono impostati finché la libreria non si avvia, quindi leggili dentro `ON('ready', ...)`. Il riferimento [Eventi](../../reference/events/) elenca gli eventi della 20.\n\n## Helper jQuery\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `$('#panel').components()` | `$('#panel').COMPONENTS()` |\n| `$('#panel').FIND('box')` | `$('#panel').COMPONENTS().findItem('name', 'box')` |\n| `$('#panel').RECONFIGURE('box', 'size:2');` | `$('#panel').SETTER('box/reconfigure', 'size:2');` |\n| `$('#panel').EMIT('hello', 1);` | `EMIT('hello', 1);` |\n\n## Helper per stringhe, numeri, date e array\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `'Hello {name}'.arg({ name: 'Ann' })` | `'Hello {name}'.args({ name: 'Ann' })` |\n| `'{{ name }}'.render({ name: 'Ann' })` | `Tangular.render('{{ name }}', { name: 'Ann' })` |\n| `'<b>Ann</b>'.removeTags()` | `'<b>Ann</b>'.replace(/<[^>]*>/g, '')` |\n| `'a=1&b=2'.parseEncoded()` | `Object.fromEntries(new URLSearchParams('a=1&b=2'))` |\n| `new Date(2026, 0, 5).toNumber()` | `+new Date(2026, 0, 5).format('yyyyMMdd')` |\n| `new Date(2026, 0, 5).parseDate()` | `new Date(2026, 0, 5)` |\n| `(5).between({ 1: 'low', 10: 'high' })` | `value < 10 ? 'low' : 'high'` |\n| `tasks.async(() => console.log('done'));` | `tasks.wait((task, next) => task(next), () => console.log('done'));` |\n\n`String.parseConfig()` non accetta più una callback e, se gliene passi una, la ignora senza errori. Scorri l'oggetto restituito:\n\n```js\nvar config = 'size:2;open:true'.parseConfig();\n\nfor (var key in config)\n\tconsole.log(key, config[key]);\n```\n\n## Funzioni senza sostituto\n\nQueste funzioni globali sono state rimosse e 20.015 non ha un equivalente diretto.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WAPI`, `WAPI_INIT`, `AJAXCACHEREVIEW` | Nessun sostituto |\n| `DEBUG`, `STOPDEBUG` | Nessun sostituto |\n| `QUEUE`, `REPEAT`, `WORKFLOW` | Nessun sostituto |\n| `PLUGINABLE`, `VERSION`, `IMPORTCACHE` | Nessun sostituto |\n| `CLEARCACHE`, `REWRITE`, `REWRITE2`, `NOTMODIFIED`, `BIND`, `OPT` | Nessun sostituto |\n\n## Un form completo\n\nQuesto form ha due campi obbligatori e un pulsante che si abilita quando il form è valido. Entrambe le versioni si comportano allo stesso modo: il primo salvataggio segnala i due path non validi e un salvataggio con i campi compilati restituisce il modello.\n\nPrima, in jComponent 19:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.validators.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" data-jc-bind />');\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nWATCH('form.*', function(path, value, type) {\n\t$('#save').prop('disabled', DISABLED('form.*'));\n});\n\nfunction save() {\n\n\tCHANGE('form.*');\n\n\tif (!VALID('form.*')) {\n\t\tconsole.log(ERRORS('form.*').map(com => com.path));\n\t\treturn;\n\t}\n\n\tconsole.log(GET('form @reset'));\n}\n</script>\n```\n\nDopo, in jComponent 20:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.regexp.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n\nWATCH('form', function(value, flags, path) {\n\t$('#save').prop('disabled', !can('form'));\n});\n\nfunction save() {\n\n\tUPD('form @change');\n\n\tERRORS('form', function(list) {\n\n\t\tif (list.length) {\n\t\t\tconsole.log(list.map(com => com.path.toString()));\n\t\t\treturn;\n\t\t}\n\n\t\tconsole.log(GET('form @reset'));\n\t});\n}\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JanEc21ew61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/migrating-from-v19/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Migrácia z jComponent 19","summary":"Nahraď každé odstránené alebo zmenené API jComponent 19 jeho ekvivalentom v jComponent 20 vrátane zmien, ktoré zlyhajú bez chybového hlásenia.","markdown":"---\ntitle: \"Migrácia z jComponent 19\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/migrating-from-v19/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# Migrácia z jComponent 19\n\n> Nahraď každé odstránené alebo zmenené API jComponent 19 jeho ekvivalentom v jComponent 20 vrátane zmien, ktoré zlyhajú bez chybového hlásenia.\n\nTento sprievodca ti ukáže, ako presunúť aplikáciu z jComponent 19 na jComponent 20.015. Uvádza náhradu za každú odstránenú alebo zmenenú funkciu, atribút a nastavenie a označuje zmeny, ktoré v konzole prehliadača nevyvolajú žiadnu chybu, pretože práve tie pri rýchlom teste prehliadneš.\n\n## Aktualizuj súbory na CDN\n\nNahraď oba súbory. Balík stále obsahuje jQuery, Tangular a funkcie smerovania, takže nič ďalšie nemusíš načítavať.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `https://cdn.componentator.com/spa.min@19.js` | `https://cdn.componentator.com/spa.min@20.js` |\n| `https://cdn.componentator.com/spa.min@19.css` | `https://cdn.componentator.com/spa.min@20.css` |\n\n## Odporúčané poradie práce\n\n1. Nahraď súbory na CDN a otvor aplikáciu s viditeľnou konzolou prehliadača.\n2. Najprv zmeň značkovanie: elementy `data---`, `data-bind` a `data-scope` sa ignorujú, takže kým ich neprevedieš, nemôžeš otestovať nič iné.\n3. V kóde vyhľadaj vzory z časti [Zmeny, ktoré zlyhajú potichu](#changes-that-fail-silently) a oprav ich. Konzola ťa na ne neupozorní.\n4. Oprav chyby, ktoré hlási konzola, napríklad `VALID is not defined` alebo `$(...).scope is not a function`.\n5. Prenes formuláre a potom každý formulár otestuj ručne: prázdny, neplatný, platný a po resete.\n6. Otestuj obrazovky, ktoré načítavajú dáta, pretože callbacky AJAX dostávajú menej argumentov.\n\n## Zmeny, ktoré zlyhajú potichu\n\nKaždá z týchto konštrukcií v 20.015 prebehne bez chyby a urobí niečo iné, než má. V kóde hľadaj zápisy z ľavého stĺpca.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `RESET('form.*');` | `RESET('form');` |\n| `GET('form @modified')` | `COMPONENTS('form @modified')` |\n| `return value; // a non-empty string means valid` | `return !!value;` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<ui-plugin path=\"address\">` | `<ui-plugin path=\"?.address\">` |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n\nDeklarácia `PLUGIN()` bez elementu `<ui-plugin>` tiež prestane fungovať. Pozri [Scope a pluginy](#scopes-and-plugins).\n\n## Formuláre a validácia\n\n`VALID()`, `CAN()`, `DISABLED()`, `INVALID()`, `CHANGE()`, `MODIFIED()` a `DEFAULT()` boli odstránené. Stav formulára čítaj pomocou `COMPONENTS()` a `ERRORS()` a meň ho pomocou flagov. Nový spôsob práce opisuje časť [Formuláre a validácia](../forms/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `VALID('form.*')` | `COMPONENTS('form @invalid').length === 0` |\n| `CAN('form.*')` | `can('form')` (funkcia nižšie) |\n| `DISABLED('form.*')` | `!can('form')` |\n| `ERRORS('form.*')` | `ERRORS('form @touched', list => console.log(list.length))` |\n| `CHANGE('form.*');` | `UPD('form @change');` |\n| `CHANGE('form.*', false);` | `RESET('form');` |\n| `MODIFIED('form.*')` | `COMPONENTS('form @modified').map(com => com.path.toString())` |\n| `DEFAULT('filter.*');` | `SET('filter @default', {});` |\n| `INVALID('form.name');` | `COMPONENTS('form.name').forEach(com => com.reconfigure({ touched: 1, invalid: true }));` |\n| `RESET('form.*');` | `RESET('form');` |\n\n`CAN()` nemá priamu náhradu, preto si v aplikácii ponechaj malú funkciu:\n\n```js\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n```\n\n**`ERRORS()` vyžaduje callback.** Bez neho vyhodí `r is not a function`. V 19 vracala polia, ktoré boli dotknuté a neplatné. V 20 odovzdáva všetky neplatné polia, takže ak chceš zachovať pôvodný výsledok, pridaj flag `@touched`:\n\n```js\nERRORS('form @touched', list => console.log(list.length)); // 0\nSET('form.name @change', '');\nERRORS('form @touched', list => console.log(list.map(com => com.path.toString()))); // [\"form.name\"]\n```\n\n**V path už nemôžeš použiť `.*`.** Nezodpovedá ničomu a nezobrazí sa žiadna chyba. `ERRORS()` potom pokazený formulár vyhodnotí ako platný:\n\n```js\nERRORS('form.*', list => console.log(list.length)); // 0\nERRORS('form', list => console.log(list.length)); // 1\n```\n\nV 20 **`GET('form @modified')` vracia celý model**. Zmenené polia si pozbieraj:\n\n```js\nSET('form.city @change', 'Prague');\n\nvar changed = {};\nCOMPONENTS('form @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n**Výsledok `self.validate` sa vyhodnocuje inak.** V 19 bola platná každá pravdivá hodnota. V 20 je neprázdny reťazec chybové hlásenie, takže validátor, ktorý vracia hodnotu, označí vyplnené pole ako neplatné. Neplatné je aj číslo, napríklad `value.length`. Vracaj boolean:\n\n```js\nself.validate = function(value) {\n\treturn !!value;\n};\n```\n\n```js\nself.validate = function(value) {\n\treturn value.length > 0;\n};\n```\n\n`self.validate` prišiel aj o druhý argument `init`. Ak prvé spustenie potrebuje iné spracovanie, použi vlastný flag:\n\n```js\nCOMPONENT('field', function(self, config) {\n\tvar init = true;\n\tself.validate = function(value) {\n\t\tconsole.log(init);\n\t\tinit = false;\n\t\treturn true;\n\t};\n});\n```\n\n### Väzba vstupného poľa\n\nAtribút `data-jc-bind` sa ignoruje, takže vstupné pole nezapisuje do modelu. Keď už HTML existuje, zavolaj `self.autobind20()`:\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n```\n\nGlobálne funkcie `FORMATTER()` a `PARSER()` boli odstránené. Zaregistruj ich na komponente:\n\n```js\nself.formatter(function(path, value) {\n\treturn value ? value.toUpperCase() : value;\n});\n```\n\n```js\nself.parser(function(path, value) {\n\treturn value ? value.toLowerCase() : value;\n});\n```\n\n## Sledovače a path\n\nArgumenty sledovača zmenili poradie a kód beží ďalej s nesprávnymi hodnotami. Sledovače v 20 opisuje časť [Path](../paths/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WATCH('user.name', function(path, value, type) {` | `WATCH('user.name', function(value, flags, path) {` |\n| `self.watch('user.name', function(path, value, type) {` | `self.watch('user.name', function(value, flags, path) {` |\n| `exports.watch('count', function(value, path, type) {` | `exports.watch('count', function(value, flags, path) {` |\n| `WATCH('user.*', function(path) {` | `WATCH('user', function(value, flags, path) {` |\n| `WATCHONCE('user.name', function(path, value) {` | `UNWATCH('user.name', once);` vnútri callbacku |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nSledovač na nadradenom path sa spúšťa aj pre path pod ním, takže `WATCH('user', ...)` nahrádza zástupný znak.\n\n## Zápis do modelu\n\nTretí argument funkcie `SET()` bol odstránený. Oneskorenie alebo flag resetu, ktorý tam odovzdáš, sa ignoruje a hodnota sa zapíše okamžite.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SET('user.name', 'Ann', 100);` | `setTimeout(() => SET('user.name', 'Ann'), 100);` |\n| `SET('form.city', 'Vienna', true);` | `SET('form.city @reset', 'Vienna');` |\n| `PUSH('cart.items', [2, 3]);` | `[2, 3].forEach(item => PUSH('cart.items', item));` |\n| `PUSH('cart.items', 'tea');` na neexistujúci path | `SET('cart.items', ['tea']);` |\n| `NOTIFY('user.name');` | `UPD('user.name');` |\n| `EXT('user', { age: 30 });` | `SET('user', Object.assign(GET('user'), { age: 30 }));` |\n| `MAKE(function(obj) {` | Obyčajný objekt |\n| `EVALUATE('user.age', 'value >= 18')` | `FN('value => value >= 18')(GET('user.age'))` |\n| `REMOVECACHE('token');` | `CACHE('token', null, '1 day');` |\n| `CL_INIT('colors', function(next) {` | `CLINIT('colors', function(next) {` |\n\n`PUSH()` na path, ktorý neexistuje, neupozorní žiadny sledovač, preto pole vytvor pomocou `SET()`.\n\nTretí argument `CACHEPATH()` je teraz predvolená hodnota a hodnoty uložené v jComponent 19 sa nečítajú:\n\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n```\n\n## Volanie komponentov a funkcií\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `SETTER('box', 'show', 1);` | `SETTER('box/show', 1);` |\n| `RECONFIGURE('box', 'size:2');` | `SETTER('box/reconfigure', 'size:2');` |\n| `RETURN('box/name')` | `FIND('box').name` |\n| `FIND('box', function(com) {` | `WAIT(() => FIND('box'), function() {` |\n| `EXEC(true, 'FUNC.start', 'now');` | `EXEC('FUNC.start @important', 'now');` |\n| `AEXEC('FUNC.save', 1)` | `() => EXEC('FUNC.save', 1)` |\n| `ADD('box__user.name', '#panel');` | `$('#panel').append('<ui-component name=\"box\" path=\"user.name\"></ui-component>');` |\n\n## Atribúty v značkovaní\n\nZápisy pomocou atribútov sa bez chyby ignorujú a elementy zostanú prázdne. Použi vlastné elementy opísané v častiach [Používanie komponentov](../using-components/) a [Dátová väzba](../data-binding/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `<div data---=\"box__user.name__size:2\"></div>` | `<ui-component name=\"box\" path=\"user.name\" config=\"size:2\"></ui-component>` |\n| `<span id=\"name\" data-bind=\"user.name__text\"></span>` | `<ui-bind id=\"name\" path=\"user.name\" config=\"text\"></ui-bind>` |\n| `<div id=\"box\" data-scope=\"panel\">` | `<ui-plugin id=\"box\" path=\"panel\">` |\n\n## Scope a pluginy\n\nV 20 neexistuje objekt scope. Scope je element `<ui-plugin>` a `$(selector).plugin()` vracia inštanciu. Element s path obsahujúcim `?` mimo `<ui-plugin>` sa nevykreslí. Objekt pluginu opisuje časť [Pluginy](../plugins/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `var scope = $('#panel').scope();` | `var plugin = $('#panel').plugin();` |\n| `console.log(scope.path); // invoice` | `console.log(plugin.path.toString()); // invoice` |\n| `scope.watch('number', function(path, value) {` | `plugin.watch('number', function(value, flags, path) {` |\n| `<ui-plugin path=\"address\">` vnorený do pluginu | `<ui-plugin path=\"?.address\">` |\n| `<ui-plugin path=\"!shared\">` | `<ui-plugin path=\"shared\">` |\n| `<ui-plugin path=\"login\" default=\"{ user: 'guest' }\">` | `exports.set('user', 'guest');` v plugine |\n| `function loginready(path, element) {` | `function loginready(element) {` |\n| `config=\"text:?/format\"` | `config=\"text:PLUGINS.contact.format(value)\"` |\n\nVnorený `<ui-plugin>` už nerozširuje path svojho rodiča. Ak chceš pôvodný výsledok, napíš do path `?`, inak plugin číta globálny path s rovnakým názvom:\n\n```html\n<ui-plugin path=\"order\">\n\t<ui-plugin path=\"?.address\">\n\t\t<ui-bind id=\"city\" path=\"?.city\" config=\"text\"></ui-bind>\n\t</ui-plugin>\n</ui-plugin>\n```\n\n**Plugin potrebuje svoj element.** V 19 vytvoril `PLUGIN()` inštanciu sám. V 20 sa callback spustí, len keď existuje element `<ui-plugin>` s daným path, takže plugin bez neho sa nikdy nespustí:\n\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n```\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `exports.extend('filter', { page: 2 });` | `exports.set('filter', Object.assign(exports.get('filter'), { page: 2 }));` |\n| `PLUGINS.orders.reset();` | `RESET(PLUGINS.orders.path.toString());` |\n| `exports.api('/api/ orders_list', { page: 1 }, function() {` | `API('/api/', 'orders_list', { page: 1 }, function() {` |\n| `console.log(exports.modified); // {\"city\":\"Prague\"}` | Kód nižšie |\n\n`exports.modified` vráti celý model a vynuluje stav komponentov. Zmenené polia najprv pozbieraj:\n\n```js\nvar changed = {};\nCOMPONENTS(exports.path + ' @modified').forEach(com => changed[com.path.toString().split('.').pop()] = com.get());\nRESET(exports.path.toString());\nconsole.log(changed); // {\"city\":\"Prague\"}\n```\n\n## Príkazy ui-bind\n\nViaceré príkazy `<ui-bind>` boli odstránené a väčšina z nich sa bez chyby preskočí. Výraz príkazu je obyčajný JavaScript, takže väčšinu z nich nahradí volanie vnútri výrazu. Príkazy verzie 20 uvádza [referencia ui-bind](../../reference/ui-bind/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `config=\"text;format:2\"` | `config=\"text:value.format(2)\"` |\n| `config=\"text;currency:eur\"` | `config=\"text:value.currency('eur')\"` |\n| `config=\"text;default:'none'\"` | `config=\"text:value == null ? 'none' : value\"` |\n| `config=\"text;helper:pluralize('no items','# item','# items','# items')\"` | `config=\"text:value.pluralize('no items','# item','# items','# items')\"` |\n| `config=\"text;selector:b\"` | `config=\"text\" child=\"b\"` |\n| `config=\"checked input\"` | `config=\"checked\"` |\n| `config=\"init:FUNC.start;text\"` | `config=\"exec:FUNC.start;text\"` |\n| `config=\"click:FUNC.open\"` | `<button id=\"a\" class=\"exec\" data-exec=\"FUNC.open\">Open</button>` |\n| `config=\"setter:'box/show',value\"` | `config=\"exec:FUNC.show\"` |\n| `config=\"config:'size:' + value\"` | `<ui-component name=\"box\" config=\"=size:ui.size\"></ui-component>` |\n\n**Hodnota `false` sa vykreslí ako prázdna** pri príkaze `text`. Preveď hodnotu na reťazec:\n\n```html\n<ui-bind id=\"a\" path=\"order.count\" config=\"text:value + ''\"></ui-bind>\n```\n\n## Komponenty\n\n`path` komponentu je teraz objekt. Porovnanie s reťazcom vráti `false` a reťazcové metódy ako `split()` na ňom neexistujú, preto ho najprv preveď. Tretí argument `self.setter` je namiesto čísla objekt s flagmi. Delegates opisuje časť [Vytváranie komponentov](../creating-components/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `self.path === 'form.name'` | `self.path.toString() === 'form.name'` |\n| `self.setter = function(value, path, type) {` | `self.setter = function(value, path, flags) {` |\n| `type === 0` | `flags.init` |\n| `self.notify();` | `self.upd();` |\n| `self.faicon('home')` | `self.icon('home')` |\n| `self.scopepath('user.age')` | `self.makepath('user.age')` |\n| `self.inc(2);` | `self.set(self.get() + 2);` |\n| `self.extend({ b: 2 });` | `self.set(Object.assign(self.get(), { b: 2 }));` |\n| `self.dirty()` | `!config.touched` |\n| `self.dirty(false);` | `self.touch();` |\n| `self.invalid();` | `self.reconfigure({ touched: 1, invalid: true });` |\n| `self.skip();` pred `self.set(2);` | `self.rewrite(2);` |\n| `self.main()` | `self.element.parent().component()` |\n| `self.exec('show', 1)` | `self.element.SETTER('*/show', 1)` |\n| `self.data('page', 2);` | Premenná vnútri komponentu |\n\nArgumenty `self.state(type, what)` majú v 20 iné hodnoty. Stav čítaj z `config`:\n\n```js\nself.state = function() {\n\tif (config.touched && config.modified && !changed) {\n\t\tchanged = true;\n\t\tconsole.log('changed');\n\t}\n};\n```\n\n`self.bindchanges()` bola odstránená. Hodnotu porovnaj v setteri:\n\n```js\nvar last;\nself.setter = function(value) {\n\tif (value !== last) {\n\t\tlast = value;\n\t\tconsole.log(value);\n\t}\n};\n```\n\n## Macro a virtuálne väzby\n\n`MACRO()`, príkaz `macro`, `VBIND()`, `VBINDARRAY()` a príkaz `vbindarray` boli odstránené. Macro prepíš ako komponent a virtuálnu väzbu ako príkaz `template` s [Tangular](../tangular/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `MACRO('clicks', function(self, element) {` | `COMPONENT('clicks', function(self) {` |\n| `config=\"macro:clicks\"` | `<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>` |\n| `VBIND('<div><b data-bind=\".name__text\"></b></div>')` | `config=\"template\"` |\n| `VBINDARRAY('<li data-bind=\".name__text\"></li>', '#list')` | `config=\"template\"` |\n| `config=\"vbindarray\"` | `config=\"template\"` |\n\n```html\n<ui-component id=\"c\" name=\"clicks\" path=\"counter\"></ui-component>\n```\n\n```js\nCOMPONENT('clicks', function(self) {\n\tself.make = function() {\n\t\tself.event('click', () => self.set((self.get() || 0) + 1));\n\t};\n\tself.setter = function(value) {\n\t\tself.text('Clicked ' + (value || 0));\n\t};\n});\n```\n\nZoznam, ktorý používal `VBINDARRAY()`, sa zmení na šablónu:\n\n```html\n<ul id=\"list\">\n\t<ui-bind path=\"rows\" config=\"template\">\n\t\t<script type=\"text/html\">{{ foreach m in value }}<li>{{ m.name }}</li>{{ end }}</script>\n\t</ui-bind>\n</ul>\n```\n\n## Objekt M\n\n`M` stále existuje a je to ten istý objekt ako `jComponent` a `MAIN`. `M.version`, `M.components` a `M.binders` fungujú ako predtým. Metódy, ktoré menili model, boli odstránené alebo prijímajú iné argumenty, preto použi globálne funkcie.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `M.set('user.name', 'Ann');` | `SET('user.name', 'Ann');` |\n| `M.inc('user.age', 2);` | `INC('user.age', 2);` |\n| `M.push('user.tags', 'new');` | `PUSH('user.tags', 'new');` |\n\n## AJAX a API\n\nCallback funkcie `AJAX()` dostáva len odpoveď a `AJAX()` už nevracia Promise. `AJAX()` opisuje referencia [Globálne funkcie](../../reference/globals/).\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `AJAX('GET /orders/', function(response, err) {` | `ON('response', opt => status = opt.status);` |\n| `AJAX('GET /orders/').then(function(response) {` | `new Promise(resolve => AJAX('GET /orders/', resolve)).then(function(response) {` |\n| `AJAX('GET /orders/ error', () => console.log('callback'));` | `AJAX('GET /orders/ ERROR', () => console.log('callback'));` |\n| `AJAX('GET /orders/ {\"X-Token\":\"abc\"}', function() {` | `ON('request', opt => opt.headers['X-Token'] = 'abc');` |\n| `AJAXCONFIG('secure', function(options) {` | `ON('request', function(options) {` |\n| `AJAXCACHE('GET /orders/', null, NOOP, '1 minute');` | `AJAX('GET /orders/ <1 minute>', NOOP);` |\n| `AJAX('GET /orders/', null, 'orders', 100);` | `setTimeout(() => AJAX('GET /orders/', 'orders'), 100);` |\n| `API('/api/ users_save', { name: 'Ann' }, function() {` | `API('/api/', 'users_save', { name: 'Ann' }, function() {` |\n| `DAPI('users_save', { name: 'Ann' }, function() {` | `TAPI('users_save', { name: 'Ann' }, function() {` |\n\nAk chceš prečítať stavový kód odpovede, ešte pred požiadavkou začni počúvať udalosť `response`:\n\n```js\nvar status = 0;\n\nON('response', opt => status = opt.status);\n\nAJAX('GET /orders/', function(response) {\n\tconsole.log(response.error, status); // denied 403\n});\n```\n\n## Nastavenia\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `DEF.validators.email` | `DEF.regexp.email` |\n| `DEF.pathcommon` | `DEF.path.common` |\n| `DEF.pathcl` | `DEF.path.cl` |\n| `DEF.environment` | `DEF.env` |\n| `DEF.languagehtml = 'sk';` | `DEF.language = 'sk';` |\n\nTieto nastavenia už neexistujú: `ajaxcredentials`, `ajaxcredentialshtml`, `ajaxerrors`, `customelements`, `delay`, `delaybinder`, `delaykeypress`, `delaypref`, `delayrepeat`, `delaywatcher`, `fallbackcache`, `importcache`, `jsoncompress`, `jsonconverter`, `jsondate`, `keypress`, `makeurl`, `monitor`, `prefixcssmacros`, `repeatfocus`, `scope`, `secret` a `versioncomponents`. Nastavenia verzie 20 uvádza referencia [DEF](../../reference/def/).\n\n## Udalosti\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `ON('destroy', name => console.log('removed', name));` | `self.destroy = () => console.log('removed', self.name);` |\n| `ON('watch', 'user.name', function(path, value) {` | `WATCH('user.name', function(value) {` |\n\nUdalosť `exec` sa už nevysiela. `WW` a `WH` sa nastavia až po spustení knižnice, preto ich čítaj vnútri `ON('ready', ...)`. Udalosti verzie 20 uvádza referencia [Udalosti](../../reference/events/).\n\n## jQuery helpery\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `$('#panel').components()` | `$('#panel').COMPONENTS()` |\n| `$('#panel').FIND('box')` | `$('#panel').COMPONENTS().findItem('name', 'box')` |\n| `$('#panel').RECONFIGURE('box', 'size:2');` | `$('#panel').SETTER('box/reconfigure', 'size:2');` |\n| `$('#panel').EMIT('hello', 1);` | `EMIT('hello', 1);` |\n\n## Helpery pre reťazce, čísla, dátumy a polia\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `'Hello {name}'.arg({ name: 'Ann' })` | `'Hello {name}'.args({ name: 'Ann' })` |\n| `'{{ name }}'.render({ name: 'Ann' })` | `Tangular.render('{{ name }}', { name: 'Ann' })` |\n| `'<b>Ann</b>'.removeTags()` | `'<b>Ann</b>'.replace(/<[^>]*>/g, '')` |\n| `'a=1&b=2'.parseEncoded()` | `Object.fromEntries(new URLSearchParams('a=1&b=2'))` |\n| `new Date(2026, 0, 5).toNumber()` | `+new Date(2026, 0, 5).format('yyyyMMdd')` |\n| `new Date(2026, 0, 5).parseDate()` | `new Date(2026, 0, 5)` |\n| `(5).between({ 1: 'low', 10: 'high' })` | `value < 10 ? 'low' : 'high'` |\n| `tasks.async(() => console.log('done'));` | `tasks.wait((task, next) => task(next), () => console.log('done'));` |\n\n`String.parseConfig()` už neprijíma callback a bez chyby ho ignoruje. Prejdi vrátený objekt v cykle:\n\n```js\nvar config = 'size:2;open:true'.parseConfig();\n\nfor (var key in config)\n\tconsole.log(key, config[key]);\n```\n\n## Funkcie bez náhrady\n\nTieto globálne funkcie boli odstránené a 20.015 nemá ich priamy ekvivalent.\n\n| jComponent 19 | jComponent 20 |\n| --- | --- |\n| `WAPI`, `WAPI_INIT`, `AJAXCACHEREVIEW` | Bez náhrady |\n| `DEBUG`, `STOPDEBUG` | Bez náhrady |\n| `QUEUE`, `REPEAT`, `WORKFLOW` | Bez náhrady |\n| `PLUGINABLE`, `VERSION`, `IMPORTCACHE` | Bez náhrady |\n| `CLEARCACHE`, `REWRITE`, `REWRITE2`, `NOTMODIFIED`, `BIND`, `OPT` | Bez náhrady |\n\n## Kompletný formulár\n\nTento formulár má dve povinné polia a tlačidlo, ktoré sa aktivuje, keď je formulár platný. Obe verzie sa správajú rovnako: prvé uloženie nahlási dva neplatné path a uloženie s vyplnenými poľami vráti model.\n\nPred zmenou, v jComponent 19:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.validators.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" data-jc-bind />');\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nWATCH('form.*', function(path, value, type) {\n\t$('#save').prop('disabled', DISABLED('form.*'));\n});\n\nfunction save() {\n\n\tCHANGE('form.*');\n\n\tif (!VALID('form.*')) {\n\t\tconsole.log(ERRORS('form.*').map(com => com.path));\n\t\treturn;\n\t}\n\n\tconsole.log(GET('form @reset'));\n}\n</script>\n```\n\nPo zmene, v jComponent 20:\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"textbox\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n<button id=\"save\" disabled>Save</button>\n<script>\nCOMPONENT('textbox', function(self, config) {\n\n\tself.validate = function(value) {\n\t\tif (!config.required)\n\t\t\treturn true;\n\t\tif (!value)\n\t\t\treturn false;\n\t\treturn config.email ? DEF.regexp.email.test(value) : true;\n\t};\n\n\tself.make = function() {\n\t\tself.html('<label>' + config.label + '</label><input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nvar form = { name: '', email: '' };\n\nfunction can(path) {\n\treturn COMPONENTS(path + ' @invalid').length === 0 && COMPONENTS(path + ' @touched').length > 0;\n}\n\nWATCH('form', function(value, flags, path) {\n\t$('#save').prop('disabled', !can('form'));\n});\n\nfunction save() {\n\n\tUPD('form @change');\n\n\tERRORS('form', function(list) {\n\n\t\tif (list.length) {\n\t\t\tconsole.log(list.map(com => com.path.toString()));\n\t\t\treturn;\n\t\t}\n\n\t\tconsole.log(GET('form @reset'));\n\t});\n}\n</script>\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JamcNa1wd61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/paths/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Paths","summary":"How to address, read, change and watch values of the model with string paths.","markdown":"---\ntitle: Paths\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/paths/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Paths\n\n> How to address, read, change and watch values of the model with string paths.\n\nA path is a string that addresses a value in the global `window` object: `app.user.name` is the same value as `window.app.user.name`. All data in jComponent is read and written through paths, which is how the library knows what has changed and who needs to be told.\n\n## Reading and writing values\n\n`SET(path, value)` writes a value and notifies everything that depends on the path. `GET(path)` reads a value.\n\n```js\nSET('app.user.name', 'Ana');\n\nconsole.log(app.user.name);\nconsole.log(GET('app.user.name'));\nconsole.log(GET('app.user'));\nconsole.log(GET('app.company.name'));\n```\n\n```text\nAna\nAna\n{\"name\":\"Ana\"}\nundefined\n```\n\n`SET()` creates the missing objects along the path. `GET()` returns `undefined` when a part of the path does not exist.\n\nThe first part of a path is a global variable, so choose a name that the browser does not already use. Names such as `name`, `location` or `status` belong to `window`.\n\n## Path syntax\n\n| Path | Meaning |\n| --- | --- |\n| `app.user.name` | A nested key |\n| `shop.products[1].name` | A key of an existing array item |\n| `shop.tags[]` | With `SET()`, appends the value to an array and creates the array when it is missing |\n| `shop.prices['pen.blue']` | A key that contains a dot |\n\n```js\nSET('shop.products', [{ name: 'Pen' }, { name: 'Book' }]);\nSET('shop.products[1].name', 'Notebook');\nconsole.log(GET('shop.products[1].name'));\n\nSET('shop.tags[]', 'new');\nSET('shop.tags[]', 'sale');\nconsole.log(GET('shop.tags'));\n\nSET(\"shop.prices['pen.blue']\", 12);\nconsole.log(GET(\"shop.prices['pen.blue']\"));\n```\n\n```text\nNotebook\n[\"new\",\"sale\"]\n12\n```\n\n## Changing values\n\n| Function | What it does |\n| --- | --- |\n| `SET(path, value)` | Writes a value |\n| `INC(path, [value])` | Adds a number to the value, `1` by default |\n| `TOGGLE(path)` | Negates the value |\n| `PUSH(path, value)` | Appends a value to an existing array. With the prefix `^`, the value goes to the start of the array |\n| `NUL(path)` | Writes `null` |\n\n```js\nSET('cart.count', 1);\nINC('cart.count');\nINC('cart.count', 5);\nconsole.log(cart.count);\n\nTOGGLE('cart.open');\nconsole.log(cart.open);\n\nSET('cart.items', ['b']);\nPUSH('cart.items', 'c');\nPUSH('^cart.items', 'a');\nconsole.log(cart.items);\n\nNUL('cart.count');\nconsole.log(cart.count);\n```\n\n```text\n7\ntrue\n[\"a\",\"b\",\"c\"]\nnull\n```\n\n## Who is notified\n\nA change reaches listeners on the same path, on its parent paths and on its child paths. Listeners on sibling paths are left alone.\n\n```js\nWATCH('order', () => console.log('order'));\nWATCH('order.customer', () => console.log('order.customer'));\nWATCH('order.customer.name', () => console.log('order.customer.name'));\nWATCH('order.total', () => console.log('order.total'));\n\nSET('order.customer', { name: 'Ana' });\n```\n\n```text\norder\norder.customer\norder.customer.name\n```\n\nThe watcher of `order.total` does not run, because `order.customer` is neither its parent nor its child.\n\n## Changing the model directly\n\nThe model is a plain object, so you can change it with normal JavaScript. The library does not see such a change. Call `UPD(path)` to announce it:\n\n```js\nSET('todo.items', ['Write']);\n\nWATCH('todo.items', function(value, flags, path) {\n\tconsole.log(path, value.length);\n});\n\n// Changing the object directly notifies nobody\ntodo.items.push('Test');\n\n// UPD() tells everybody that the value has changed\nUPD('todo.items');\n```\n\n```text\ntodo.items 2\n```\n\n## Watching a path\n\n`WATCH(path, callback, [init])` runs a function whenever the value at the path changes. `UNWATCH(path, [callback])` removes the watcher. Without the `callback` argument, it removes all watchers of the path.\n\nThe callback receives three arguments:\n\n| Argument | Description |\n| --- | --- |\n| `value` | The current value at the watched path |\n| `flags` | An object with the [flags](../flags/) of the operation |\n| `path` | The path that was changed, which can be a parent or a child of the watched path |\n\n```js\nfunction onchange(value, flags, path) {\n\tconsole.log(path, value);\n}\n\nWATCH('stats.visits', onchange);\nSET('stats.visits', 1);\n\nUNWATCH('stats.visits', onchange);\nSET('stats.visits', 2);\n\n// Several paths with one callback\nWATCH('stats.a + stats.b', onchange);\nSET('stats.a', 10);\nSET('stats.b', 20);\n\n// The third argument calls the callback right after the registration\nSET('stats.c', 30);\nWATCH('stats.c', onchange, true);\n```\n\n```text\nstats.visits 1\nstats.a 10\nstats.b 20\nstats.c 30\n```\n\nTo display a value on the page, you do not need a watcher. Use [data binding](../data-binding/).\n\n## Shortcuts\n\nPaths support prefixes for common places in the model, such as `*title` for `common.title`. They are described in [Flags and path modifiers](../flags/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNa1wd61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/paths/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Paths","summary":"Wie du Werte des Modells mit Paths in Form von Strings adressierst, liest, änderst und beobachtest.","markdown":"---\ntitle: Paths\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/paths/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Paths\n\n> Wie du Werte des Modells mit Paths in Form von Strings adressierst, liest, änderst und beobachtest.\n\nEin Path ist ein String, der einen Wert im globalen Objekt `window` adressiert: `app.user.name` ist derselbe Wert wie `window.app.user.name`. Alle Daten in jComponent werden über Paths gelesen und geschrieben. So weiß die Bibliothek, was sich geändert hat und wer davon erfahren muss.\n\n## Werte lesen und schreiben\n\n`SET(path, value)` schreibt einen Wert und benachrichtigt alles, was vom Path abhängt. `GET(path)` liest einen Wert.\n\n```js\nSET('app.user.name', 'Ana');\n\nconsole.log(app.user.name);\nconsole.log(GET('app.user.name'));\nconsole.log(GET('app.user'));\nconsole.log(GET('app.company.name'));\n```\n\n```text\nAna\nAna\n{\"name\":\"Ana\"}\nundefined\n```\n\n`SET()` erstellt die fehlenden Objekte entlang des Paths. `GET()` gibt `undefined` zurück, wenn ein Teil des Paths nicht existiert.\n\nDer erste Teil eines Paths ist eine globale Variable, wähle also einen Namen, den der Browser nicht bereits verwendet. Namen wie `name`, `location` oder `status` gehören zu `window`.\n\n## Syntax von Paths\n\n| Path | Bedeutung |\n| --- | --- |\n| `app.user.name` | Ein verschachtelter Schlüssel |\n| `shop.products[1].name` | Ein Schlüssel eines vorhandenen Array-Elements |\n| `shop.tags[]` | Hängt mit `SET()` den Wert an ein Array an und erstellt das Array, falls es fehlt |\n| `shop.prices['pen.blue']` | Ein Schlüssel, der einen Punkt enthält |\n\n```js\nSET('shop.products', [{ name: 'Pen' }, { name: 'Book' }]);\nSET('shop.products[1].name', 'Notebook');\nconsole.log(GET('shop.products[1].name'));\n\nSET('shop.tags[]', 'new');\nSET('shop.tags[]', 'sale');\nconsole.log(GET('shop.tags'));\n\nSET(\"shop.prices['pen.blue']\", 12);\nconsole.log(GET(\"shop.prices['pen.blue']\"));\n```\n\n```text\nNotebook\n[\"new\",\"sale\"]\n12\n```\n\n## Werte ändern\n\n| Funktion | Was sie macht |\n| --- | --- |\n| `SET(path, value)` | Schreibt einen Wert |\n| `INC(path, [value])` | Addiert eine Zahl zum Wert, standardmäßig `1` |\n| `TOGGLE(path)` | Negiert den Wert |\n| `PUSH(path, value)` | Hängt einen Wert an ein vorhandenes Array an. Mit dem Präfix `^` kommt der Wert an den Anfang des Arrays |\n| `NUL(path)` | Schreibt `null` |\n\n```js\nSET('cart.count', 1);\nINC('cart.count');\nINC('cart.count', 5);\nconsole.log(cart.count);\n\nTOGGLE('cart.open');\nconsole.log(cart.open);\n\nSET('cart.items', ['b']);\nPUSH('cart.items', 'c');\nPUSH('^cart.items', 'a');\nconsole.log(cart.items);\n\nNUL('cart.count');\nconsole.log(cart.count);\n```\n\n```text\n7\ntrue\n[\"a\",\"b\",\"c\"]\nnull\n```\n\n## Wer benachrichtigt wird\n\nEine Änderung erreicht Listener auf demselben Path, auf seinen übergeordneten Paths und auf seinen untergeordneten Paths. Listener auf benachbarten Paths bleiben unberührt.\n\n```js\nWATCH('order', () => console.log('order'));\nWATCH('order.customer', () => console.log('order.customer'));\nWATCH('order.customer.name', () => console.log('order.customer.name'));\nWATCH('order.total', () => console.log('order.total'));\n\nSET('order.customer', { name: 'Ana' });\n```\n\n```text\norder\norder.customer\norder.customer.name\n```\n\nDer Watcher von `order.total` läuft nicht, denn `order.customer` ist ihm weder über- noch untergeordnet.\n\n## Das Modell direkt ändern\n\nDas Modell ist ein einfaches Objekt, du kannst es also mit normalem JavaScript ändern. Die Bibliothek bemerkt eine solche Änderung nicht. Rufe `UPD(path)` auf, um sie bekannt zu machen:\n\n```js\nSET('todo.items', ['Write']);\n\nWATCH('todo.items', function(value, flags, path) {\n\tconsole.log(path, value.length);\n});\n\n// Changing the object directly notifies nobody\ntodo.items.push('Test');\n\n// UPD() tells everybody that the value has changed\nUPD('todo.items');\n```\n\n```text\ntodo.items 2\n```\n\n## Einen Path beobachten\n\n`WATCH(path, callback, [init])` führt eine Funktion aus, sobald sich der Wert am Path ändert. `UNWATCH(path, [callback])` entfernt den Watcher. Ohne das Argument `callback` entfernt es alle Watcher des Paths.\n\nDer Callback erhält drei Argumente:\n\n| Argument | Beschreibung |\n| --- | --- |\n| `value` | Der aktuelle Wert am beobachteten Path |\n| `flags` | Ein Objekt mit den [Flags](../flags/) der Operation |\n| `path` | Der geänderte Path, der dem beobachteten Path über- oder untergeordnet sein kann |\n\n```js\nfunction onchange(value, flags, path) {\n\tconsole.log(path, value);\n}\n\nWATCH('stats.visits', onchange);\nSET('stats.visits', 1);\n\nUNWATCH('stats.visits', onchange);\nSET('stats.visits', 2);\n\n// Several paths with one callback\nWATCH('stats.a + stats.b', onchange);\nSET('stats.a', 10);\nSET('stats.b', 20);\n\n// The third argument calls the callback right after the registration\nSET('stats.c', 30);\nWATCH('stats.c', onchange, true);\n```\n\n```text\nstats.visits 1\nstats.a 10\nstats.b 20\nstats.c 30\n```\n\nUm einen Wert auf der Seite anzuzeigen, brauchst du keinen Watcher. Verwende dafür die [Datenbindung](../data-binding/).\n\n## Kurzformen\n\nPaths unterstützen Präfixe für häufig genutzte Stellen im Modell, etwa `*title` für `common.title`. Diese Präfixe sind unter [Flags und Path-Modifikatoren](../flags/) beschrieben.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNa1wd61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/paths/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Paths","summary":"Cómo acceder a los valores del modelo, leerlos, cambiarlos y observarlos con paths en forma de cadena.","markdown":"---\ntitle: Paths\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/paths/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Paths\n\n> Cómo acceder a los valores del modelo, leerlos, cambiarlos y observarlos con paths en forma de cadena.\n\nUn path es una cadena que apunta a un valor del objeto global `window`: `app.user.name` es el mismo valor que `window.app.user.name`. Todos los datos de jComponent se leen y se escriben mediante paths, y así la biblioteca sabe qué ha cambiado y a quién debe avisar.\n\n## Leer y escribir valores\n\n`SET(path, value)` escribe un valor y avisa a todo lo que depende del path. `GET(path)` lee un valor.\n\n```js\nSET('app.user.name', 'Ana');\n\nconsole.log(app.user.name);\nconsole.log(GET('app.user.name'));\nconsole.log(GET('app.user'));\nconsole.log(GET('app.company.name'));\n```\n\n```text\nAna\nAna\n{\"name\":\"Ana\"}\nundefined\n```\n\n`SET()` crea los objetos que falten a lo largo del path. `GET()` devuelve `undefined` cuando una parte del path no existe.\n\nLa primera parte de un path es una variable global, así que elige un nombre que el navegador no use ya. Nombres como `name`, `location` o `status` pertenecen a `window`.\n\n## Sintaxis de los paths\n\n| Path | Significado |\n| --- | --- |\n| `app.user.name` | Una clave anidada |\n| `shop.products[1].name` | Una clave de un elemento existente de un array |\n| `shop.tags[]` | Con `SET()`, añade el valor al final de un array y crea el array si no existe |\n| `shop.prices['pen.blue']` | Una clave que contiene un punto |\n\n```js\nSET('shop.products', [{ name: 'Pen' }, { name: 'Book' }]);\nSET('shop.products[1].name', 'Notebook');\nconsole.log(GET('shop.products[1].name'));\n\nSET('shop.tags[]', 'new');\nSET('shop.tags[]', 'sale');\nconsole.log(GET('shop.tags'));\n\nSET(\"shop.prices['pen.blue']\", 12);\nconsole.log(GET(\"shop.prices['pen.blue']\"));\n```\n\n```text\nNotebook\n[\"new\",\"sale\"]\n12\n```\n\n## Cambiar valores\n\n| Función | Qué hace |\n| --- | --- |\n| `SET(path, value)` | Escribe un valor |\n| `INC(path, [value])` | Suma un número al valor, `1` de forma predeterminada |\n| `TOGGLE(path)` | Niega el valor |\n| `PUSH(path, value)` | Añade un valor al final de un array existente. Con el prefijo `^`, el valor va al principio del array |\n| `NUL(path)` | Escribe `null` |\n\n```js\nSET('cart.count', 1);\nINC('cart.count');\nINC('cart.count', 5);\nconsole.log(cart.count);\n\nTOGGLE('cart.open');\nconsole.log(cart.open);\n\nSET('cart.items', ['b']);\nPUSH('cart.items', 'c');\nPUSH('^cart.items', 'a');\nconsole.log(cart.items);\n\nNUL('cart.count');\nconsole.log(cart.count);\n```\n\n```text\n7\ntrue\n[\"a\",\"b\",\"c\"]\nnull\n```\n\n## A quién se avisa\n\nUn cambio llega a quienes escuchan el mismo path, sus paths padre y sus paths hijo. Quienes escuchan paths hermanos no reciben nada.\n\n```js\nWATCH('order', () => console.log('order'));\nWATCH('order.customer', () => console.log('order.customer'));\nWATCH('order.customer.name', () => console.log('order.customer.name'));\nWATCH('order.total', () => console.log('order.total'));\n\nSET('order.customer', { name: 'Ana' });\n```\n\n```text\norder\norder.customer\norder.customer.name\n```\n\nEl observador de `order.total` no se ejecuta, porque `order.customer` no es ni su padre ni su hijo.\n\n## Cambiar el modelo directamente\n\nEl modelo es un objeto normal, así que puedes cambiarlo con JavaScript corriente. La biblioteca no detecta ese cambio. Llama a `UPD(path)` para anunciarlo:\n\n```js\nSET('todo.items', ['Write']);\n\nWATCH('todo.items', function(value, flags, path) {\n\tconsole.log(path, value.length);\n});\n\n// Changing the object directly notifies nobody\ntodo.items.push('Test');\n\n// UPD() tells everybody that the value has changed\nUPD('todo.items');\n```\n\n```text\ntodo.items 2\n```\n\n## Observar un path\n\n`WATCH(path, callback, [init])` ejecuta una función cada vez que cambia el valor del path. `UNWATCH(path, [callback])` elimina el observador. Sin el argumento `callback`, elimina todos los observadores del path.\n\nEl callback recibe tres argumentos:\n\n| Argumento | Descripción |\n| --- | --- |\n| `value` | El valor actual del path observado |\n| `flags` | Un objeto con los [flags](../flags/) de la operación |\n| `path` | El path que ha cambiado, que puede ser un padre o un hijo del path observado |\n\n```js\nfunction onchange(value, flags, path) {\n\tconsole.log(path, value);\n}\n\nWATCH('stats.visits', onchange);\nSET('stats.visits', 1);\n\nUNWATCH('stats.visits', onchange);\nSET('stats.visits', 2);\n\n// Several paths with one callback\nWATCH('stats.a + stats.b', onchange);\nSET('stats.a', 10);\nSET('stats.b', 20);\n\n// The third argument calls the callback right after the registration\nSET('stats.c', 30);\nWATCH('stats.c', onchange, true);\n```\n\n```text\nstats.visits 1\nstats.a 10\nstats.b 20\nstats.c 30\n```\n\nPara mostrar un valor en la página no necesitas un observador. Usa el [enlace de datos](../data-binding/).\n\n## Atajos\n\nLos paths admiten prefijos para lugares habituales del modelo, como `*title` para `common.title`. Se describen en [Flags y modificadores de path](../flags/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNa1wd61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/paths/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Paths","summary":"Comment désigner, lire, modifier et observer les valeurs du modèle de données avec des paths sous forme de chaînes.","markdown":"---\ntitle: Paths\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/paths/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Paths\n\n> Comment désigner, lire, modifier et observer les valeurs du modèle de données avec des paths sous forme de chaînes.\n\nUn path est une chaîne qui désigne une valeur dans l'objet global `window` : `app.user.name` est la même valeur que `window.app.user.name`. Dans jComponent, toutes les données sont lues et écrites par des paths : c'est ainsi que la bibliothèque sait ce qui a changé et qui doit en être informé.\n\n## Lire et écrire des valeurs\n\n`SET(path, value)` écrit une valeur et prévient tout ce qui dépend du path. `GET(path)` lit une valeur.\n\n```js\nSET('app.user.name', 'Ana');\n\nconsole.log(app.user.name);\nconsole.log(GET('app.user.name'));\nconsole.log(GET('app.user'));\nconsole.log(GET('app.company.name'));\n```\n\n```text\nAna\nAna\n{\"name\":\"Ana\"}\nundefined\n```\n\n`SET()` crée les objets manquants le long du path. `GET()` renvoie `undefined` quand une partie du path n'existe pas.\n\nLa première partie d'un path est une variable globale : choisis donc un nom que le navigateur n'utilise pas déjà. Des noms comme `name`, `location` ou `status` appartiennent à `window`.\n\n## Syntaxe des paths\n\n| Path | Signification |\n| --- | --- |\n| `app.user.name` | Une clé imbriquée |\n| `shop.products[1].name` | Une clé d'un élément existant d'un tableau |\n| `shop.tags[]` | Avec `SET()`, ajoute la valeur à la fin d'un tableau et crée le tableau s'il manque |\n| `shop.prices['pen.blue']` | Une clé qui contient un point |\n\n```js\nSET('shop.products', [{ name: 'Pen' }, { name: 'Book' }]);\nSET('shop.products[1].name', 'Notebook');\nconsole.log(GET('shop.products[1].name'));\n\nSET('shop.tags[]', 'new');\nSET('shop.tags[]', 'sale');\nconsole.log(GET('shop.tags'));\n\nSET(\"shop.prices['pen.blue']\", 12);\nconsole.log(GET(\"shop.prices['pen.blue']\"));\n```\n\n```text\nNotebook\n[\"new\",\"sale\"]\n12\n```\n\n## Modifier des valeurs\n\n| Fonction | Ce qu'elle fait |\n| --- | --- |\n| `SET(path, value)` | Écrit une valeur |\n| `INC(path, [value])` | Ajoute un nombre à la valeur, `1` par défaut |\n| `TOGGLE(path)` | Inverse la valeur |\n| `PUSH(path, value)` | Ajoute une valeur à la fin d'un tableau existant. Avec le préfixe `^`, la valeur est placée au début du tableau |\n| `NUL(path)` | Écrit `null` |\n\n```js\nSET('cart.count', 1);\nINC('cart.count');\nINC('cart.count', 5);\nconsole.log(cart.count);\n\nTOGGLE('cart.open');\nconsole.log(cart.open);\n\nSET('cart.items', ['b']);\nPUSH('cart.items', 'c');\nPUSH('^cart.items', 'a');\nconsole.log(cart.items);\n\nNUL('cart.count');\nconsole.log(cart.count);\n```\n\n```text\n7\ntrue\n[\"a\",\"b\",\"c\"]\nnull\n```\n\n## Qui est prévenu\n\nUn changement atteint les écouteurs du même path, de ses paths parents et de ses paths enfants. Les écouteurs des paths frères ne sont pas concernés.\n\n```js\nWATCH('order', () => console.log('order'));\nWATCH('order.customer', () => console.log('order.customer'));\nWATCH('order.customer.name', () => console.log('order.customer.name'));\nWATCH('order.total', () => console.log('order.total'));\n\nSET('order.customer', { name: 'Ana' });\n```\n\n```text\norder\norder.customer\norder.customer.name\n```\n\nL'observateur de `order.total` ne s'exécute pas, car `order.customer` n'est ni son parent ni son enfant.\n\n## Modifier directement le modèle de données\n\nLe modèle de données est un simple objet : tu peux donc le modifier en JavaScript classique. La bibliothèque ne voit pas ce genre de changement. Appelle `UPD(path)` pour le signaler :\n\n```js\nSET('todo.items', ['Write']);\n\nWATCH('todo.items', function(value, flags, path) {\n\tconsole.log(path, value.length);\n});\n\n// Changing the object directly notifies nobody\ntodo.items.push('Test');\n\n// UPD() tells everybody that the value has changed\nUPD('todo.items');\n```\n\n```text\ntodo.items 2\n```\n\n## Observer un path\n\n`WATCH(path, callback, [init])` exécute une fonction chaque fois que la valeur du path change. `UNWATCH(path, [callback])` retire l'observateur. Sans l'argument `callback`, il retire tous les observateurs du path.\n\nLe callback reçoit trois arguments :\n\n| Argument | Description |\n| --- | --- |\n| `value` | La valeur actuelle du path observé |\n| `flags` | Un objet contenant les [flags](../flags/) de l'opération |\n| `path` | Le path qui a été modifié, qui peut être un parent ou un enfant du path observé |\n\n```js\nfunction onchange(value, flags, path) {\n\tconsole.log(path, value);\n}\n\nWATCH('stats.visits', onchange);\nSET('stats.visits', 1);\n\nUNWATCH('stats.visits', onchange);\nSET('stats.visits', 2);\n\n// Several paths with one callback\nWATCH('stats.a + stats.b', onchange);\nSET('stats.a', 10);\nSET('stats.b', 20);\n\n// The third argument calls the callback right after the registration\nSET('stats.c', 30);\nWATCH('stats.c', onchange, true);\n```\n\n```text\nstats.visits 1\nstats.a 10\nstats.b 20\nstats.c 30\n```\n\nPour afficher une valeur sur la page, tu n'as pas besoin d'un observateur. Utilise la [liaison de données](../data-binding/).\n\n## Raccourcis\n\nLes paths acceptent des préfixes pour les emplacements courants du modèle de données, comme `*title` pour `common.title`. Ils sont décrits dans [Flags et modificateurs de path](../flags/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNa1wd61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/paths/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Path","summary":"Come indirizzare, leggere, modificare e osservare i valori del modello con path sotto forma di stringa.","markdown":"---\ntitle: Path\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/paths/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Path\n\n> Come indirizzare, leggere, modificare e osservare i valori del modello con path sotto forma di stringa.\n\nUn path è una stringa che indirizza un valore nell'oggetto globale `window`: `app.user.name` è lo stesso valore di `window.app.user.name`. In jComponent tutti i dati vengono letti e scritti tramite i path: è così che la libreria sa che cosa è cambiato e chi deve esserne informato.\n\n## Leggere e scrivere valori\n\n`SET(path, value)` scrive un valore e avvisa tutto ciò che dipende dal path. `GET(path)` legge un valore.\n\n```js\nSET('app.user.name', 'Ana');\n\nconsole.log(app.user.name);\nconsole.log(GET('app.user.name'));\nconsole.log(GET('app.user'));\nconsole.log(GET('app.company.name'));\n```\n\n```text\nAna\nAna\n{\"name\":\"Ana\"}\nundefined\n```\n\n`SET()` crea gli oggetti mancanti lungo il path. `GET()` restituisce `undefined` quando una parte del path non esiste.\n\nLa prima parte di un path è una variabile globale, quindi scegli un nome che il browser non usi già. Nomi come `name`, `location` o `status` appartengono a `window`.\n\n## Sintassi dei path\n\n| Path | Significato |\n| --- | --- |\n| `app.user.name` | Una chiave annidata |\n| `shop.products[1].name` | Una chiave di un elemento esistente di un array |\n| `shop.tags[]` | Con `SET()`, aggiunge il valore in fondo a un array e crea l'array se manca |\n| `shop.prices['pen.blue']` | Una chiave che contiene un punto |\n\n```js\nSET('shop.products', [{ name: 'Pen' }, { name: 'Book' }]);\nSET('shop.products[1].name', 'Notebook');\nconsole.log(GET('shop.products[1].name'));\n\nSET('shop.tags[]', 'new');\nSET('shop.tags[]', 'sale');\nconsole.log(GET('shop.tags'));\n\nSET(\"shop.prices['pen.blue']\", 12);\nconsole.log(GET(\"shop.prices['pen.blue']\"));\n```\n\n```text\nNotebook\n[\"new\",\"sale\"]\n12\n```\n\n## Modificare i valori\n\n| Funzione | Che cosa fa |\n| --- | --- |\n| `SET(path, value)` | Scrive un valore |\n| `INC(path, [value])` | Aggiunge un numero al valore, `1` se non indicato |\n| `TOGGLE(path)` | Nega il valore |\n| `PUSH(path, value)` | Aggiunge un valore in fondo a un array esistente. Con il prefisso `^`, il valore va all'inizio dell'array |\n| `NUL(path)` | Scrive `null` |\n\n```js\nSET('cart.count', 1);\nINC('cart.count');\nINC('cart.count', 5);\nconsole.log(cart.count);\n\nTOGGLE('cart.open');\nconsole.log(cart.open);\n\nSET('cart.items', ['b']);\nPUSH('cart.items', 'c');\nPUSH('^cart.items', 'a');\nconsole.log(cart.items);\n\nNUL('cart.count');\nconsole.log(cart.count);\n```\n\n```text\n7\ntrue\n[\"a\",\"b\",\"c\"]\nnull\n```\n\n## Chi viene avvisato\n\nUna modifica raggiunge chi è in ascolto sullo stesso path, sui path genitori e sui path figli. Chi è in ascolto sui path fratelli non viene coinvolto.\n\n```js\nWATCH('order', () => console.log('order'));\nWATCH('order.customer', () => console.log('order.customer'));\nWATCH('order.customer.name', () => console.log('order.customer.name'));\nWATCH('order.total', () => console.log('order.total'));\n\nSET('order.customer', { name: 'Ana' });\n```\n\n```text\norder\norder.customer\norder.customer.name\n```\n\nL'osservatore di `order.total` non viene eseguito, perché `order.customer` non è né il suo genitore né suo figlio.\n\n## Modificare direttamente il modello\n\nIl modello è un semplice oggetto, quindi puoi modificarlo con il normale JavaScript. La libreria però non vede questa modifica. Chiama `UPD(path)` per annunciarla:\n\n```js\nSET('todo.items', ['Write']);\n\nWATCH('todo.items', function(value, flags, path) {\n\tconsole.log(path, value.length);\n});\n\n// Changing the object directly notifies nobody\ntodo.items.push('Test');\n\n// UPD() tells everybody that the value has changed\nUPD('todo.items');\n```\n\n```text\ntodo.items 2\n```\n\n## Osservare un path\n\n`WATCH(path, callback, [init])` esegue una funzione ogni volta che il valore nel path cambia. `UNWATCH(path, [callback])` rimuove l'osservatore. Senza l'argomento `callback`, rimuove tutti gli osservatori del path.\n\nLa callback riceve tre argomenti:\n\n| Argomento | Descrizione |\n| --- | --- |\n| `value` | Il valore corrente nel path osservato |\n| `flags` | Un oggetto con i [flag](../flags/) dell'operazione |\n| `path` | Il path modificato, che può essere un genitore o un figlio del path osservato |\n\n```js\nfunction onchange(value, flags, path) {\n\tconsole.log(path, value);\n}\n\nWATCH('stats.visits', onchange);\nSET('stats.visits', 1);\n\nUNWATCH('stats.visits', onchange);\nSET('stats.visits', 2);\n\n// Several paths with one callback\nWATCH('stats.a + stats.b', onchange);\nSET('stats.a', 10);\nSET('stats.b', 20);\n\n// The third argument calls the callback right after the registration\nSET('stats.c', 30);\nWATCH('stats.c', onchange, true);\n```\n\n```text\nstats.visits 1\nstats.a 10\nstats.b 20\nstats.c 30\n```\n\nPer visualizzare un valore nella pagina non ti serve un osservatore. Usa l'[associazione dei dati](../data-binding/).\n\n## Scorciatoie\n\nI path supportano prefissi per i punti più comuni del modello, come `*title` per `common.title`. Sono descritti in [Flag e modificatori di path](../flags/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNa1wd61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/paths/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Paths","summary":"Ako pomocou textových path odkazovať na hodnoty modelu, čítať ich, meniť a sledovať.","markdown":"---\ntitle: Paths\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/paths/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Paths\n\n> Ako pomocou textových path odkazovať na hodnoty modelu, čítať ich, meniť a sledovať.\n\nPath je reťazec, ktorý odkazuje na hodnotu v globálnom objekte `window`: `app.user.name` je tá istá hodnota ako `window.app.user.name`. Všetky dáta sa v jComponent čítajú a zapisujú cez path, a preto knižnica vie, čo sa zmenilo a koho má upozorniť.\n\n## Čítanie a zápis hodnôt\n\n`SET(path, value)` zapíše hodnotu a upozorní všetko, čo od danej path závisí. `GET(path)` hodnotu prečíta.\n\n```js\nSET('app.user.name', 'Ana');\n\nconsole.log(app.user.name);\nconsole.log(GET('app.user.name'));\nconsole.log(GET('app.user'));\nconsole.log(GET('app.company.name'));\n```\n\n```text\nAna\nAna\n{\"name\":\"Ana\"}\nundefined\n```\n\n`SET()` vytvorí chýbajúce objekty pozdĺž path. `GET()` vráti `undefined`, keď niektorá časť path neexistuje.\n\nPrvá časť path je globálna premenná, preto si vyber názov, ktorý prehliadač ešte nepoužíva. Názvy ako `name`, `location` alebo `status` patria objektu `window`.\n\n## Syntax path\n\n| Path | Význam |\n| --- | --- |\n| `app.user.name` | Vnorený kľúč |\n| `shop.products[1].name` | Kľúč existujúcej položky poľa |\n| `shop.tags[]` | S `SET()` pridá hodnotu na koniec poľa a pole vytvorí, ak chýba |\n| `shop.prices['pen.blue']` | Kľúč, ktorý obsahuje bodku |\n\n```js\nSET('shop.products', [{ name: 'Pen' }, { name: 'Book' }]);\nSET('shop.products[1].name', 'Notebook');\nconsole.log(GET('shop.products[1].name'));\n\nSET('shop.tags[]', 'new');\nSET('shop.tags[]', 'sale');\nconsole.log(GET('shop.tags'));\n\nSET(\"shop.prices['pen.blue']\", 12);\nconsole.log(GET(\"shop.prices['pen.blue']\"));\n```\n\n```text\nNotebook\n[\"new\",\"sale\"]\n12\n```\n\n## Zmena hodnôt\n\n| Funkcia | Čo robí |\n| --- | --- |\n| `SET(path, value)` | Zapíše hodnotu |\n| `INC(path, [value])` | Pripočíta k hodnote číslo, predvolene `1` |\n| `TOGGLE(path)` | Zneguje hodnotu |\n| `PUSH(path, value)` | Pridá hodnotu na koniec existujúceho poľa. S prefixom `^` ide hodnota na začiatok poľa |\n| `NUL(path)` | Zapíše `null` |\n\n```js\nSET('cart.count', 1);\nINC('cart.count');\nINC('cart.count', 5);\nconsole.log(cart.count);\n\nTOGGLE('cart.open');\nconsole.log(cart.open);\n\nSET('cart.items', ['b']);\nPUSH('cart.items', 'c');\nPUSH('^cart.items', 'a');\nconsole.log(cart.items);\n\nNUL('cart.count');\nconsole.log(cart.count);\n```\n\n```text\n7\ntrue\n[\"a\",\"b\",\"c\"]\nnull\n```\n\n## Kto dostane upozornenie\n\nZmena sa dostane k poslucháčom na tej istej path, na jej nadradených path a na jej podradených path. Poslucháčov na súrodeneckých path sa nedotkne.\n\n```js\nWATCH('order', () => console.log('order'));\nWATCH('order.customer', () => console.log('order.customer'));\nWATCH('order.customer.name', () => console.log('order.customer.name'));\nWATCH('order.total', () => console.log('order.total'));\n\nSET('order.customer', { name: 'Ana' });\n```\n\n```text\norder\norder.customer\norder.customer.name\n```\n\nSledovač `order.total` sa nespustí, pretože `order.customer` nie je jeho nadradená ani podradená path.\n\n## Priama zmena modelu\n\nModel je obyčajný objekt, takže ho môžeš meniť bežným JavaScriptom. Knižnica takúto zmenu nevidí. Oznámiš ju zavolaním `UPD(path)`:\n\n```js\nSET('todo.items', ['Write']);\n\nWATCH('todo.items', function(value, flags, path) {\n\tconsole.log(path, value.length);\n});\n\n// Changing the object directly notifies nobody\ntodo.items.push('Test');\n\n// UPD() tells everybody that the value has changed\nUPD('todo.items');\n```\n\n```text\ntodo.items 2\n```\n\n## Sledovanie path\n\n`WATCH(path, callback, [init])` spustí funkciu vždy, keď sa zmení hodnota na danej path. `UNWATCH(path, [callback])` sledovač odstráni. Bez argumentu `callback` odstráni všetky sledovače danej path.\n\nCallback dostane tri argumenty:\n\n| Argument | Popis |\n| --- | --- |\n| `value` | Aktuálna hodnota na sledovanej path |\n| `flags` | Objekt s [flagmi](../flags/) operácie |\n| `path` | Path, ktorá sa zmenila. Môže byť nadradená alebo podradená sledovanej path |\n\n```js\nfunction onchange(value, flags, path) {\n\tconsole.log(path, value);\n}\n\nWATCH('stats.visits', onchange);\nSET('stats.visits', 1);\n\nUNWATCH('stats.visits', onchange);\nSET('stats.visits', 2);\n\n// Several paths with one callback\nWATCH('stats.a + stats.b', onchange);\nSET('stats.a', 10);\nSET('stats.b', 20);\n\n// The third argument calls the callback right after the registration\nSET('stats.c', 30);\nWATCH('stats.c', onchange, true);\n```\n\n```text\nstats.visits 1\nstats.a 10\nstats.b 20\nstats.c 30\n```\n\nNa zobrazenie hodnoty na stránke sledovač nepotrebuješ. Použi [dátovú väzbu](../data-binding/).\n\n## Skratky\n\nPath podporujú prefixy pre bežné miesta v modeli, napríklad `*title` pre `common.title`. Opisuje ich časť [Flagy a modifikátory path](../flags/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNH1kd61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/flags/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Flags and path modifiers","summary":"How flags change the behaviour of an operation on a path and how path modifiers shorten paths.","markdown":"---\ntitle: Flags and path modifiers\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/flags/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Flags and path modifiers\n\n> How flags change the behaviour of an operation on a path and how path modifiers shorten paths.\n\nA flag is a word that starts with `@` and follows a path, separated by a space: `SET('form.name @change', 'Ana')`. Flags tell the library, the components and your own code how to treat the operation. A path modifier is a character that changes what the path points to, such as `*` in `*title`.\n\n## Passing flags\n\nAdd any number of flags after the path. Watchers and component setters receive them as an object. A flag can carry a value in the form `@name:value`.\n\n```js\nWATCH('form.name', function(value, flags) {\n\tconsole.log(value, flags);\n});\n\nSET('form.name @mine', 'Ana');\nSET('form.name @mode:edit @type:3', 'Peter');\n```\n\n```text\nAna {\"mine\":1}\nPeter {\"mode\":\"edit\",\"type\":3}\n```\n\nThe value of the flag `@type` is converted to a number when it starts with a digit. Values of other flags stay strings.\n\n## Flags for the state of components\n\nEach component tracks whether the user has touched and modified it. These flags change that state for all components on the path:\n\n| Flag | Effect |\n| --- | --- |\n| `@change`, `@touch`, `@modify`, `@modified` | Marks the components as touched and modified |\n| `@reset` | Clears the touched and modified state |\n| `@default` | Clears the state and fills empty values from the `default` attribute of the component |\n\n```html\n<ui-component id=\"name\" name=\"field\" path=\"form.name\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tvar el = document.getElementById('name');\n\n\tSET('form.name @change', 'Ana');\n\tconsole.log(el.className);\n\n\tSET('form.name @reset', 'Peter');\n\tconsole.log('[' + el.className + ']');\n\n\tSET('form.name @touch', 'Eva');\n\tconsole.log(el.className);\n\n\tGET('form.name @reset');\n\tconsole.log('[' + el.className + ']');\n});\n```\n\n```text\nui-touched ui-modified\n[]\nui-touched ui-modified\n[]\n```\n\nThe state is visible in the CSS classes `ui-touched` and `ui-modified`. `GET()` with a flag notifies the path and returns the value, so `GET('form.name @reset')` resets the state without changing the data. `RESET(path)` does the same for a whole path.\n\nThe flag `@default` uses the value of the `default` attribute when the model contains `null` or `undefined`:\n\n```html\n<ui-component name=\"field\" path=\"form.age\" default=\"18\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tSET('form.age', 30);\n\tconsole.log(form.age);\n\n\tSET('form.age @default', null);\n\tconsole.log(form.age);\n});\n```\n\n```text\n30\n18\n```\n\n## Filtering components\n\n`COMPONENTS(path)` returns the components on a path. Flags limit the result:\n\n| Flag | Returns the components that are |\n| --- | --- |\n| `@touched` | touched |\n| `@modified` | modified |\n| `@required` | configured with `required:true` |\n| `@invalid` | invalid |\n| `@valid` | valid |\n| `@disabled` | disabled |\n| `@enabled` | not disabled |\n| `@visible` | visible on the page |\n| `@hidden` | hidden on the page |\n\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\n```js\nCOMPONENT('field', function(self, config) {\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n});\nON('ready', function() {\n\tSET('form.name @change', 'Ana');\n\n\tconst names = list => list.map(com => com.path.toString());\n\n\tconsole.log(names(COMPONENTS('form')));\n\tconsole.log(names(COMPONENTS('form @required')));\n\tconsole.log(names(COMPONENTS('form @invalid')));\n\tconsole.log(names(COMPONENTS('form @modified')));\n\tconsole.log(names(COMPONENTS('form @disabled')));\n});\n```\n\n```text\n[\"form.name\",\"form.email\",\"form.note\"]\n[\"form.name\",\"form.email\"]\n[\"form.email\"]\n[\"form.name\"]\n[\"form.note\"]\n```\n\n[Forms and validation](../forms/) shows how to use the state in a form.\n\n## Waiting for a target\n\n`EXEC()` and `SETTER()` do nothing when the function or the component does not exist yet. With the flag `@important`, they try again every 500 milliseconds until the target appears.\n\n```js\nEXEC('FUNC.start @important', 'now');\n\nsetTimeout(function() {\n\tFUNC.start = function(value) {\n\t\tconsole.log('started', value);\n\t};\n}, 100);\n```\n\n```text\nstarted now\n```\n\n## Custom flags\n\nA custom flag emits the event `@flag name`, and the handler receives the path. `UPD()`, `EMIT()` and `FLAGS(flags, [callback])` accept custom flags:\n\n```js\nON('@flag saved', function(path) {\n\tconsole.log('saved:', path);\n});\n\nSET('invoice.total', 100);\nUPD('invoice.total @saved');\n\nFLAGS('@saved @other', function() {\n\tconsole.log('flags processed');\n});\n\nEMIT('finished @saved');\n```\n\n```text\nsaved: invoice.total\nsaved:\nflags processed\nsaved:\n```\n\n## Path modifiers\n\n| Modifier | Example | Points to |\n| --- | --- | --- |\n| `*` | `*title` | `common.title` |\n| `%` | `%search` | `DEF.tmp.search`, a place for temporary values |\n| `#` | `#languages` | `DEF.cl.languages`, a code list |\n| `[key]` | `[section].count` | The part in brackets is replaced by the environment value set with `ENV()` |\n| ` #name` | `user.language #languages` | With `SET()`, the value is written after the code list `languages` has loaded |\n\n```html\n<ui-bind id=\"a\" path=\"*title\" config=\"text\"></ui-bind>\n<ui-bind id=\"b\" path=\"#languages\" config=\"text:value.length\"></ui-bind>\n```\n\n```js\nSET('*title', 'Common title');\nconsole.log(common.title);\n\nSET('%search', 'pen');\nconsole.log(DEF.tmp.search);\n\nENV('section', 'invoices');\nSET('[section].count', 5);\nconsole.log(invoices.count);\n\nCLINIT('languages', function(next) {\n\tnext([{ id: 'en' }, { id: 'sk' }]);\n});\n\nSET('user.language #languages', 'sk');\nON('ready', function() {\n\tCL('languages', function() {\n\t\tconsole.log(user.language, GET('#languages').length);\n\t});\n});\n```\n\n```text\nCommon title\npen\n5\nsk 2\n```\n\n`CLINIT(name, callback)` declares how a code list loads, and `CL(name, callback)` runs a function when it is available.\n\n### Paths in plugins\n\n| Modifier | Example | Points to |\n| --- | --- | --- |\n| `?` | `?.name` | The model of the closest parent plugin |\n| `?\\|` | `?\\|title` | A property of the closest parent plugin instance |\n| `\\|` | `contact\\|title` | A property of the plugin registered as `contact` |\n\n```html\n<ui-plugin path=\"contact\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-bind id=\"outside\" path=\"contact|title\" config=\"text\"></ui-bind>\n```\n\n```js\nPLUGIN('contact', function(exports) {\n\texports.title = 'Contact form';\n\texports.make = function() {\n\t\texports.set('name', 'Ana');\n\t};\n});\n```\n\nThe first `<ui-bind>` shows `Ana` and the second shows `Contact form`. Read more in [Plugins](../plugins/).\n\n### Prefixes of functions and elements\n\n| Prefix | Used in | Effect |\n| --- | --- | --- |\n| `^` | `PUSH('^list', value)` | Inserts the value at the start of the array |\n| `!` | `<ui-bind path=\"!user.name\">` | Skips rendering while the value is `null` or `undefined` |\n| `!` | `SETTER('!dialog/open')` | Does not create a [lazy component](../using-components/) |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNH1kd61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/flags/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Flags und Path-Modifikatoren","summary":"Wie Flags das Verhalten einer Operation auf einem Path ändern und wie Path-Modifikatoren Paths verkürzen.","markdown":"---\ntitle: Flags und Path-Modifikatoren\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/flags/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Flags und Path-Modifikatoren\n\n> Wie Flags das Verhalten einer Operation auf einem Path ändern und wie Path-Modifikatoren Paths verkürzen.\n\nEin Flag ist ein Wort, das mit `@` beginnt und durch ein Leerzeichen getrennt auf einen Path folgt: `SET('form.name @change', 'Ana')`. Flags teilen der Bibliothek, den Komponenten und deinem eigenen Code mit, wie die Operation zu behandeln ist. Ein Path-Modifikator ist ein Zeichen, das ändert, worauf der Path zeigt, wie `*` in `*title`.\n\n## Flags übergeben\n\nHänge beliebig viele Flags an den Path an. Watcher und Setter von Komponenten erhalten sie als Objekt. Ein Flag kann in der Form `@name:value` einen Wert mitführen.\n\n```js\nWATCH('form.name', function(value, flags) {\n\tconsole.log(value, flags);\n});\n\nSET('form.name @mine', 'Ana');\nSET('form.name @mode:edit @type:3', 'Peter');\n```\n\n```text\nAna {\"mine\":1}\nPeter {\"mode\":\"edit\",\"type\":3}\n```\n\nDer Wert des Flags `@type` wird in eine Zahl umgewandelt, wenn er mit einer Ziffer beginnt. Die Werte anderer Flags bleiben Strings.\n\n## Flags für den Zustand von Komponenten\n\nJede Komponente merkt sich, ob der Benutzer sie berührt und geändert hat. Diese Flags ändern diesen Zustand für alle Komponenten auf dem Path:\n\n| Flag | Wirkung |\n| --- | --- |\n| `@change`, `@touch`, `@modify`, `@modified` | Markiert die Komponenten als berührt und geändert |\n| `@reset` | Löscht den Zustand „berührt“ und „geändert“ |\n| `@default` | Löscht den Zustand und füllt leere Werte aus dem Attribut `default` der Komponente |\n\n```html\n<ui-component id=\"name\" name=\"field\" path=\"form.name\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tvar el = document.getElementById('name');\n\n\tSET('form.name @change', 'Ana');\n\tconsole.log(el.className);\n\n\tSET('form.name @reset', 'Peter');\n\tconsole.log('[' + el.className + ']');\n\n\tSET('form.name @touch', 'Eva');\n\tconsole.log(el.className);\n\n\tGET('form.name @reset');\n\tconsole.log('[' + el.className + ']');\n});\n```\n\n```text\nui-touched ui-modified\n[]\nui-touched ui-modified\n[]\n```\n\nDer Zustand ist an den CSS-Klassen `ui-touched` und `ui-modified` erkennbar. `GET()` mit einem Flag benachrichtigt den Path und gibt den Wert zurück, `GET('form.name @reset')` setzt also den Zustand zurück, ohne die Daten zu ändern. `RESET(path)` macht das Gleiche für einen ganzen Path.\n\nDas Flag `@default` verwendet den Wert des Attributs `default`, wenn das Modell `null` oder `undefined` enthält:\n\n```html\n<ui-component name=\"field\" path=\"form.age\" default=\"18\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tSET('form.age', 30);\n\tconsole.log(form.age);\n\n\tSET('form.age @default', null);\n\tconsole.log(form.age);\n});\n```\n\n```text\n30\n18\n```\n\n## Komponenten filtern\n\n`COMPONENTS(path)` gibt die Komponenten auf einem Path zurück. Flags schränken das Ergebnis ein:\n\n| Flag | Gibt die Komponenten zurück, die |\n| --- | --- |\n| `@touched` | berührt sind |\n| `@modified` | geändert sind |\n| `@required` | mit `required:true` konfiguriert sind |\n| `@invalid` | ungültig sind |\n| `@valid` | gültig sind |\n| `@disabled` | deaktiviert sind |\n| `@enabled` | nicht deaktiviert sind |\n| `@visible` | auf der Seite sichtbar sind |\n| `@hidden` | auf der Seite ausgeblendet sind |\n\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\n```js\nCOMPONENT('field', function(self, config) {\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n});\nON('ready', function() {\n\tSET('form.name @change', 'Ana');\n\n\tconst names = list => list.map(com => com.path.toString());\n\n\tconsole.log(names(COMPONENTS('form')));\n\tconsole.log(names(COMPONENTS('form @required')));\n\tconsole.log(names(COMPONENTS('form @invalid')));\n\tconsole.log(names(COMPONENTS('form @modified')));\n\tconsole.log(names(COMPONENTS('form @disabled')));\n});\n```\n\n```text\n[\"form.name\",\"form.email\",\"form.note\"]\n[\"form.name\",\"form.email\"]\n[\"form.email\"]\n[\"form.name\"]\n[\"form.note\"]\n```\n\n[Formulare und Validierung](../forms/) zeigt, wie du den Zustand in einem Formular nutzt.\n\n## Auf ein Ziel warten\n\n`EXEC()` und `SETTER()` machen nichts, solange die Funktion oder die Komponente noch nicht existiert. Mit dem Flag `@important` versuchen sie es alle 500 Millisekunden erneut, bis das Ziel erscheint.\n\n```js\nEXEC('FUNC.start @important', 'now');\n\nsetTimeout(function() {\n\tFUNC.start = function(value) {\n\t\tconsole.log('started', value);\n\t};\n}, 100);\n```\n\n```text\nstarted now\n```\n\n## Eigene Flags\n\nEin eigenes Flag löst das Event `@flag name` aus, und der Handler erhält den Path. `UPD()`, `EMIT()` und `FLAGS(flags, [callback])` akzeptieren eigene Flags:\n\n```js\nON('@flag saved', function(path) {\n\tconsole.log('saved:', path);\n});\n\nSET('invoice.total', 100);\nUPD('invoice.total @saved');\n\nFLAGS('@saved @other', function() {\n\tconsole.log('flags processed');\n});\n\nEMIT('finished @saved');\n```\n\n```text\nsaved: invoice.total\nsaved:\nflags processed\nsaved:\n```\n\n## Path-Modifikatoren\n\n| Modifikator | Beispiel | Zeigt auf |\n| --- | --- | --- |\n| `*` | `*title` | `common.title` |\n| `%` | `%search` | `DEF.tmp.search`, einen Ort für temporäre Werte |\n| `#` | `#languages` | `DEF.cl.languages`, eine Codeliste |\n| `[key]` | `[section].count` | Der Teil in eckigen Klammern wird durch den mit `ENV()` gesetzten Umgebungswert ersetzt |\n| ` #name` | `user.language #languages` | Mit `SET()` wird der Wert geschrieben, nachdem die Codeliste `languages` geladen wurde |\n\n```html\n<ui-bind id=\"a\" path=\"*title\" config=\"text\"></ui-bind>\n<ui-bind id=\"b\" path=\"#languages\" config=\"text:value.length\"></ui-bind>\n```\n\n```js\nSET('*title', 'Common title');\nconsole.log(common.title);\n\nSET('%search', 'pen');\nconsole.log(DEF.tmp.search);\n\nENV('section', 'invoices');\nSET('[section].count', 5);\nconsole.log(invoices.count);\n\nCLINIT('languages', function(next) {\n\tnext([{ id: 'en' }, { id: 'sk' }]);\n});\n\nSET('user.language #languages', 'sk');\nON('ready', function() {\n\tCL('languages', function() {\n\t\tconsole.log(user.language, GET('#languages').length);\n\t});\n});\n```\n\n```text\nCommon title\npen\n5\nsk 2\n```\n\n`CLINIT(name, callback)` legt fest, wie eine Codeliste geladen wird, und `CL(name, callback)` führt eine Funktion aus, sobald sie verfügbar ist.\n\n### Paths in Plugins\n\n| Modifikator | Beispiel | Zeigt auf |\n| --- | --- | --- |\n| `?` | `?.name` | Das Modell des nächsten übergeordneten Plugins |\n| `?\\|` | `?\\|title` | Eine Eigenschaft der nächsten übergeordneten Plugin-Instanz |\n| `\\|` | `contact\\|title` | Eine Eigenschaft des als `contact` registrierten Plugins |\n\n```html\n<ui-plugin path=\"contact\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-bind id=\"outside\" path=\"contact|title\" config=\"text\"></ui-bind>\n```\n\n```js\nPLUGIN('contact', function(exports) {\n\texports.title = 'Contact form';\n\texports.make = function() {\n\t\texports.set('name', 'Ana');\n\t};\n});\n```\n\nDas erste `<ui-bind>` zeigt `Ana` und das zweite `Contact form`. Mehr dazu findest du unter [Plugins](../plugins/).\n\n### Präfixe von Funktionen und Elementen\n\n| Präfix | Verwendet in | Wirkung |\n| --- | --- | --- |\n| `^` | `PUSH('^list', value)` | Fügt den Wert am Anfang des Arrays ein |\n| `!` | `<ui-bind path=\"!user.name\">` | Überspringt das Rendern, solange der Wert `null` oder `undefined` ist |\n| `!` | `SETTER('!dialog/open')` | Erstellt keine [Lazy-Komponente](../using-components/) |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNH1kd61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/flags/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Flags y modificadores de path","summary":"Cómo los flags cambian el comportamiento de una operación sobre un path y cómo los modificadores de path acortan los paths.","markdown":"---\ntitle: Flags y modificadores de path\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/flags/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Flags y modificadores de path\n\n> Cómo los flags cambian el comportamiento de una operación sobre un path y cómo los modificadores de path acortan los paths.\n\nUn flag es una palabra que empieza por `@` y va detrás de un path, separada por un espacio: `SET('form.name @change', 'Ana')`. Los flags indican a la biblioteca, a los componentes y a tu propio código cómo tratar la operación. Un modificador de path es un carácter que cambia aquello a lo que apunta el path, como `*` en `*title`.\n\n## Pasar flags\n\nAñade tantos flags como quieras detrás del path. Los observadores y los setters de los componentes los reciben como un objeto. Un flag puede llevar un valor con la forma `@name:value`.\n\n```js\nWATCH('form.name', function(value, flags) {\n\tconsole.log(value, flags);\n});\n\nSET('form.name @mine', 'Ana');\nSET('form.name @mode:edit @type:3', 'Peter');\n```\n\n```text\nAna {\"mine\":1}\nPeter {\"mode\":\"edit\",\"type\":3}\n```\n\nEl valor del flag `@type` se convierte en número cuando empieza por un dígito. Los valores de los demás flags siguen siendo cadenas.\n\n## Flags para el estado de los componentes\n\nCada componente registra si el usuario lo ha tocado y modificado. Estos flags cambian ese estado en todos los componentes del path:\n\n| Flag | Efecto |\n| --- | --- |\n| `@change`, `@touch`, `@modify`, `@modified` | Marca los componentes como tocados y modificados |\n| `@reset` | Borra el estado de tocado y modificado |\n| `@default` | Borra el estado y rellena los valores vacíos a partir del atributo `default` del componente |\n\n```html\n<ui-component id=\"name\" name=\"field\" path=\"form.name\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tvar el = document.getElementById('name');\n\n\tSET('form.name @change', 'Ana');\n\tconsole.log(el.className);\n\n\tSET('form.name @reset', 'Peter');\n\tconsole.log('[' + el.className + ']');\n\n\tSET('form.name @touch', 'Eva');\n\tconsole.log(el.className);\n\n\tGET('form.name @reset');\n\tconsole.log('[' + el.className + ']');\n});\n```\n\n```text\nui-touched ui-modified\n[]\nui-touched ui-modified\n[]\n```\n\nEl estado se refleja en las clases CSS `ui-touched` y `ui-modified`. `GET()` con un flag avisa al path y devuelve el valor, de modo que `GET('form.name @reset')` restablece el estado sin cambiar los datos. `RESET(path)` hace lo mismo para todo un path.\n\nEl flag `@default` usa el valor del atributo `default` cuando el modelo contiene `null` o `undefined`:\n\n```html\n<ui-component name=\"field\" path=\"form.age\" default=\"18\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tSET('form.age', 30);\n\tconsole.log(form.age);\n\n\tSET('form.age @default', null);\n\tconsole.log(form.age);\n});\n```\n\n```text\n30\n18\n```\n\n## Filtrar componentes\n\n`COMPONENTS(path)` devuelve los componentes de un path. Los flags limitan el resultado:\n\n| Flag | Devuelve los componentes que están |\n| --- | --- |\n| `@touched` | tocados |\n| `@modified` | modificados |\n| `@required` | configurados con `required:true` |\n| `@invalid` | no válidos |\n| `@valid` | válidos |\n| `@disabled` | desactivados |\n| `@enabled` | no desactivados |\n| `@visible` | visibles en la página |\n| `@hidden` | ocultos en la página |\n\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\n```js\nCOMPONENT('field', function(self, config) {\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n});\nON('ready', function() {\n\tSET('form.name @change', 'Ana');\n\n\tconst names = list => list.map(com => com.path.toString());\n\n\tconsole.log(names(COMPONENTS('form')));\n\tconsole.log(names(COMPONENTS('form @required')));\n\tconsole.log(names(COMPONENTS('form @invalid')));\n\tconsole.log(names(COMPONENTS('form @modified')));\n\tconsole.log(names(COMPONENTS('form @disabled')));\n});\n```\n\n```text\n[\"form.name\",\"form.email\",\"form.note\"]\n[\"form.name\",\"form.email\"]\n[\"form.email\"]\n[\"form.name\"]\n[\"form.note\"]\n```\n\n[Formularios y validación](../forms/) muestra cómo usar el estado en un formulario.\n\n## Esperar a un destino\n\n`EXEC()` y `SETTER()` no hacen nada cuando la función o el componente todavía no existen. Con el flag `@important`, lo reintentan cada 500 milisegundos hasta que aparece el destino.\n\n```js\nEXEC('FUNC.start @important', 'now');\n\nsetTimeout(function() {\n\tFUNC.start = function(value) {\n\t\tconsole.log('started', value);\n\t};\n}, 100);\n```\n\n```text\nstarted now\n```\n\n## Flags personalizados\n\nUn flag personalizado emite el evento `@flag name`, y el manejador recibe el path. `UPD()`, `EMIT()` y `FLAGS(flags, [callback])` aceptan flags personalizados:\n\n```js\nON('@flag saved', function(path) {\n\tconsole.log('saved:', path);\n});\n\nSET('invoice.total', 100);\nUPD('invoice.total @saved');\n\nFLAGS('@saved @other', function() {\n\tconsole.log('flags processed');\n});\n\nEMIT('finished @saved');\n```\n\n```text\nsaved: invoice.total\nsaved:\nflags processed\nsaved:\n```\n\n## Modificadores de path\n\n| Modificador | Ejemplo | Apunta a |\n| --- | --- | --- |\n| `*` | `*title` | `common.title` |\n| `%` | `%search` | `DEF.tmp.search`, un lugar para valores temporales |\n| `#` | `#languages` | `DEF.cl.languages`, una lista de códigos |\n| `[key]` | `[section].count` | La parte entre corchetes se sustituye por el valor de entorno definido con `ENV()` |\n| ` #name` | `user.language #languages` | Con `SET()`, el valor se escribe cuando se ha cargado la lista de códigos `languages` |\n\n```html\n<ui-bind id=\"a\" path=\"*title\" config=\"text\"></ui-bind>\n<ui-bind id=\"b\" path=\"#languages\" config=\"text:value.length\"></ui-bind>\n```\n\n```js\nSET('*title', 'Common title');\nconsole.log(common.title);\n\nSET('%search', 'pen');\nconsole.log(DEF.tmp.search);\n\nENV('section', 'invoices');\nSET('[section].count', 5);\nconsole.log(invoices.count);\n\nCLINIT('languages', function(next) {\n\tnext([{ id: 'en' }, { id: 'sk' }]);\n});\n\nSET('user.language #languages', 'sk');\nON('ready', function() {\n\tCL('languages', function() {\n\t\tconsole.log(user.language, GET('#languages').length);\n\t});\n});\n```\n\n```text\nCommon title\npen\n5\nsk 2\n```\n\n`CLINIT(name, callback)` declara cómo se carga una lista de códigos, y `CL(name, callback)` ejecuta una función cuando está disponible.\n\n### Paths en plugins\n\n| Modificador | Ejemplo | Apunta a |\n| --- | --- | --- |\n| `?` | `?.name` | El modelo del plugin padre más cercano |\n| `?\\|` | `?\\|title` | Una propiedad de la instancia del plugin padre más cercano |\n| `\\|` | `contact\\|title` | Una propiedad del plugin registrado como `contact` |\n\n```html\n<ui-plugin path=\"contact\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-bind id=\"outside\" path=\"contact|title\" config=\"text\"></ui-bind>\n```\n\n```js\nPLUGIN('contact', function(exports) {\n\texports.title = 'Contact form';\n\texports.make = function() {\n\t\texports.set('name', 'Ana');\n\t};\n});\n```\n\nEl primer `<ui-bind>` muestra `Ana` y el segundo muestra `Contact form`. Lee más en [Plugins](../plugins/).\n\n### Prefijos de funciones y elementos\n\n| Prefijo | Se usa en | Efecto |\n| --- | --- | --- |\n| `^` | `PUSH('^list', value)` | Inserta el valor al principio del array |\n| `!` | `<ui-bind path=\"!user.name\">` | No renderiza mientras el valor sea `null` o `undefined` |\n| `!` | `SETTER('!dialog/open')` | No crea un [componente diferido](../using-components/) |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNH1kd61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/flags/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Flags et modificateurs de path","summary":"Comment les flags modifient le comportement d'une opération sur un path et comment les modificateurs de path raccourcissent les paths.","markdown":"---\ntitle: Flags et modificateurs de path\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/flags/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Flags et modificateurs de path\n\n> Comment les flags modifient le comportement d'une opération sur un path et comment les modificateurs de path raccourcissent les paths.\n\nUn flag est un mot qui commence par `@` et qui suit un path, séparé par une espace : `SET('form.name @change', 'Ana')`. Les flags indiquent à la bibliothèque, aux composants et à ton propre code comment traiter l'opération. Un modificateur de path est un caractère qui change ce que désigne le path, comme `*` dans `*title`.\n\n## Passer des flags\n\nAjoute autant de flags que tu veux après le path. Les observateurs et les setters des composants les reçoivent sous forme d'objet. Un flag peut porter une valeur sous la forme `@name:value`.\n\n```js\nWATCH('form.name', function(value, flags) {\n\tconsole.log(value, flags);\n});\n\nSET('form.name @mine', 'Ana');\nSET('form.name @mode:edit @type:3', 'Peter');\n```\n\n```text\nAna {\"mine\":1}\nPeter {\"mode\":\"edit\",\"type\":3}\n```\n\nLa valeur du flag `@type` est convertie en nombre quand elle commence par un chiffre. Les valeurs des autres flags restent des chaînes.\n\n## Flags pour l'état des composants\n\nChaque composant retient si l'utilisateur l'a touché et modifié. Ces flags changent cet état pour tous les composants du path :\n\n| Flag | Effet |\n| --- | --- |\n| `@change`, `@touch`, `@modify`, `@modified` | Marque les composants comme touchés et modifiés |\n| `@reset` | Efface l'état touché et modifié |\n| `@default` | Efface l'état et remplit les valeurs vides à partir de l'attribut `default` du composant |\n\n```html\n<ui-component id=\"name\" name=\"field\" path=\"form.name\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tvar el = document.getElementById('name');\n\n\tSET('form.name @change', 'Ana');\n\tconsole.log(el.className);\n\n\tSET('form.name @reset', 'Peter');\n\tconsole.log('[' + el.className + ']');\n\n\tSET('form.name @touch', 'Eva');\n\tconsole.log(el.className);\n\n\tGET('form.name @reset');\n\tconsole.log('[' + el.className + ']');\n});\n```\n\n```text\nui-touched ui-modified\n[]\nui-touched ui-modified\n[]\n```\n\nL'état est visible dans les classes CSS `ui-touched` et `ui-modified`. `GET()` avec un flag prévient le path et renvoie la valeur : `GET('form.name @reset')` réinitialise donc l'état sans modifier les données. `RESET(path)` fait la même chose pour un path entier.\n\nLe flag `@default` utilise la valeur de l'attribut `default` quand le modèle de données contient `null` ou `undefined` :\n\n```html\n<ui-component name=\"field\" path=\"form.age\" default=\"18\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tSET('form.age', 30);\n\tconsole.log(form.age);\n\n\tSET('form.age @default', null);\n\tconsole.log(form.age);\n});\n```\n\n```text\n30\n18\n```\n\n## Filtrer les composants\n\n`COMPONENTS(path)` renvoie les composants d'un path. Les flags limitent le résultat :\n\n| Flag | Renvoie les composants qui sont |\n| --- | --- |\n| `@touched` | touchés |\n| `@modified` | modifiés |\n| `@required` | configurés avec `required:true` |\n| `@invalid` | invalides |\n| `@valid` | valides |\n| `@disabled` | désactivés |\n| `@enabled` | non désactivés |\n| `@visible` | visibles sur la page |\n| `@hidden` | masqués sur la page |\n\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\n```js\nCOMPONENT('field', function(self, config) {\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n});\nON('ready', function() {\n\tSET('form.name @change', 'Ana');\n\n\tconst names = list => list.map(com => com.path.toString());\n\n\tconsole.log(names(COMPONENTS('form')));\n\tconsole.log(names(COMPONENTS('form @required')));\n\tconsole.log(names(COMPONENTS('form @invalid')));\n\tconsole.log(names(COMPONENTS('form @modified')));\n\tconsole.log(names(COMPONENTS('form @disabled')));\n});\n```\n\n```text\n[\"form.name\",\"form.email\",\"form.note\"]\n[\"form.name\",\"form.email\"]\n[\"form.email\"]\n[\"form.name\"]\n[\"form.note\"]\n```\n\n[Formulaires et validation](../forms/) montre comment utiliser l'état dans un formulaire.\n\n## Attendre une cible\n\n`EXEC()` et `SETTER()` ne font rien quand la fonction ou le composant n'existe pas encore. Avec le flag `@important`, ils réessaient toutes les 500 millisecondes jusqu'à ce que la cible apparaisse.\n\n```js\nEXEC('FUNC.start @important', 'now');\n\nsetTimeout(function() {\n\tFUNC.start = function(value) {\n\t\tconsole.log('started', value);\n\t};\n}, 100);\n```\n\n```text\nstarted now\n```\n\n## Flags personnalisés\n\nUn flag personnalisé émet l'événement `@flag name`, et le gestionnaire reçoit le path. `UPD()`, `EMIT()` et `FLAGS(flags, [callback])` acceptent les flags personnalisés :\n\n```js\nON('@flag saved', function(path) {\n\tconsole.log('saved:', path);\n});\n\nSET('invoice.total', 100);\nUPD('invoice.total @saved');\n\nFLAGS('@saved @other', function() {\n\tconsole.log('flags processed');\n});\n\nEMIT('finished @saved');\n```\n\n```text\nsaved: invoice.total\nsaved:\nflags processed\nsaved:\n```\n\n## Modificateurs de path\n\n| Modificateur | Exemple | Désigne |\n| --- | --- | --- |\n| `*` | `*title` | `common.title` |\n| `%` | `%search` | `DEF.tmp.search`, un emplacement pour les valeurs temporaires |\n| `#` | `#languages` | `DEF.cl.languages`, une liste de codes |\n| `[key]` | `[section].count` | La partie entre crochets est remplacée par la valeur d'environnement définie avec `ENV()` |\n| ` #name` | `user.language #languages` | Avec `SET()`, la valeur est écrite une fois la liste de codes `languages` chargée |\n\n```html\n<ui-bind id=\"a\" path=\"*title\" config=\"text\"></ui-bind>\n<ui-bind id=\"b\" path=\"#languages\" config=\"text:value.length\"></ui-bind>\n```\n\n```js\nSET('*title', 'Common title');\nconsole.log(common.title);\n\nSET('%search', 'pen');\nconsole.log(DEF.tmp.search);\n\nENV('section', 'invoices');\nSET('[section].count', 5);\nconsole.log(invoices.count);\n\nCLINIT('languages', function(next) {\n\tnext([{ id: 'en' }, { id: 'sk' }]);\n});\n\nSET('user.language #languages', 'sk');\nON('ready', function() {\n\tCL('languages', function() {\n\t\tconsole.log(user.language, GET('#languages').length);\n\t});\n});\n```\n\n```text\nCommon title\npen\n5\nsk 2\n```\n\n`CLINIT(name, callback)` déclare comment une liste de codes se charge, et `CL(name, callback)` exécute une fonction quand elle est disponible.\n\n### Paths dans les plugins\n\n| Modificateur | Exemple | Désigne |\n| --- | --- | --- |\n| `?` | `?.name` | Le modèle de données du plugin parent le plus proche |\n| `?\\|` | `?\\|title` | Une propriété de l'instance du plugin parent le plus proche |\n| `\\|` | `contact\\|title` | Une propriété du plugin enregistré sous le nom `contact` |\n\n```html\n<ui-plugin path=\"contact\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-bind id=\"outside\" path=\"contact|title\" config=\"text\"></ui-bind>\n```\n\n```js\nPLUGIN('contact', function(exports) {\n\texports.title = 'Contact form';\n\texports.make = function() {\n\t\texports.set('name', 'Ana');\n\t};\n});\n```\n\nLe premier `<ui-bind>` affiche `Ana` et le second `Contact form`. Pour en savoir plus, lis [Plugins](../plugins/).\n\n### Préfixes des fonctions et des éléments\n\n| Préfixe | Utilisé dans | Effet |\n| --- | --- | --- |\n| `^` | `PUSH('^list', value)` | Insère la valeur au début du tableau |\n| `!` | `<ui-bind path=\"!user.name\">` | Ignore l'affichage tant que la valeur est `null` ou `undefined` |\n| `!` | `SETTER('!dialog/open')` | Ne crée pas de [composant différé](../using-components/) |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNH1kd61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/flags/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Flag e modificatori di path","summary":"Come i flag cambiano il comportamento di un'operazione su un path e come i modificatori di path accorciano i path.","markdown":"---\ntitle: Flag e modificatori di path\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/flags/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Flag e modificatori di path\n\n> Come i flag cambiano il comportamento di un'operazione su un path e come i modificatori di path accorciano i path.\n\nUn flag è una parola che inizia con `@` e segue un path, separata da uno spazio: `SET('form.name @change', 'Ana')`. I flag indicano alla libreria, ai componenti e al tuo codice come trattare l'operazione. Un modificatore di path è un carattere che cambia ciò a cui punta il path, come `*` in `*title`.\n\n## Passare i flag\n\nAggiungi dopo il path tutti i flag che vuoi. Gli osservatori e i setter dei componenti li ricevono come oggetto. Un flag può contenere un valore nella forma `@name:value`.\n\n```js\nWATCH('form.name', function(value, flags) {\n\tconsole.log(value, flags);\n});\n\nSET('form.name @mine', 'Ana');\nSET('form.name @mode:edit @type:3', 'Peter');\n```\n\n```text\nAna {\"mine\":1}\nPeter {\"mode\":\"edit\",\"type\":3}\n```\n\nIl valore del flag `@type` viene convertito in numero quando inizia con una cifra. I valori degli altri flag restano stringhe.\n\n## Flag per lo stato dei componenti\n\nOgni componente tiene traccia del fatto che l'utente lo abbia toccato e modificato. Questi flag cambiano tale stato per tutti i componenti sul path:\n\n| Flag | Effetto |\n| --- | --- |\n| `@change`, `@touch`, `@modify`, `@modified` | Segna i componenti come toccati e modificati |\n| `@reset` | Azzera lo stato di toccato e modificato |\n| `@default` | Azzera lo stato e riempie i valori vuoti con l'attributo `default` del componente |\n\n```html\n<ui-component id=\"name\" name=\"field\" path=\"form.name\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tvar el = document.getElementById('name');\n\n\tSET('form.name @change', 'Ana');\n\tconsole.log(el.className);\n\n\tSET('form.name @reset', 'Peter');\n\tconsole.log('[' + el.className + ']');\n\n\tSET('form.name @touch', 'Eva');\n\tconsole.log(el.className);\n\n\tGET('form.name @reset');\n\tconsole.log('[' + el.className + ']');\n});\n```\n\n```text\nui-touched ui-modified\n[]\nui-touched ui-modified\n[]\n```\n\nLo stato è visibile nelle classi CSS `ui-touched` e `ui-modified`. `GET()` con un flag avvisa il path e restituisce il valore, quindi `GET('form.name @reset')` azzera lo stato senza modificare i dati. `RESET(path)` fa lo stesso per un intero path.\n\nIl flag `@default` usa il valore dell'attributo `default` quando il modello contiene `null` o `undefined`:\n\n```html\n<ui-component name=\"field\" path=\"form.age\" default=\"18\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tSET('form.age', 30);\n\tconsole.log(form.age);\n\n\tSET('form.age @default', null);\n\tconsole.log(form.age);\n});\n```\n\n```text\n30\n18\n```\n\n## Filtrare i componenti\n\n`COMPONENTS(path)` restituisce i componenti su un path. I flag limitano il risultato:\n\n| Flag | Restituisce i componenti che sono |\n| --- | --- |\n| `@touched` | toccati |\n| `@modified` | modificati |\n| `@required` | configurati con `required:true` |\n| `@invalid` | non validi |\n| `@valid` | validi |\n| `@disabled` | disabilitati |\n| `@enabled` | non disabilitati |\n| `@visible` | visibili nella pagina |\n| `@hidden` | nascosti nella pagina |\n\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\n```js\nCOMPONENT('field', function(self, config) {\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n});\nON('ready', function() {\n\tSET('form.name @change', 'Ana');\n\n\tconst names = list => list.map(com => com.path.toString());\n\n\tconsole.log(names(COMPONENTS('form')));\n\tconsole.log(names(COMPONENTS('form @required')));\n\tconsole.log(names(COMPONENTS('form @invalid')));\n\tconsole.log(names(COMPONENTS('form @modified')));\n\tconsole.log(names(COMPONENTS('form @disabled')));\n});\n```\n\n```text\n[\"form.name\",\"form.email\",\"form.note\"]\n[\"form.name\",\"form.email\"]\n[\"form.email\"]\n[\"form.name\"]\n[\"form.note\"]\n```\n\n[Moduli e validazione](../forms/) mostra come usare lo stato in un modulo.\n\n## Attendere una destinazione\n\n`EXEC()` e `SETTER()` non fanno nulla quando la funzione o il componente non esiste ancora. Con il flag `@important`, riprovano ogni 500 millisecondi finché la destinazione non compare.\n\n```js\nEXEC('FUNC.start @important', 'now');\n\nsetTimeout(function() {\n\tFUNC.start = function(value) {\n\t\tconsole.log('started', value);\n\t};\n}, 100);\n```\n\n```text\nstarted now\n```\n\n## Flag personalizzati\n\nUn flag personalizzato emette l'evento `@flag name` e il gestore riceve il path. `UPD()`, `EMIT()` e `FLAGS(flags, [callback])` accettano flag personalizzati:\n\n```js\nON('@flag saved', function(path) {\n\tconsole.log('saved:', path);\n});\n\nSET('invoice.total', 100);\nUPD('invoice.total @saved');\n\nFLAGS('@saved @other', function() {\n\tconsole.log('flags processed');\n});\n\nEMIT('finished @saved');\n```\n\n```text\nsaved: invoice.total\nsaved:\nflags processed\nsaved:\n```\n\n## Modificatori di path\n\n| Modificatore | Esempio | Punta a |\n| --- | --- | --- |\n| `*` | `*title` | `common.title` |\n| `%` | `%search` | `DEF.tmp.search`, uno spazio per i valori temporanei |\n| `#` | `#languages` | `DEF.cl.languages`, un elenco di codici |\n| `[key]` | `[section].count` | La parte tra parentesi quadre viene sostituita dal valore d'ambiente impostato con `ENV()` |\n| ` #name` | `user.language #languages` | Con `SET()`, il valore viene scritto dopo il caricamento dell'elenco di codici `languages` |\n\n```html\n<ui-bind id=\"a\" path=\"*title\" config=\"text\"></ui-bind>\n<ui-bind id=\"b\" path=\"#languages\" config=\"text:value.length\"></ui-bind>\n```\n\n```js\nSET('*title', 'Common title');\nconsole.log(common.title);\n\nSET('%search', 'pen');\nconsole.log(DEF.tmp.search);\n\nENV('section', 'invoices');\nSET('[section].count', 5);\nconsole.log(invoices.count);\n\nCLINIT('languages', function(next) {\n\tnext([{ id: 'en' }, { id: 'sk' }]);\n});\n\nSET('user.language #languages', 'sk');\nON('ready', function() {\n\tCL('languages', function() {\n\t\tconsole.log(user.language, GET('#languages').length);\n\t});\n});\n```\n\n```text\nCommon title\npen\n5\nsk 2\n```\n\n`CLINIT(name, callback)` dichiara come si carica un elenco di codici e `CL(name, callback)` esegue una funzione quando questo è disponibile.\n\n### Path nei plugin\n\n| Modificatore | Esempio | Punta a |\n| --- | --- | --- |\n| `?` | `?.name` | Il modello del plugin genitore più vicino |\n| `?\\|` | `?\\|title` | Una proprietà dell'istanza del plugin genitore più vicino |\n| `\\|` | `contact\\|title` | Una proprietà del plugin registrato come `contact` |\n\n```html\n<ui-plugin path=\"contact\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-bind id=\"outside\" path=\"contact|title\" config=\"text\"></ui-bind>\n```\n\n```js\nPLUGIN('contact', function(exports) {\n\texports.title = 'Contact form';\n\texports.make = function() {\n\t\texports.set('name', 'Ana');\n\t};\n});\n```\n\nIl primo `<ui-bind>` mostra `Ana` e il secondo `Contact form`. Approfondisci in [Plugin](../plugins/).\n\n### Prefissi di funzioni ed elementi\n\n| Prefisso | Usato in | Effetto |\n| --- | --- | --- |\n| `^` | `PUSH('^list', value)` | Inserisce il valore all'inizio dell'array |\n| `!` | `<ui-bind path=\"!user.name\">` | Salta la visualizzazione finché il valore è `null` o `undefined` |\n| `!` | `SETTER('!dialog/open')` | Non crea un [componente lazy](../using-components/) |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNH1kd61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/flags/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Flagy a modifikátory path","summary":"Ako flagy menia správanie operácie na path a ako modifikátory path skracujú path.","markdown":"---\ntitle: \"Flagy a modifikátory path\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/flags/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Flagy a modifikátory path\n\n> Ako flagy menia správanie operácie na path a ako modifikátory path skracujú path.\n\nFlag je slovo, ktoré začína znakom `@` a nasleduje za path, oddelené medzerou: `SET('form.name @change', 'Ana')`. Flagy hovoria knižnici, komponentom aj tvojmu kódu, ako má s operáciou naložiť. Modifikátor path je znak, ktorý mení, na čo path ukazuje, napríklad `*` v `*title`.\n\n## Odovzdávanie flagov\n\nZa path pridaj ľubovoľný počet flagov. Sledovače a settery komponentov ich dostanú ako objekt. Flag môže niesť hodnotu v tvare `@name:value`.\n\n```js\nWATCH('form.name', function(value, flags) {\n\tconsole.log(value, flags);\n});\n\nSET('form.name @mine', 'Ana');\nSET('form.name @mode:edit @type:3', 'Peter');\n```\n\n```text\nAna {\"mine\":1}\nPeter {\"mode\":\"edit\",\"type\":3}\n```\n\nHodnota flagu `@type` sa prevedie na číslo, keď začína číslicou. Hodnoty ostatných flagov zostávajú reťazcami.\n\n## Flagy pre stav komponentov\n\nKaždý komponent si eviduje, či sa ho používateľ dotkol a či ho upravil. Tieto flagy menia daný stav všetkých komponentov na path:\n\n| Flag | Účinok |\n| --- | --- |\n| `@change`, `@touch`, `@modify`, `@modified` | Označí komponenty ako dotknuté a upravené |\n| `@reset` | Vymaže stav dotknutia a úpravy |\n| `@default` | Vymaže stav a prázdne hodnoty doplní z atribútu `default` komponentu |\n\n```html\n<ui-component id=\"name\" name=\"field\" path=\"form.name\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tvar el = document.getElementById('name');\n\n\tSET('form.name @change', 'Ana');\n\tconsole.log(el.className);\n\n\tSET('form.name @reset', 'Peter');\n\tconsole.log('[' + el.className + ']');\n\n\tSET('form.name @touch', 'Eva');\n\tconsole.log(el.className);\n\n\tGET('form.name @reset');\n\tconsole.log('[' + el.className + ']');\n});\n```\n\n```text\nui-touched ui-modified\n[]\nui-touched ui-modified\n[]\n```\n\nStav vidno v CSS triedach `ui-touched` a `ui-modified`. `GET()` s flagom upozorní path a vráti hodnotu, takže `GET('form.name @reset')` vynuluje stav bez zmeny dát. `RESET(path)` urobí to isté pre celú path.\n\nFlag `@default` použije hodnotu atribútu `default`, keď model obsahuje `null` alebo `undefined`:\n\n```html\n<ui-component name=\"field\" path=\"form.age\" default=\"18\"></ui-component>\n```\n\n```js\nON('ready', function() {\n\tSET('form.age', 30);\n\tconsole.log(form.age);\n\n\tSET('form.age @default', null);\n\tconsole.log(form.age);\n});\n```\n\n```text\n30\n18\n```\n\n## Filtrovanie komponentov\n\n`COMPONENTS(path)` vráti komponenty na path. Flagy výsledok obmedzia:\n\n| Flag | Vráti komponenty, ktoré sú |\n| --- | --- |\n| `@touched` | dotknuté |\n| `@modified` | upravené |\n| `@required` | nakonfigurované s `required:true` |\n| `@invalid` | neplatné |\n| `@valid` | platné |\n| `@disabled` | vypnuté |\n| `@enabled` | nevypnuté |\n| `@visible` | viditeľné na stránke |\n| `@hidden` | skryté na stránke |\n\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\n```js\nCOMPONENT('field', function(self, config) {\n\tself.validate = function(value) {\n\t\treturn !config.required || !!value;\n\t};\n});\nON('ready', function() {\n\tSET('form.name @change', 'Ana');\n\n\tconst names = list => list.map(com => com.path.toString());\n\n\tconsole.log(names(COMPONENTS('form')));\n\tconsole.log(names(COMPONENTS('form @required')));\n\tconsole.log(names(COMPONENTS('form @invalid')));\n\tconsole.log(names(COMPONENTS('form @modified')));\n\tconsole.log(names(COMPONENTS('form @disabled')));\n});\n```\n\n```text\n[\"form.name\",\"form.email\",\"form.note\"]\n[\"form.name\",\"form.email\"]\n[\"form.email\"]\n[\"form.name\"]\n[\"form.note\"]\n```\n\n[Formuláre a validácia](../forms/) ukazuje, ako stav využiť vo formulári.\n\n## Čakanie na cieľ\n\n`EXEC()` a `SETTER()` neurobia nič, keď funkcia alebo komponent ešte neexistuje. S flagom `@important` to skúšajú znova každých 500 milisekúnd, kým sa cieľ neobjaví.\n\n```js\nEXEC('FUNC.start @important', 'now');\n\nsetTimeout(function() {\n\tFUNC.start = function(value) {\n\t\tconsole.log('started', value);\n\t};\n}, 100);\n```\n\n```text\nstarted now\n```\n\n## Vlastné flagy\n\nVlastný flag vyšle udalosť `@flag name` a obslužná funkcia dostane path. Vlastné flagy prijímajú `UPD()`, `EMIT()` a `FLAGS(flags, [callback])`:\n\n```js\nON('@flag saved', function(path) {\n\tconsole.log('saved:', path);\n});\n\nSET('invoice.total', 100);\nUPD('invoice.total @saved');\n\nFLAGS('@saved @other', function() {\n\tconsole.log('flags processed');\n});\n\nEMIT('finished @saved');\n```\n\n```text\nsaved: invoice.total\nsaved:\nflags processed\nsaved:\n```\n\n## Modifikátory path\n\n| Modifikátor | Príklad | Ukazuje na |\n| --- | --- | --- |\n| `*` | `*title` | `common.title` |\n| `%` | `%search` | `DEF.tmp.search`, miesto pre dočasné hodnoty |\n| `#` | `#languages` | `DEF.cl.languages`, zoznam kódov |\n| `[key]` | `[section].count` | Časť v hranatých zátvorkách sa nahradí hodnotou prostredia nastavenou cez `ENV()` |\n| ` #name` | `user.language #languages` | S `SET()` sa hodnota zapíše až po načítaní zoznamu kódov `languages` |\n\n```html\n<ui-bind id=\"a\" path=\"*title\" config=\"text\"></ui-bind>\n<ui-bind id=\"b\" path=\"#languages\" config=\"text:value.length\"></ui-bind>\n```\n\n```js\nSET('*title', 'Common title');\nconsole.log(common.title);\n\nSET('%search', 'pen');\nconsole.log(DEF.tmp.search);\n\nENV('section', 'invoices');\nSET('[section].count', 5);\nconsole.log(invoices.count);\n\nCLINIT('languages', function(next) {\n\tnext([{ id: 'en' }, { id: 'sk' }]);\n});\n\nSET('user.language #languages', 'sk');\nON('ready', function() {\n\tCL('languages', function() {\n\t\tconsole.log(user.language, GET('#languages').length);\n\t});\n});\n```\n\n```text\nCommon title\npen\n5\nsk 2\n```\n\n`CLINIT(name, callback)` deklaruje, ako sa zoznam kódov načíta, a `CL(name, callback)` spustí funkciu, keď je zoznam dostupný.\n\n### Path v pluginoch\n\n| Modifikátor | Príklad | Ukazuje na |\n| --- | --- | --- |\n| `?` | `?.name` | Model najbližšieho nadradeného pluginu |\n| `?\\|` | `?\\|title` | Vlastnosť inštancie najbližšieho nadradeného pluginu |\n| `\\|` | `contact\\|title` | Vlastnosť pluginu zaregistrovaného ako `contact` |\n\n```html\n<ui-plugin path=\"contact\">\n\t<ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n\n<ui-bind id=\"outside\" path=\"contact|title\" config=\"text\"></ui-bind>\n```\n\n```js\nPLUGIN('contact', function(exports) {\n\texports.title = 'Contact form';\n\texports.make = function() {\n\t\texports.set('name', 'Ana');\n\t};\n});\n```\n\nPrvý `<ui-bind>` zobrazí `Ana` a druhý `Contact form`. Viac sa dočítaš v časti [Pluginy](../plugins/).\n\n### Prefixy funkcií a elementov\n\n| Prefix | Použitie | Účinok |\n| --- | --- | --- |\n| `^` | `PUSH('^list', value)` | Vloží hodnotu na začiatok poľa |\n| `!` | `<ui-bind path=\"!user.name\">` | Preskočí vykresľovanie, kým je hodnota `null` alebo `undefined` |\n| `!` | `SETTER('!dialog/open')` | Nevytvorí [lenivý komponent](../using-components/) |\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNE1id61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/data-binding/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Data binding","summary":"How to render values of the model into the page with ui-bind and keep inputs and the model in sync.","markdown":"---\ntitle: Data binding\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/data-binding/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Data binding\n\n> How to render values of the model into the page with ui-bind and keep inputs and the model in sync.\n\nData binding connects the model to the page. The `<ui-bind>` element renders a value from a path and renders it again whenever the value changes. Components add the opposite direction: they write what the user enters back to the model.\n\n## The ui-bind element\n\n`<ui-bind>` has two main attributes. `path` is the value to listen to and `config` is a list of commands separated by semicolons. A command in the form `name:expression` uses the result of a JavaScript expression. Without an expression, the command uses the value itself.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n<ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n<ui-bind path=\"user.age\" config=\"text:value >= 18 ? 'adult' : 'minor'\"></ui-bind>\n```\n\n```js\nSET('user', { name: 'Ana', age: 30 });\n```\n\nThe three elements show `Ana`, `ANA` and `adult`.\n\nAn expression can use these variables:\n\n| Variable | Description |\n| --- | --- |\n| `value` | The value at the path |\n| `element`, `el` | The target element as a jQuery object |\n| `flags` | The [flags](../flags/) of the operation |\n| `path` | The path that was changed |\n\nInside `config`, write a semicolon as `\\;`:\n\n```html\n<ui-bind path=\"note.text\" config=\"text:value + '\\; ok';title:'Note\\: ' + value\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"exec:FUNC.log\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"text:element.attr('data-prefix') + value\" data-prefix=\"&gt; \"></ui-bind>\n```\n\n## Commands\n\n| Command | Effect |\n| --- | --- |\n| `text` | Sets the text content |\n| `html` | Sets the HTML content |\n| `value` | Sets the value of a form control |\n| `title`, `href`, `src` | Sets the attribute of the same name |\n| `attr name` | Sets the attribute `name` |\n| `.name` | Adds the CSS class `name` when the result is truthy and removes it otherwise |\n| `show` | Adds the class `hidden` when the result is falsy |\n| `hide` | Adds the class `hidden` when the result is truthy |\n| `visible` | Adds the class `invisible` when the result is falsy |\n| `invisible` | Adds the class `invisible` when the result is truthy |\n| `disabled` | Disables the form controls inside the target when the result is truthy |\n| `enabled` | Disables the form controls inside the target when the result is falsy |\n| `checked` | Checks the inputs inside the target when the result is truthy |\n| `template` | Renders a [Tangular](../tangular/) template |\n| `exec` | Calls a function with the arguments `value`, `path` and `element` |\n\nWhile `show`, `hide`, `visible` or `invisible` keeps the element hidden, `text`, `html` and `template` do not render. They render when the element is displayed again.\n\nThe [ui-bind reference](../../reference/ui-bind/) describes all commands and options.\n\n## Choosing the target\n\nBy default, a command changes the `<ui-bind>` element itself. Write a CSS selector after the command to change elements inside it:\n\n```html\n<ui-bind path=\"product\" config=\"text b:value.name;html span:'<i>' + value.price + ' EUR</i>';href a:value.url;title a:value.name;attr data-id a:value.id;.sale:value.discount > 0\">\n\t<b></b>\n\t<span></span>\n\t<a>Detail</a>\n</ui-bind>\n```\n\n```js\nSET('product', { id: 7, name: 'Pen', price: 12, url: '/products/pen/', discount: 10 });\n```\n\nThe rendered result:\n\n```html\n<ui-bind path=\"product\" class=\"sale\">\n\t<b>Pen</b>\n\t<span><i>12 EUR</i></span>\n\t<a href=\"/products/pen/\" title=\"Pen\" data-id=\"7\">Detail</a>\n</ui-bind>\n```\n\nForm controls and visibility work the same way:\n\n```html\n<ui-bind path=\"panel.open\" config=\"show\"><p id=\"a\">Shown when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.open\" config=\"hide\"><p id=\"b\">Hidden when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.locked\" config=\"disabled\"><input type=\"text\" /><button>Save</button></ui-bind>\n<ui-bind path=\"panel.accepted\" config=\"checked\"><input id=\"c\" type=\"checkbox\" /></ui-bind>\n<ui-bind path=\"panel.note\" config=\"value input\"><input id=\"d\" type=\"text\" /></ui-bind>\n```\n\n```js\nSET('panel', { open: true, locked: true, accepted: true, note: 'Hello' });\n```\n\nThree attributes move the target of all commands outside the default element:\n\n| Attribute | Target |\n| --- | --- |\n| `element` | Any element on the page that matches the selector |\n| `parent` | The closest parent that matches the selector |\n| `child` | The elements inside `<ui-bind>` that match the selector |\n\n```html\n<h2></h2>\n<ui-bind path=\"page.title\" config=\"text\" element=\"h2\"></ui-bind>\n\n<section>\n\t<ui-bind path=\"page.active\" config=\".active\" parent=\"section\"></ui-bind>\n</section>\n\n<ui-bind path=\"page.title\" config=\"text\" child=\".name\">\n\t<span class=\"name\"></span>\n\t<span class=\"other\">untouched</span>\n</ui-bind>\n```\n\n```js\nSET('page', { title: 'Invoices', active: true });\n```\n\n## Rendering lists\n\nThe `template` command compiles the content of a `<script type=\"text/html\">` or `<template>` element inside `<ui-bind>`. The bound value is available as `value`.\n\n```html\n<ui-bind path=\"team.members\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t\t{{ foreach m in value }}\n\t\t\t\t<li>{{ m.name }}</li>\n\t\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n```\n\n```js\nSET('team.members', [{ name: 'Ana' }, { name: 'Peter' }]);\n```\n\nEach change of `team.members` renders the list again. For the template syntax, read [Templates with Tangular](../tangular/).\n\n## Controlling when it renders\n\n| Option | Effect |\n| --- | --- |\n| `!` in front of the path | Skips rendering while the value is `null` or `undefined` |\n| `strict` | Renders only when the exact path changes, not its children |\n| `track:a,b` | For changes of child paths, renders only for the listed keys |\n| `changes` | Renders only when the value is different from the last rendered one |\n| `delay:100` | Waits for the given number of milliseconds and renders the last value |\n| `once` | Renders once and stops listening |\n| `check:FUNC.name` | Renders only when the function returns a truthy value. Arguments: `value`, `path`, `element` |\n| `empty:text` | Shows this text for an empty value. Without a text, it shows `---` |\n\n```html\n<ui-bind id=\"a\" path=\"!report.total\" config=\"text:'Total: ' + value\"></ui-bind>\n<ui-bind id=\"b\" path=\"report.data\" config=\"text:value.a;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"report.data\" config=\"text:value.b;track:a\"></ui-bind>\n<ui-bind id=\"d\" path=\"report.data\" config=\"text:value.a;changes;exec:FUNC.rendered\"></ui-bind>\n<ui-bind id=\"e\" path=\"report.search\" config=\"text;delay:100\"></ui-bind>\n<ui-bind id=\"f\" path=\"report.version\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"g\" path=\"report.total\" config=\"text;check:FUNC.positive\"></ui-bind>\n```\n\n```js\nFUNC.positive = value => value > 0;\nFUNC.rendered = value => console.log('rendered', value);\n\nSET('report.data', { a: 1, b: 1 });\nSET('report.version', 1);\n```\n\nAfter these changes:\n\n```js\nSET('report.total', 5);\nSET('report.data.a', 2);\nSET('report.data.b', 2);\nSET('report.version', 2);\n```\n\n| Element | Shows | Why |\n| --- | --- | --- |\n| `#a` | `Total: 5` | It stayed empty until the value appeared |\n| `#b` | `1` | `strict` ignores changes of `report.data.a` and `report.data.b` |\n| `#c` | `1` | It renders `value.b` but tracks only the key `a` |\n| `#d` | `2` | The value has changed |\n| `#f` | `1` | `once` rendered only the first value |\n| `#g` | `5` | The check passed. For `-1`, the element would keep showing `5` |\n\n## Two-way binding\n\n`<ui-bind>` only displays data. To let the user change a value, use a component on the same path. A component receives changes of the model and writes the user's input back:\n\n```html\n<ui-component name=\"textbox\" path=\"profile.city\"></ui-component>\n<p>You live in <ui-bind path=\"profile.city\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nSET('profile.city', 'Bratislava');\n```\n\nThe input starts with `Bratislava`. When the user types `Kosice`, the model and the paragraph change. A later `SET('profile.city', 'Nitra')` updates both the input and the paragraph. [Creating components](../creating-components/) explains `autobind20()`.\n\n## Reacting in code\n\nTo run code when a value changes, use `WATCH()` as described in [Paths](../paths/), or the `exec` command:\n\n```js\nFUNC.log = function(value, path, element) {\n\tconsole.log(value, path.toString(), element.prop('tagName'));\n};\n\nSET('note.text', 'Hi');\n```\n\n```text\nHi note.text UI-BIND\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNE1id61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/data-binding/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Datenbindung","summary":"Wie du Werte des Modells mit ui-bind in der Seite darstellst und Eingabefelder und Modell synchron hältst.","markdown":"---\ntitle: Datenbindung\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/data-binding/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Datenbindung\n\n> Wie du Werte des Modells mit ui-bind in der Seite darstellst und Eingabefelder und Modell synchron hältst.\n\nDie Datenbindung verbindet das Modell mit der Seite. Das Element `<ui-bind>` stellt einen Wert aus einem Path dar und rendert ihn erneut, sobald sich der Wert ändert. Komponenten ergänzen die Gegenrichtung: Was der Benutzer eingibt, schreiben sie zurück in das Modell.\n\n## Das Element ui-bind\n\n`<ui-bind>` hat zwei Hauptattribute. `path` ist der Wert, auf den es hört, und `config` ist eine Liste von Befehlen, die durch Semikolons getrennt sind. Ein Befehl in der Form `name:expression` verwendet das Ergebnis eines JavaScript-Ausdrucks. Ohne Ausdruck verwendet der Befehl den Wert selbst.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n<ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n<ui-bind path=\"user.age\" config=\"text:value >= 18 ? 'adult' : 'minor'\"></ui-bind>\n```\n\n```js\nSET('user', { name: 'Ana', age: 30 });\n```\n\nDie drei Elemente zeigen `Ana`, `ANA` und `adult`.\n\nEin Ausdruck kann diese Variablen verwenden:\n\n| Variable | Beschreibung |\n| --- | --- |\n| `value` | Der Wert am Path |\n| `element`, `el` | Das Zielelement als jQuery-Objekt |\n| `flags` | Die [Flags](../flags/) der Operation |\n| `path` | Der geänderte Path |\n\nInnerhalb von `config` schreibst du ein Semikolon als `\\;`:\n\n```html\n<ui-bind path=\"note.text\" config=\"text:value + '\\; ok';title:'Note\\: ' + value\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"exec:FUNC.log\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"text:element.attr('data-prefix') + value\" data-prefix=\"&gt; \"></ui-bind>\n```\n\n## Befehle\n\n| Befehl | Wirkung |\n| --- | --- |\n| `text` | Setzt den Textinhalt |\n| `html` | Setzt den HTML-Inhalt |\n| `value` | Setzt den Wert eines Formularelements |\n| `title`, `href`, `src` | Setzt das gleichnamige Attribut |\n| `attr name` | Setzt das Attribut `name` |\n| `.name` | Fügt die CSS-Klasse `name` hinzu, wenn das Ergebnis truthy ist, und entfernt sie andernfalls |\n| `show` | Fügt die Klasse `hidden` hinzu, wenn das Ergebnis falsy ist |\n| `hide` | Fügt die Klasse `hidden` hinzu, wenn das Ergebnis truthy ist |\n| `visible` | Fügt die Klasse `invisible` hinzu, wenn das Ergebnis falsy ist |\n| `invisible` | Fügt die Klasse `invisible` hinzu, wenn das Ergebnis truthy ist |\n| `disabled` | Deaktiviert die Formularelemente im Ziel, wenn das Ergebnis truthy ist |\n| `enabled` | Deaktiviert die Formularelemente im Ziel, wenn das Ergebnis falsy ist |\n| `checked` | Hakt die Eingabefelder im Ziel an, wenn das Ergebnis truthy ist |\n| `template` | Rendert ein [Tangular](../tangular/)-Template |\n| `exec` | Ruft eine Funktion mit den Argumenten `value`, `path` und `element` auf |\n\nSolange `show`, `hide`, `visible` oder `invisible` das Element ausgeblendet halten, rendern `text`, `html` und `template` nicht. Gerendert wird erst, sobald das Element wieder angezeigt wird.\n\nDie [Referenz zu ui-bind](../../reference/ui-bind/) beschreibt alle Befehle und Optionen.\n\n## Das Ziel wählen\n\nStandardmäßig ändert ein Befehl das Element `<ui-bind>` selbst. Schreibe nach dem Befehl einen CSS-Selektor, um Elemente darin zu ändern:\n\n```html\n<ui-bind path=\"product\" config=\"text b:value.name;html span:'<i>' + value.price + ' EUR</i>';href a:value.url;title a:value.name;attr data-id a:value.id;.sale:value.discount > 0\">\n\t<b></b>\n\t<span></span>\n\t<a>Detail</a>\n</ui-bind>\n```\n\n```js\nSET('product', { id: 7, name: 'Pen', price: 12, url: '/products/pen/', discount: 10 });\n```\n\nDas gerenderte Ergebnis:\n\n```html\n<ui-bind path=\"product\" class=\"sale\">\n\t<b>Pen</b>\n\t<span><i>12 EUR</i></span>\n\t<a href=\"/products/pen/\" title=\"Pen\" data-id=\"7\">Detail</a>\n</ui-bind>\n```\n\nFormularelemente und Sichtbarkeit funktionieren genauso:\n\n```html\n<ui-bind path=\"panel.open\" config=\"show\"><p id=\"a\">Shown when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.open\" config=\"hide\"><p id=\"b\">Hidden when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.locked\" config=\"disabled\"><input type=\"text\" /><button>Save</button></ui-bind>\n<ui-bind path=\"panel.accepted\" config=\"checked\"><input id=\"c\" type=\"checkbox\" /></ui-bind>\n<ui-bind path=\"panel.note\" config=\"value input\"><input id=\"d\" type=\"text\" /></ui-bind>\n```\n\n```js\nSET('panel', { open: true, locked: true, accepted: true, note: 'Hello' });\n```\n\nDrei Attribute verlegen das Ziel aller Befehle weg vom Standardelement:\n\n| Attribut | Ziel |\n| --- | --- |\n| `element` | Jedes Element auf der Seite, das zum Selektor passt |\n| `parent` | Das nächste übergeordnete Element, das zum Selektor passt |\n| `child` | Die Elemente innerhalb von `<ui-bind>`, die zum Selektor passen |\n\n```html\n<h2></h2>\n<ui-bind path=\"page.title\" config=\"text\" element=\"h2\"></ui-bind>\n\n<section>\n\t<ui-bind path=\"page.active\" config=\".active\" parent=\"section\"></ui-bind>\n</section>\n\n<ui-bind path=\"page.title\" config=\"text\" child=\".name\">\n\t<span class=\"name\"></span>\n\t<span class=\"other\">untouched</span>\n</ui-bind>\n```\n\n```js\nSET('page', { title: 'Invoices', active: true });\n```\n\n## Listen rendern\n\nDer Befehl `template` kompiliert den Inhalt eines Elements `<script type=\"text/html\">` oder `<template>` innerhalb von `<ui-bind>`. Der gebundene Wert steht als `value` zur Verfügung.\n\n```html\n<ui-bind path=\"team.members\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t\t{{ foreach m in value }}\n\t\t\t\t<li>{{ m.name }}</li>\n\t\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n```\n\n```js\nSET('team.members', [{ name: 'Ana' }, { name: 'Peter' }]);\n```\n\nJede Änderung von `team.members` rendert die Liste erneut. Die Template-Syntax findest du unter [Templates mit Tangular](../tangular/).\n\n## Steuern, wann gerendert wird\n\n| Option | Wirkung |\n| --- | --- |\n| `!` vor dem Path | Überspringt das Rendern, solange der Wert `null` oder `undefined` ist |\n| `strict` | Rendert nur, wenn sich genau dieser Path ändert, nicht seine untergeordneten Paths |\n| `track:a,b` | Rendert bei Änderungen untergeordneter Paths nur für die aufgeführten Schlüssel |\n| `changes` | Rendert nur, wenn sich der Wert vom zuletzt gerenderten unterscheidet |\n| `delay:100` | Wartet die angegebene Anzahl Millisekunden und rendert den letzten Wert |\n| `once` | Rendert einmal und hört danach nicht mehr auf Änderungen |\n| `check:FUNC.name` | Rendert nur, wenn die Funktion einen truthy Wert zurückgibt. Argumente: `value`, `path`, `element` |\n| `empty:text` | Zeigt diesen Text bei einem leeren Wert. Ohne Text zeigt es `---` |\n\n```html\n<ui-bind id=\"a\" path=\"!report.total\" config=\"text:'Total: ' + value\"></ui-bind>\n<ui-bind id=\"b\" path=\"report.data\" config=\"text:value.a;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"report.data\" config=\"text:value.b;track:a\"></ui-bind>\n<ui-bind id=\"d\" path=\"report.data\" config=\"text:value.a;changes;exec:FUNC.rendered\"></ui-bind>\n<ui-bind id=\"e\" path=\"report.search\" config=\"text;delay:100\"></ui-bind>\n<ui-bind id=\"f\" path=\"report.version\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"g\" path=\"report.total\" config=\"text;check:FUNC.positive\"></ui-bind>\n```\n\n```js\nFUNC.positive = value => value > 0;\nFUNC.rendered = value => console.log('rendered', value);\n\nSET('report.data', { a: 1, b: 1 });\nSET('report.version', 1);\n```\n\nNach diesen Änderungen:\n\n```js\nSET('report.total', 5);\nSET('report.data.a', 2);\nSET('report.data.b', 2);\nSET('report.version', 2);\n```\n\n| Element | Zeigt | Grund |\n| --- | --- | --- |\n| `#a` | `Total: 5` | Es blieb leer, bis der Wert erschien |\n| `#b` | `1` | `strict` ignoriert Änderungen an `report.data.a` und `report.data.b` |\n| `#c` | `1` | Es rendert `value.b`, verfolgt aber nur den Schlüssel `a` |\n| `#d` | `2` | Der Wert hat sich geändert |\n| `#f` | `1` | `once` hat nur den ersten Wert gerendert |\n| `#g` | `5` | Die Prüfung war erfolgreich. Bei `-1` würde das Element weiterhin `5` zeigen |\n\n## Zwei-Wege-Bindung\n\n`<ui-bind>` zeigt Daten nur an. Damit der Benutzer einen Wert ändern kann, verwendest du eine Komponente auf demselben Path. Eine Komponente empfängt Änderungen des Modells und schreibt die Eingabe des Benutzers zurück:\n\n```html\n<ui-component name=\"textbox\" path=\"profile.city\"></ui-component>\n<p>You live in <ui-bind path=\"profile.city\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nSET('profile.city', 'Bratislava');\n```\n\nDas Eingabefeld beginnt mit `Bratislava`. Tippt der Benutzer `Kosice`, ändern sich das Modell und der Absatz. Ein späteres `SET('profile.city', 'Nitra')` aktualisiert sowohl das Eingabefeld als auch den Absatz. [Komponenten erstellen](../creating-components/) erklärt `autobind20()`.\n\n## Im Code reagieren\n\nUm Code auszuführen, wenn sich ein Wert ändert, verwendest du `WATCH()` wie unter [Paths](../paths/) beschrieben oder den Befehl `exec`:\n\n```js\nFUNC.log = function(value, path, element) {\n\tconsole.log(value, path.toString(), element.prop('tagName'));\n};\n\nSET('note.text', 'Hi');\n```\n\n```text\nHi note.text UI-BIND\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNE1id61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/data-binding/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Enlace de datos","summary":"Cómo renderizar valores del modelo en la página con ui-bind y mantener sincronizados los campos y el modelo.","markdown":"---\ntitle: Enlace de datos\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/data-binding/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Enlace de datos\n\n> Cómo renderizar valores del modelo en la página con ui-bind y mantener sincronizados los campos y el modelo.\n\nEl enlace de datos conecta el modelo con la página. El elemento `<ui-bind>` renderiza un valor de un path y vuelve a renderizarlo cada vez que el valor cambia. Los componentes añaden la dirección contraria: escriben en el modelo lo que introduce el usuario.\n\n## El elemento ui-bind\n\n`<ui-bind>` tiene dos atributos principales. `path` es el valor que se escucha y `config` es una lista de comandos separados por punto y coma. Un comando con la forma `name:expression` usa el resultado de una expresión JavaScript. Sin expresión, el comando usa el propio valor.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n<ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n<ui-bind path=\"user.age\" config=\"text:value >= 18 ? 'adult' : 'minor'\"></ui-bind>\n```\n\n```js\nSET('user', { name: 'Ana', age: 30 });\n```\n\nLos tres elementos muestran `Ana`, `ANA` y `adult`.\n\nUna expresión puede usar estas variables:\n\n| Variable | Descripción |\n| --- | --- |\n| `value` | El valor del path |\n| `element`, `el` | El elemento de destino como objeto jQuery |\n| `flags` | Los [flags](../flags/) de la operación |\n| `path` | El path que ha cambiado |\n\nDentro de `config`, escribe el punto y coma como `\\;`:\n\n```html\n<ui-bind path=\"note.text\" config=\"text:value + '\\; ok';title:'Note\\: ' + value\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"exec:FUNC.log\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"text:element.attr('data-prefix') + value\" data-prefix=\"&gt; \"></ui-bind>\n```\n\n## Comandos\n\n| Comando | Efecto |\n| --- | --- |\n| `text` | Establece el contenido de texto |\n| `html` | Establece el contenido HTML |\n| `value` | Establece el valor de un control de formulario |\n| `title`, `href`, `src` | Establece el atributo del mismo nombre |\n| `attr name` | Establece el atributo `name` |\n| `.name` | Añade la clase CSS `name` cuando el resultado es verdadero y la quita en caso contrario |\n| `show` | Añade la clase `hidden` cuando el resultado es falso |\n| `hide` | Añade la clase `hidden` cuando el resultado es verdadero |\n| `visible` | Añade la clase `invisible` cuando el resultado es falso |\n| `invisible` | Añade la clase `invisible` cuando el resultado es verdadero |\n| `disabled` | Desactiva los controles de formulario del destino cuando el resultado es verdadero |\n| `enabled` | Desactiva los controles de formulario del destino cuando el resultado es falso |\n| `checked` | Marca los campos del destino cuando el resultado es verdadero |\n| `template` | Renderiza una plantilla de [Tangular](../tangular/) |\n| `exec` | Llama a una función con los argumentos `value`, `path` y `element` |\n\nMientras `show`, `hide`, `visible` o `invisible` mantienen oculto el elemento, `text`, `html` y `template` no renderizan. Lo hacen cuando el elemento vuelve a mostrarse.\n\nLa [referencia de ui-bind](../../reference/ui-bind/) describe todos los comandos y opciones.\n\n## Elegir el destino\n\nDe forma predeterminada, un comando cambia el propio elemento `<ui-bind>`. Escribe un selector CSS detrás del comando para cambiar elementos que estén dentro de él:\n\n```html\n<ui-bind path=\"product\" config=\"text b:value.name;html span:'<i>' + value.price + ' EUR</i>';href a:value.url;title a:value.name;attr data-id a:value.id;.sale:value.discount > 0\">\n\t<b></b>\n\t<span></span>\n\t<a>Detail</a>\n</ui-bind>\n```\n\n```js\nSET('product', { id: 7, name: 'Pen', price: 12, url: '/products/pen/', discount: 10 });\n```\n\nEl resultado renderizado:\n\n```html\n<ui-bind path=\"product\" class=\"sale\">\n\t<b>Pen</b>\n\t<span><i>12 EUR</i></span>\n\t<a href=\"/products/pen/\" title=\"Pen\" data-id=\"7\">Detail</a>\n</ui-bind>\n```\n\nLos controles de formulario y la visibilidad funcionan igual:\n\n```html\n<ui-bind path=\"panel.open\" config=\"show\"><p id=\"a\">Shown when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.open\" config=\"hide\"><p id=\"b\">Hidden when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.locked\" config=\"disabled\"><input type=\"text\" /><button>Save</button></ui-bind>\n<ui-bind path=\"panel.accepted\" config=\"checked\"><input id=\"c\" type=\"checkbox\" /></ui-bind>\n<ui-bind path=\"panel.note\" config=\"value input\"><input id=\"d\" type=\"text\" /></ui-bind>\n```\n\n```js\nSET('panel', { open: true, locked: true, accepted: true, note: 'Hello' });\n```\n\nTres atributos llevan el destino de todos los comandos fuera del elemento predeterminado:\n\n| Atributo | Destino |\n| --- | --- |\n| `element` | Cualquier elemento de la página que coincida con el selector |\n| `parent` | El padre más cercano que coincida con el selector |\n| `child` | Los elementos dentro de `<ui-bind>` que coincidan con el selector |\n\n```html\n<h2></h2>\n<ui-bind path=\"page.title\" config=\"text\" element=\"h2\"></ui-bind>\n\n<section>\n\t<ui-bind path=\"page.active\" config=\".active\" parent=\"section\"></ui-bind>\n</section>\n\n<ui-bind path=\"page.title\" config=\"text\" child=\".name\">\n\t<span class=\"name\"></span>\n\t<span class=\"other\">untouched</span>\n</ui-bind>\n```\n\n```js\nSET('page', { title: 'Invoices', active: true });\n```\n\n## Renderizar listas\n\nEl comando `template` compila el contenido de un elemento `<script type=\"text/html\">` o `<template>` situado dentro de `<ui-bind>`. El valor enlazado está disponible como `value`.\n\n```html\n<ui-bind path=\"team.members\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t\t{{ foreach m in value }}\n\t\t\t\t<li>{{ m.name }}</li>\n\t\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n```\n\n```js\nSET('team.members', [{ name: 'Ana' }, { name: 'Peter' }]);\n```\n\nCada cambio de `team.members` vuelve a renderizar la lista. Para conocer la sintaxis de las plantillas, lee [Plantillas con Tangular](../tangular/).\n\n## Controlar cuándo se renderiza\n\n| Opción | Efecto |\n| --- | --- |\n| `!` delante del path | No renderiza mientras el valor sea `null` o `undefined` |\n| `strict` | Renderiza solo cuando cambia el path exacto, no sus hijos |\n| `track:a,b` | En los cambios de paths hijo, renderiza solo para las claves indicadas |\n| `changes` | Renderiza solo cuando el valor es distinto del último renderizado |\n| `delay:100` | Espera el número de milisegundos indicado y renderiza el último valor |\n| `once` | Renderiza una vez y deja de escuchar |\n| `check:FUNC.name` | Renderiza solo cuando la función devuelve un valor verdadero. Argumentos: `value`, `path`, `element` |\n| `empty:text` | Muestra este texto para un valor vacío. Sin texto, muestra `---` |\n\n```html\n<ui-bind id=\"a\" path=\"!report.total\" config=\"text:'Total: ' + value\"></ui-bind>\n<ui-bind id=\"b\" path=\"report.data\" config=\"text:value.a;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"report.data\" config=\"text:value.b;track:a\"></ui-bind>\n<ui-bind id=\"d\" path=\"report.data\" config=\"text:value.a;changes;exec:FUNC.rendered\"></ui-bind>\n<ui-bind id=\"e\" path=\"report.search\" config=\"text;delay:100\"></ui-bind>\n<ui-bind id=\"f\" path=\"report.version\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"g\" path=\"report.total\" config=\"text;check:FUNC.positive\"></ui-bind>\n```\n\n```js\nFUNC.positive = value => value > 0;\nFUNC.rendered = value => console.log('rendered', value);\n\nSET('report.data', { a: 1, b: 1 });\nSET('report.version', 1);\n```\n\nTras estos cambios:\n\n```js\nSET('report.total', 5);\nSET('report.data.a', 2);\nSET('report.data.b', 2);\nSET('report.version', 2);\n```\n\n| Elemento | Muestra | Por qué |\n| --- | --- | --- |\n| `#a` | `Total: 5` | Se quedó vacío hasta que apareció el valor |\n| `#b` | `1` | `strict` ignora los cambios de `report.data.a` y `report.data.b` |\n| `#c` | `1` | Renderiza `value.b`, pero solo sigue la clave `a` |\n| `#d` | `2` | El valor ha cambiado |\n| `#f` | `1` | `once` renderizó solo el primer valor |\n| `#g` | `5` | La comprobación se superó. Con `-1`, el elemento seguiría mostrando `5` |\n\n## Enlace bidireccional\n\n`<ui-bind>` solo muestra datos. Para que el usuario pueda cambiar un valor, usa un componente en el mismo path. Un componente recibe los cambios del modelo y escribe en él lo que introduce el usuario:\n\n```html\n<ui-component name=\"textbox\" path=\"profile.city\"></ui-component>\n<p>You live in <ui-bind path=\"profile.city\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nSET('profile.city', 'Bratislava');\n```\n\nEl campo empieza con `Bratislava`. Cuando el usuario escribe `Kosice`, cambian el modelo y el párrafo. Un `SET('profile.city', 'Nitra')` posterior actualiza tanto el campo como el párrafo. [Crear componentes](../creating-components/) explica `autobind20()`.\n\n## Reaccionar desde el código\n\nPara ejecutar código cuando cambia un valor, usa `WATCH()` como se describe en [Paths](../paths/), o el comando `exec`:\n\n```js\nFUNC.log = function(value, path, element) {\n\tconsole.log(value, path.toString(), element.prop('tagName'));\n};\n\nSET('note.text', 'Hi');\n```\n\n```text\nHi note.text UI-BIND\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNE1id61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/data-binding/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Liaison de données","summary":"Comment afficher dans la page les valeurs du modèle de données avec ui-bind et garder les champs de saisie synchronisés avec le modèle de données.","markdown":"---\ntitle: \"Liaison de données\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/data-binding/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Liaison de données\n\n> Comment afficher dans la page les valeurs du modèle de données avec ui-bind et garder les champs de saisie synchronisés avec le modèle de données.\n\nLa liaison de données relie le modèle de données à la page. L'élément `<ui-bind>` affiche une valeur issue d'un path et l'affiche de nouveau chaque fois qu'elle change. Les composants ajoutent le sens inverse : ils réécrivent dans le modèle de données ce que l'utilisateur saisit.\n\n## L'élément ui-bind\n\n`<ui-bind>` possède deux attributs principaux. `path` est la valeur à écouter et `config` est une liste de commandes séparées par des points-virgules. Une commande de la forme `name:expression` utilise le résultat d'une expression JavaScript. Sans expression, la commande utilise la valeur elle-même.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n<ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n<ui-bind path=\"user.age\" config=\"text:value >= 18 ? 'adult' : 'minor'\"></ui-bind>\n```\n\n```js\nSET('user', { name: 'Ana', age: 30 });\n```\n\nLes trois éléments affichent `Ana`, `ANA` et `adult`.\n\nUne expression peut utiliser ces variables :\n\n| Variable | Description |\n| --- | --- |\n| `value` | La valeur du path |\n| `element`, `el` | L'élément cible sous forme d'objet jQuery |\n| `flags` | Les [flags](../flags/) de l'opération |\n| `path` | Le path qui a été modifié |\n\nDans `config`, écris un point-virgule sous la forme `\\;` :\n\n```html\n<ui-bind path=\"note.text\" config=\"text:value + '\\; ok';title:'Note\\: ' + value\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"exec:FUNC.log\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"text:element.attr('data-prefix') + value\" data-prefix=\"&gt; \"></ui-bind>\n```\n\n## Commandes\n\n| Commande | Effet |\n| --- | --- |\n| `text` | Définit le contenu textuel |\n| `html` | Définit le contenu HTML |\n| `value` | Définit la valeur d'un contrôle de formulaire |\n| `title`, `href`, `src` | Définit l'attribut du même nom |\n| `attr name` | Définit l'attribut `name` |\n| `.name` | Ajoute la classe CSS `name` quand le résultat est truthy et la retire sinon |\n| `show` | Ajoute la classe `hidden` quand le résultat est falsy |\n| `hide` | Ajoute la classe `hidden` quand le résultat est truthy |\n| `visible` | Ajoute la classe `invisible` quand le résultat est falsy |\n| `invisible` | Ajoute la classe `invisible` quand le résultat est truthy |\n| `disabled` | Désactive les contrôles de formulaire à l'intérieur de la cible quand le résultat est truthy |\n| `enabled` | Désactive les contrôles de formulaire à l'intérieur de la cible quand le résultat est falsy |\n| `checked` | Coche les champs à l'intérieur de la cible quand le résultat est truthy |\n| `template` | Affiche un modèle [Tangular](../tangular/) |\n| `exec` | Appelle une fonction avec les arguments `value`, `path` et `element` |\n\nTant que `show`, `hide`, `visible` ou `invisible` garde l'élément masqué, `text`, `html` et `template` n'affichent rien. Ils s'affichent quand l'élément redevient visible.\n\nLa [référence de ui-bind](../../reference/ui-bind/) décrit toutes les commandes et options.\n\n## Choisir la cible\n\nPar défaut, une commande modifie l'élément `<ui-bind>` lui-même. Écris un sélecteur CSS après la commande pour modifier des éléments à l'intérieur :\n\n```html\n<ui-bind path=\"product\" config=\"text b:value.name;html span:'<i>' + value.price + ' EUR</i>';href a:value.url;title a:value.name;attr data-id a:value.id;.sale:value.discount > 0\">\n\t<b></b>\n\t<span></span>\n\t<a>Detail</a>\n</ui-bind>\n```\n\n```js\nSET('product', { id: 7, name: 'Pen', price: 12, url: '/products/pen/', discount: 10 });\n```\n\nLe résultat affiché :\n\n```html\n<ui-bind path=\"product\" class=\"sale\">\n\t<b>Pen</b>\n\t<span><i>12 EUR</i></span>\n\t<a href=\"/products/pen/\" title=\"Pen\" data-id=\"7\">Detail</a>\n</ui-bind>\n```\n\nLes contrôles de formulaire et la visibilité fonctionnent de la même façon :\n\n```html\n<ui-bind path=\"panel.open\" config=\"show\"><p id=\"a\">Shown when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.open\" config=\"hide\"><p id=\"b\">Hidden when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.locked\" config=\"disabled\"><input type=\"text\" /><button>Save</button></ui-bind>\n<ui-bind path=\"panel.accepted\" config=\"checked\"><input id=\"c\" type=\"checkbox\" /></ui-bind>\n<ui-bind path=\"panel.note\" config=\"value input\"><input id=\"d\" type=\"text\" /></ui-bind>\n```\n\n```js\nSET('panel', { open: true, locked: true, accepted: true, note: 'Hello' });\n```\n\nTrois attributs déplacent la cible de toutes les commandes hors de l'élément par défaut :\n\n| Attribut | Cible |\n| --- | --- |\n| `element` | N'importe quel élément de la page qui correspond au sélecteur |\n| `parent` | Le parent le plus proche qui correspond au sélecteur |\n| `child` | Les éléments à l'intérieur de `<ui-bind>` qui correspondent au sélecteur |\n\n```html\n<h2></h2>\n<ui-bind path=\"page.title\" config=\"text\" element=\"h2\"></ui-bind>\n\n<section>\n\t<ui-bind path=\"page.active\" config=\".active\" parent=\"section\"></ui-bind>\n</section>\n\n<ui-bind path=\"page.title\" config=\"text\" child=\".name\">\n\t<span class=\"name\"></span>\n\t<span class=\"other\">untouched</span>\n</ui-bind>\n```\n\n```js\nSET('page', { title: 'Invoices', active: true });\n```\n\n## Afficher des listes\n\nLa commande `template` compile le contenu d'un élément `<script type=\"text/html\">` ou `<template>` placé dans `<ui-bind>`. La valeur liée est disponible sous le nom `value`.\n\n```html\n<ui-bind path=\"team.members\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t\t{{ foreach m in value }}\n\t\t\t\t<li>{{ m.name }}</li>\n\t\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n```\n\n```js\nSET('team.members', [{ name: 'Ana' }, { name: 'Peter' }]);\n```\n\nChaque changement de `team.members` affiche de nouveau la liste. Pour la syntaxe des modèles, lis [Modèles avec Tangular](../tangular/).\n\n## Contrôler le moment de l'affichage\n\n| Option | Effet |\n| --- | --- |\n| `!` devant le path | Ignore l'affichage tant que la valeur est `null` ou `undefined` |\n| `strict` | N'affiche que lorsque le path exact change, pas ses enfants |\n| `track:a,b` | Pour les changements de paths enfants, n'affiche que pour les clés indiquées |\n| `changes` | N'affiche que lorsque la valeur diffère de la dernière valeur affichée |\n| `delay:100` | Attend le nombre de millisecondes indiqué et affiche la dernière valeur |\n| `once` | Affiche une seule fois et cesse d'écouter |\n| `check:FUNC.name` | N'affiche que lorsque la fonction renvoie une valeur truthy. Arguments : `value`, `path`, `element` |\n| `empty:text` | Affiche ce texte pour une valeur vide. Sans texte, affiche `---` |\n\n```html\n<ui-bind id=\"a\" path=\"!report.total\" config=\"text:'Total: ' + value\"></ui-bind>\n<ui-bind id=\"b\" path=\"report.data\" config=\"text:value.a;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"report.data\" config=\"text:value.b;track:a\"></ui-bind>\n<ui-bind id=\"d\" path=\"report.data\" config=\"text:value.a;changes;exec:FUNC.rendered\"></ui-bind>\n<ui-bind id=\"e\" path=\"report.search\" config=\"text;delay:100\"></ui-bind>\n<ui-bind id=\"f\" path=\"report.version\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"g\" path=\"report.total\" config=\"text;check:FUNC.positive\"></ui-bind>\n```\n\n```js\nFUNC.positive = value => value > 0;\nFUNC.rendered = value => console.log('rendered', value);\n\nSET('report.data', { a: 1, b: 1 });\nSET('report.version', 1);\n```\n\nAprès ces changements :\n\n```js\nSET('report.total', 5);\nSET('report.data.a', 2);\nSET('report.data.b', 2);\nSET('report.version', 2);\n```\n\n| Élément | Affiche | Pourquoi |\n| --- | --- | --- |\n| `#a` | `Total: 5` | Il est resté vide jusqu'à l'apparition de la valeur |\n| `#b` | `1` | `strict` ignore les changements de `report.data.a` et `report.data.b` |\n| `#c` | `1` | Il affiche `value.b` mais ne suit que la clé `a` |\n| `#d` | `2` | La valeur a changé |\n| `#f` | `1` | `once` n'a affiché que la première valeur |\n| `#g` | `5` | La vérification a réussi. Pour `-1`, l'élément continuerait d'afficher `5` |\n\n## Liaison bidirectionnelle\n\n`<ui-bind>` ne fait qu'afficher des données. Pour permettre à l'utilisateur de modifier une valeur, utilise un composant sur le même path. Un composant reçoit les changements du modèle de données et y réécrit ce que l'utilisateur saisit :\n\n```html\n<ui-component name=\"textbox\" path=\"profile.city\"></ui-component>\n<p>You live in <ui-bind path=\"profile.city\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nSET('profile.city', 'Bratislava');\n```\n\nLe champ commence avec `Bratislava`. Quand l'utilisateur saisit `Kosice`, le modèle de données et le paragraphe changent. Un appel ultérieur à `SET('profile.city', 'Nitra')` met à jour à la fois le champ et le paragraphe. [Créer des composants](../creating-components/) explique `autobind20()`.\n\n## Réagir dans le code\n\nPour exécuter du code quand une valeur change, utilise `WATCH()` comme décrit dans [Paths](../paths/), ou la commande `exec` :\n\n```js\nFUNC.log = function(value, path, element) {\n\tconsole.log(value, path.toString(), element.prop('tagName'));\n};\n\nSET('note.text', 'Hi');\n```\n\n```text\nHi note.text UI-BIND\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNE1id61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/data-binding/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Associazione dei dati","summary":"Come visualizzare nella pagina i valori del modello con ui-bind e mantenere sincronizzati gli input e il modello.","markdown":"---\ntitle: Associazione dei dati\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/data-binding/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Associazione dei dati\n\n> Come visualizzare nella pagina i valori del modello con ui-bind e mantenere sincronizzati gli input e il modello.\n\nL'associazione dei dati collega il modello alla pagina. L'elemento `<ui-bind>` visualizza un valore di un path e lo visualizza di nuovo ogni volta che il valore cambia. I componenti aggiungono la direzione opposta: riscrivono nel modello ciò che l'utente inserisce.\n\n## L'elemento ui-bind\n\n`<ui-bind>` ha due attributi principali. `path` è il valore da ascoltare e `config` è un elenco di comandi separati da punti e virgola. Un comando nella forma `name:expression` usa il risultato di un'espressione JavaScript. Senza espressione, il comando usa il valore stesso.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n<ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n<ui-bind path=\"user.age\" config=\"text:value >= 18 ? 'adult' : 'minor'\"></ui-bind>\n```\n\n```js\nSET('user', { name: 'Ana', age: 30 });\n```\n\nI tre elementi mostrano `Ana`, `ANA` e `adult`.\n\nUn'espressione può usare queste variabili:\n\n| Variabile | Descrizione |\n| --- | --- |\n| `value` | Il valore nel path |\n| `element`, `el` | L'elemento di destinazione come oggetto jQuery |\n| `flags` | I [flag](../flags/) dell'operazione |\n| `path` | Il path modificato |\n\nDentro `config`, scrivi il punto e virgola come `\\;`:\n\n```html\n<ui-bind path=\"note.text\" config=\"text:value + '\\; ok';title:'Note\\: ' + value\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"exec:FUNC.log\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"text:element.attr('data-prefix') + value\" data-prefix=\"&gt; \"></ui-bind>\n```\n\n## Comandi\n\n| Comando | Effetto |\n| --- | --- |\n| `text` | Imposta il contenuto testuale |\n| `html` | Imposta il contenuto HTML |\n| `value` | Imposta il valore di un controllo di modulo |\n| `title`, `href`, `src` | Imposta l'attributo con lo stesso nome |\n| `attr name` | Imposta l'attributo `name` |\n| `.name` | Aggiunge la classe CSS `name` quando il risultato è truthy e la rimuove negli altri casi |\n| `show` | Aggiunge la classe `hidden` quando il risultato è falsy |\n| `hide` | Aggiunge la classe `hidden` quando il risultato è truthy |\n| `visible` | Aggiunge la classe `invisible` quando il risultato è falsy |\n| `invisible` | Aggiunge la classe `invisible` quando il risultato è truthy |\n| `disabled` | Disabilita i controlli di modulo dentro la destinazione quando il risultato è truthy |\n| `enabled` | Disabilita i controlli di modulo dentro la destinazione quando il risultato è falsy |\n| `checked` | Seleziona gli input dentro la destinazione quando il risultato è truthy |\n| `template` | Visualizza un template [Tangular](../tangular/) |\n| `exec` | Chiama una funzione con gli argomenti `value`, `path` e `element` |\n\nFinché `show`, `hide`, `visible` o `invisible` mantengono nascosto l'elemento, `text`, `html` e `template` non visualizzano nulla. Lo fanno quando l'elemento torna visibile.\n\nIl [riferimento di ui-bind](../../reference/ui-bind/) descrive tutti i comandi e le opzioni.\n\n## Scegliere la destinazione\n\nPer impostazione predefinita, un comando modifica l'elemento `<ui-bind>` stesso. Scrivi un selettore CSS dopo il comando per modificare gli elementi al suo interno:\n\n```html\n<ui-bind path=\"product\" config=\"text b:value.name;html span:'<i>' + value.price + ' EUR</i>';href a:value.url;title a:value.name;attr data-id a:value.id;.sale:value.discount > 0\">\n\t<b></b>\n\t<span></span>\n\t<a>Detail</a>\n</ui-bind>\n```\n\n```js\nSET('product', { id: 7, name: 'Pen', price: 12, url: '/products/pen/', discount: 10 });\n```\n\nIl risultato visualizzato:\n\n```html\n<ui-bind path=\"product\" class=\"sale\">\n\t<b>Pen</b>\n\t<span><i>12 EUR</i></span>\n\t<a href=\"/products/pen/\" title=\"Pen\" data-id=\"7\">Detail</a>\n</ui-bind>\n```\n\nI controlli di modulo e la visibilità funzionano allo stesso modo:\n\n```html\n<ui-bind path=\"panel.open\" config=\"show\"><p id=\"a\">Shown when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.open\" config=\"hide\"><p id=\"b\">Hidden when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.locked\" config=\"disabled\"><input type=\"text\" /><button>Save</button></ui-bind>\n<ui-bind path=\"panel.accepted\" config=\"checked\"><input id=\"c\" type=\"checkbox\" /></ui-bind>\n<ui-bind path=\"panel.note\" config=\"value input\"><input id=\"d\" type=\"text\" /></ui-bind>\n```\n\n```js\nSET('panel', { open: true, locked: true, accepted: true, note: 'Hello' });\n```\n\nTre attributi spostano la destinazione di tutti i comandi fuori dall'elemento predefinito:\n\n| Attributo | Destinazione |\n| --- | --- |\n| `element` | Qualsiasi elemento della pagina che corrisponde al selettore |\n| `parent` | Il genitore più vicino che corrisponde al selettore |\n| `child` | Gli elementi dentro `<ui-bind>` che corrispondono al selettore |\n\n```html\n<h2></h2>\n<ui-bind path=\"page.title\" config=\"text\" element=\"h2\"></ui-bind>\n\n<section>\n\t<ui-bind path=\"page.active\" config=\".active\" parent=\"section\"></ui-bind>\n</section>\n\n<ui-bind path=\"page.title\" config=\"text\" child=\".name\">\n\t<span class=\"name\"></span>\n\t<span class=\"other\">untouched</span>\n</ui-bind>\n```\n\n```js\nSET('page', { title: 'Invoices', active: true });\n```\n\n## Visualizzare elenchi\n\nIl comando `template` compila il contenuto di un elemento `<script type=\"text/html\">` o `<template>` dentro `<ui-bind>`. Il valore associato è disponibile come `value`.\n\n```html\n<ui-bind path=\"team.members\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t\t{{ foreach m in value }}\n\t\t\t\t<li>{{ m.name }}</li>\n\t\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n```\n\n```js\nSET('team.members', [{ name: 'Ana' }, { name: 'Peter' }]);\n```\n\nOgni modifica di `team.members` visualizza di nuovo l'elenco. Per la sintassi dei template, leggi [Template con Tangular](../tangular/).\n\n## Controllare quando visualizzare\n\n| Opzione | Effetto |\n| --- | --- |\n| `!` davanti al path | Salta la visualizzazione finché il valore è `null` o `undefined` |\n| `strict` | Visualizza solo quando cambia il path esatto, non i suoi figli |\n| `track:a,b` | Per le modifiche dei path figli, visualizza solo per le chiavi indicate |\n| `changes` | Visualizza solo quando il valore è diverso dall'ultimo visualizzato |\n| `delay:100` | Attende il numero di millisecondi indicato e visualizza l'ultimo valore |\n| `once` | Visualizza una sola volta e smette di ascoltare |\n| `check:FUNC.name` | Visualizza solo quando la funzione restituisce un valore truthy. Argomenti: `value`, `path`, `element` |\n| `empty:text` | Mostra questo testo per un valore vuoto. Senza testo, mostra `---` |\n\n```html\n<ui-bind id=\"a\" path=\"!report.total\" config=\"text:'Total: ' + value\"></ui-bind>\n<ui-bind id=\"b\" path=\"report.data\" config=\"text:value.a;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"report.data\" config=\"text:value.b;track:a\"></ui-bind>\n<ui-bind id=\"d\" path=\"report.data\" config=\"text:value.a;changes;exec:FUNC.rendered\"></ui-bind>\n<ui-bind id=\"e\" path=\"report.search\" config=\"text;delay:100\"></ui-bind>\n<ui-bind id=\"f\" path=\"report.version\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"g\" path=\"report.total\" config=\"text;check:FUNC.positive\"></ui-bind>\n```\n\n```js\nFUNC.positive = value => value > 0;\nFUNC.rendered = value => console.log('rendered', value);\n\nSET('report.data', { a: 1, b: 1 });\nSET('report.version', 1);\n```\n\nDopo queste modifiche:\n\n```js\nSET('report.total', 5);\nSET('report.data.a', 2);\nSET('report.data.b', 2);\nSET('report.version', 2);\n```\n\n| Elemento | Mostra | Perché |\n| --- | --- | --- |\n| `#a` | `Total: 5` | È rimasto vuoto finché il valore non è comparso |\n| `#b` | `1` | `strict` ignora le modifiche di `report.data.a` e `report.data.b` |\n| `#c` | `1` | Visualizza `value.b` ma traccia solo la chiave `a` |\n| `#d` | `2` | Il valore è cambiato |\n| `#f` | `1` | `once` ha visualizzato solo il primo valore |\n| `#g` | `5` | Il controllo è stato superato. Con `-1`, l'elemento continuerebbe a mostrare `5` |\n\n## Associazione bidirezionale\n\n`<ui-bind>` si limita a mostrare i dati. Per permettere all'utente di modificare un valore, usa un componente sullo stesso path. Un componente riceve le modifiche del modello e riscrive ciò che l'utente inserisce:\n\n```html\n<ui-component name=\"textbox\" path=\"profile.city\"></ui-component>\n<p>You live in <ui-bind path=\"profile.city\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nSET('profile.city', 'Bratislava');\n```\n\nL'input parte con `Bratislava`. Quando l'utente digita `Kosice`, il modello e il paragrafo cambiano. Una successiva chiamata `SET('profile.city', 'Nitra')` aggiorna sia l'input sia il paragrafo. [Creare componenti](../creating-components/) spiega `autobind20()`.\n\n## Reagire nel codice\n\nPer eseguire codice quando un valore cambia, usa `WATCH()` come descritto in [Path](../paths/), oppure il comando `exec`:\n\n```js\nFUNC.log = function(value, path, element) {\n\tconsole.log(value, path.toString(), element.prop('tagName'));\n};\n\nSET('note.text', 'Hi');\n```\n\n```text\nHi note.text UI-BIND\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNE1id61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/data-binding/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Dátová väzba","summary":"Ako vykresľovať hodnoty modelu do stránky pomocou ui-bind a udržiavať vstupné polia a model v súlade.","markdown":"---\ntitle: \"Dátová väzba\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/data-binding/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Dátová väzba\n\n> Ako vykresľovať hodnoty modelu do stránky pomocou ui-bind a udržiavať vstupné polia a model v súlade.\n\nDátová väzba prepája model so stránkou. Element `<ui-bind>` vykreslí hodnotu z path a vykreslí ju znova vždy, keď sa hodnota zmení. Komponenty pridávajú opačný smer: to, čo zadá používateľ, zapisujú späť do modelu.\n\n## Element ui-bind\n\n`<ui-bind>` má dva hlavné atribúty. `path` je hodnota, ktorú počúva, a `config` je zoznam príkazov oddelených bodkočiarkami. Príkaz v tvare `name:expression` použije výsledok JavaScriptového výrazu. Bez výrazu použije samotnú hodnotu.\n\n```html\n<ui-bind path=\"user.name\" config=\"text\"></ui-bind>\n<ui-bind path=\"user.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n<ui-bind path=\"user.age\" config=\"text:value >= 18 ? 'adult' : 'minor'\"></ui-bind>\n```\n\n```js\nSET('user', { name: 'Ana', age: 30 });\n```\n\nTieto tri elementy zobrazia `Ana`, `ANA` a `adult`.\n\nVýraz môže používať tieto premenné:\n\n| Premenná | Popis |\n| --- | --- |\n| `value` | Hodnota na path |\n| `element`, `el` | Cieľový element ako objekt jQuery |\n| `flags` | [Flagy](../flags/) operácie |\n| `path` | Path, ktorá sa zmenila |\n\nV `config` zapíš bodkočiarku ako `\\;`:\n\n```html\n<ui-bind path=\"note.text\" config=\"text:value + '\\; ok';title:'Note\\: ' + value\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"exec:FUNC.log\"></ui-bind>\n<ui-bind path=\"note.text\" config=\"text:element.attr('data-prefix') + value\" data-prefix=\"&gt; \"></ui-bind>\n```\n\n## Príkazy\n\n| Príkaz | Účinok |\n| --- | --- |\n| `text` | Nastaví textový obsah |\n| `html` | Nastaví HTML obsah |\n| `value` | Nastaví hodnotu ovládacieho prvku formulára |\n| `title`, `href`, `src` | Nastaví atribút s rovnakým názvom |\n| `attr name` | Nastaví atribút `name` |\n| `.name` | Pridá CSS triedu `name`, keď je výsledok pravdivý, inak ju odstráni |\n| `show` | Pridá triedu `hidden`, keď je výsledok nepravdivý |\n| `hide` | Pridá triedu `hidden`, keď je výsledok pravdivý |\n| `visible` | Pridá triedu `invisible`, keď je výsledok nepravdivý |\n| `invisible` | Pridá triedu `invisible`, keď je výsledok pravdivý |\n| `disabled` | Vypne ovládacie prvky formulára vo vnútri cieľa, keď je výsledok pravdivý |\n| `enabled` | Vypne ovládacie prvky formulára vo vnútri cieľa, keď je výsledok nepravdivý |\n| `checked` | Zaškrtne vstupné polia vo vnútri cieľa, keď je výsledok pravdivý |\n| `template` | Vykreslí šablónu [Tangular](../tangular/) |\n| `exec` | Zavolá funkciu s argumentmi `value`, `path` a `element` |\n\nKým `show`, `hide`, `visible` alebo `invisible` držia element skrytý, `text`, `html` a `template` nevykresľujú. Vykreslia sa, keď sa element znova zobrazí.\n\n[Referencia ui-bind](../../reference/ui-bind/) opisuje všetky príkazy a možnosti.\n\n## Výber cieľa\n\nPredvolene príkaz mení samotný element `<ui-bind>`. Ak chceš zmeniť elementy v jeho vnútri, napíš za príkaz CSS selektor:\n\n```html\n<ui-bind path=\"product\" config=\"text b:value.name;html span:'<i>' + value.price + ' EUR</i>';href a:value.url;title a:value.name;attr data-id a:value.id;.sale:value.discount > 0\">\n\t<b></b>\n\t<span></span>\n\t<a>Detail</a>\n</ui-bind>\n```\n\n```js\nSET('product', { id: 7, name: 'Pen', price: 12, url: '/products/pen/', discount: 10 });\n```\n\nVykreslený výsledok:\n\n```html\n<ui-bind path=\"product\" class=\"sale\">\n\t<b>Pen</b>\n\t<span><i>12 EUR</i></span>\n\t<a href=\"/products/pen/\" title=\"Pen\" data-id=\"7\">Detail</a>\n</ui-bind>\n```\n\nOvládacie prvky formulára a viditeľnosť fungujú rovnako:\n\n```html\n<ui-bind path=\"panel.open\" config=\"show\"><p id=\"a\">Shown when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.open\" config=\"hide\"><p id=\"b\">Hidden when the value is truthy</p></ui-bind>\n<ui-bind path=\"panel.locked\" config=\"disabled\"><input type=\"text\" /><button>Save</button></ui-bind>\n<ui-bind path=\"panel.accepted\" config=\"checked\"><input id=\"c\" type=\"checkbox\" /></ui-bind>\n<ui-bind path=\"panel.note\" config=\"value input\"><input id=\"d\" type=\"text\" /></ui-bind>\n```\n\n```js\nSET('panel', { open: true, locked: true, accepted: true, note: 'Hello' });\n```\n\nTri atribúty presúvajú cieľ všetkých príkazov mimo predvolený element:\n\n| Atribút | Cieľ |\n| --- | --- |\n| `element` | Ľubovoľný element na stránke, ktorý zodpovedá selektoru |\n| `parent` | Najbližší nadradený element, ktorý zodpovedá selektoru |\n| `child` | Elementy vo vnútri `<ui-bind>`, ktoré zodpovedajú selektoru |\n\n```html\n<h2></h2>\n<ui-bind path=\"page.title\" config=\"text\" element=\"h2\"></ui-bind>\n\n<section>\n\t<ui-bind path=\"page.active\" config=\".active\" parent=\"section\"></ui-bind>\n</section>\n\n<ui-bind path=\"page.title\" config=\"text\" child=\".name\">\n\t<span class=\"name\"></span>\n\t<span class=\"other\">untouched</span>\n</ui-bind>\n```\n\n```js\nSET('page', { title: 'Invoices', active: true });\n```\n\n## Vykresľovanie zoznamov\n\nPríkaz `template` skompiluje obsah elementu `<script type=\"text/html\">` alebo `<template>` vo vnútri `<ui-bind>`. Naviazaná hodnota je dostupná ako `value`.\n\n```html\n<ui-bind path=\"team.members\" config=\"template\">\n\t<script type=\"text/html\">\n\t\t<ul>\n\t\t\t{{ foreach m in value }}\n\t\t\t\t<li>{{ m.name }}</li>\n\t\t\t{{ end }}\n\t\t</ul>\n\t</script>\n</ui-bind>\n```\n\n```js\nSET('team.members', [{ name: 'Ana' }, { name: 'Peter' }]);\n```\n\nKaždá zmena `team.members` vykreslí zoznam znova. Syntax šablón opisuje časť [Šablóny s Tangular](../tangular/).\n\n## Kedy sa vykresľuje\n\n| Možnosť | Účinok |\n| --- | --- |\n| `!` pred path | Preskočí vykresľovanie, kým je hodnota `null` alebo `undefined` |\n| `strict` | Vykreslí iba pri zmene presne tejto path, nie jej podradených path |\n| `track:a,b` | Pri zmenách podradených path vykreslí iba pre uvedené kľúče |\n| `changes` | Vykreslí iba vtedy, keď sa hodnota líši od naposledy vykreslenej |\n| `delay:100` | Počká zadaný počet milisekúnd a vykreslí poslednú hodnotu |\n| `once` | Vykreslí raz a prestane počúvať |\n| `check:FUNC.name` | Vykreslí iba vtedy, keď funkcia vráti pravdivú hodnotu. Argumenty: `value`, `path`, `element` |\n| `empty:text` | Pre prázdnu hodnotu zobrazí tento text. Bez textu zobrazí `---` |\n\n```html\n<ui-bind id=\"a\" path=\"!report.total\" config=\"text:'Total: ' + value\"></ui-bind>\n<ui-bind id=\"b\" path=\"report.data\" config=\"text:value.a;strict\"></ui-bind>\n<ui-bind id=\"c\" path=\"report.data\" config=\"text:value.b;track:a\"></ui-bind>\n<ui-bind id=\"d\" path=\"report.data\" config=\"text:value.a;changes;exec:FUNC.rendered\"></ui-bind>\n<ui-bind id=\"e\" path=\"report.search\" config=\"text;delay:100\"></ui-bind>\n<ui-bind id=\"f\" path=\"report.version\" config=\"text;once\"></ui-bind>\n<ui-bind id=\"g\" path=\"report.total\" config=\"text;check:FUNC.positive\"></ui-bind>\n```\n\n```js\nFUNC.positive = value => value > 0;\nFUNC.rendered = value => console.log('rendered', value);\n\nSET('report.data', { a: 1, b: 1 });\nSET('report.version', 1);\n```\n\nPo týchto zmenách:\n\n```js\nSET('report.total', 5);\nSET('report.data.a', 2);\nSET('report.data.b', 2);\nSET('report.version', 2);\n```\n\n| Element | Zobrazí | Prečo |\n| --- | --- | --- |\n| `#a` | `Total: 5` | Zostal prázdny, kým sa hodnota neobjavila |\n| `#b` | `1` | `strict` ignoruje zmeny `report.data.a` a `report.data.b` |\n| `#c` | `1` | Vykresľuje `value.b`, ale sleduje iba kľúč `a` |\n| `#d` | `2` | Hodnota sa zmenila |\n| `#f` | `1` | `once` vykreslil iba prvú hodnotu |\n| `#g` | `5` | Kontrola prešla. Pri `-1` by element naďalej zobrazoval `5` |\n\n## Obojsmerná väzba\n\n`<ui-bind>` dáta iba zobrazuje. Ak má používateľ hodnotu meniť, použi komponent na tej istej path. Komponent prijíma zmeny modelu a to, čo používateľ zadá, zapisuje späť:\n\n```html\n<ui-component name=\"textbox\" path=\"profile.city\"></ui-component>\n<p>You live in <ui-bind path=\"profile.city\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('textbox', function(self) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n});\n\nSET('profile.city', 'Bratislava');\n```\n\nVstupné pole začína hodnotou `Bratislava`. Keď používateľ napíše `Kosice`, zmení sa model aj odsek. Neskoršie `SET('profile.city', 'Nitra')` aktualizuje vstupné pole aj odsek. [Vytváranie komponentov](../creating-components/) vysvetľuje `autobind20()`.\n\n## Reakcia v kóde\n\nAk chceš pri zmene hodnoty spustiť kód, použi `WATCH()` podľa časti [Paths](../paths/) alebo príkaz `exec`:\n\n```js\nFUNC.log = function(value, path, element) {\n\tconsole.log(value, path.toString(), element.prop('tagName'));\n};\n\nSET('note.text', 'Hi');\n```\n\n```text\nHi note.text UI-BIND\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNn24d61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/using-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Using components","summary":"How to place components on a page, configure them, find them and call their methods.","markdown":"---\ntitle: Using components\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/using-components/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Using components\n\n> How to place components on a page, configure them, find them and call their methods.\n\nA component is a reusable widget declared once and placed on the page with the `<ui-component>` element. This guide covers how to use existing components. To write your own, read [Creating components](../creating-components/).\n\n## Adding a component\n\n```html\n<ui-component name=\"label\" config=\"text:Hello\"></ui-component>\n<ui-component name=\"label\" path=\"user.name\"></ui-component>\n<ui-component name=\"label\" path=\"user.city\" default=\"'Bratislava'\"></ui-component>\n```\n\n| Attribute | Description |\n| --- | --- |\n| `name` | The name of the component |\n| `path` | The path of the value that the component works with. Components without a value do not need it |\n| `config` | The configuration of this instance |\n| `default` | A JavaScript expression that fills the model when the value is `null` or `undefined` at startup |\n| `source` | The URL to download the component from |\n\nIn the example above, the third component writes `Bratislava` to `user.city` because the model has no value there. A string in `default` needs its own quotes.\n\nComponents work in HTML that you add later. The library initializes each `<ui-component>` element when it appears on the page.\n\n## Downloading components\n\nWhen no component with the given name is declared at the moment the element initializes, the library downloads it. The address comes from `DEF.fallback`, which is `https://cdn.componentator.com/j-{0}.html` by default. The `source` attribute sets the address for one element.\n\n```html\n<ui-component name=\"chart\" path=\"stats.sales\"></ui-component>\n<ui-component name=\"gauge\" source=\"/components/gauge.html\"></ui-component>\n```\n\nThe first element requests `https://cdn.componentator.com/j-chart.html` and the second requests `/components/gauge.html`. To load components from your own server, change the pattern:\n\n```js\nDEF.fallback = '/components/{0}.html';\n```\n\n## Configuration\n\nThe `config` attribute contains pairs in the form `key:value` separated by semicolons. Numbers and the words `true` and `false` are converted to their types. Write a literal semicolon as `\\;` and a colon as `\\:` in a value.\n\n```html\n<ui-component name=\"box\" config=\"title:Orders\\: open;limit:10;ratio:0.5;active:true;note:a\\;b\"></ui-component>\n```\n\n```js\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n\tself.make = function() {\n\t\tconsole.log(config);\n\t};\n});\n```\n\n```text\n{\"limit\":10,\"color\":\"red\",\"title\":\"Orders: open\",\"ratio\":0.5,\"active\":true,\"note\":\"a;b\"}\n```\n\nThe result combines the defaults of the component with the values of the element.\n\n### Special keys\n\nThese keys are processed by the library and work with every component:\n\n| Key | Description |\n| --- | --- |\n| `$id` | Sets the identifier of the instance |\n| `$class` | Adds CSS classes to the element |\n| `$assign` | Stores the instance at a path |\n| `$init` | Calls a function when the component is initialized. The argument is the instance |\n| `$setter` | Calls a function each time the value changes. Arguments: `value`, `path`, `flags` |\n| `=key` | Reads the value of the configuration key `key` from a path and follows its changes |\n\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$id:mainbox;$class:highlighted;$assign:refs.box;$init:FUNC.boxready;$setter:FUNC.boxchanged\"></ui-component>\n```\n\n```js\nFUNC.boxready = function(component) {\n\tconsole.log('ready', component.id);\n};\n\nFUNC.boxchanged = function(value, path, flags) {\n\tconsole.log('value', value);\n};\nON('ready', function() {\n\tSET('form.name', 'Ana');\n\tconsole.log(refs.box.name, FIND('#mainbox').element.attr('class'));\n});\n```\n\n```text\nready mainbox\nvalue undefined\nvalue Ana\nbox highlighted\n```\n\nA configuration key linked to a path changes together with the model:\n\n```html\n<ui-component name=\"title\" config=\"=text:settings.title\"></ui-component>\n```\n\n```js\nCOMPONENT('title', function(self) {\n\tself.configure = function(key, value) {\n\t\tif (key === 'text')\n\t\t\tself.text(value);\n\t};\n});\n\nSET('settings.title', 'First');\nON('ready', function() {\n\tSET('settings.title', 'Second');\n});\n```\n\nThe component shows `First` and then `Second`.\n\n### Configuring many components at once\n\n`CONFIG(selector, config)` applies a configuration to existing components and to those created later. The selector is a component name, several names separated by commas, or `*` for all components.\n\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\" config=\"color:blue\"></ui-component>\n```\n\n```js\nCONFIG('box', 'size:large');\nON('ready', function() {\n\tCONFIG('box', { color: 'green' });\n\tconsole.log(FIND('box', true).map(com => com.config.color));\n});\n```\n\n```text\nnew red large\nnew blue large\n[\"green\",\"green\"]\n```\n\n## Finding components\n\n| Code | Returns |\n| --- | --- |\n| `FIND('name')` | The first component with this name |\n| `FIND('#id')` | The component with this identifier |\n| `FIND('.path')` | The first component on this path |\n| `FIND('name', true)` | An array of all matches |\n| `COMPONENTS('path')` | An array of the components on the path. See [flags](../flags/) for filters |\n| `$(element).component()` | The component of the element or of its closest parent |\n\n`FIND()` returns only initialized components. Run your code in the `ready` event to be sure that the components on the page exist.\n\n## Calling methods\n\n`SETTER('selector/method', [a], [b], [c], [d])` calls a method on all matching components. The selector is a component name, `#id`, or `*` for all components that have the method.\n\n```html\n<ui-component id=\"first\" name=\"counter\" path=\"stats.a\" config=\"$id:visits\"></ui-component>\n<ui-component name=\"counter\" path=\"stats.b\"></ui-component>\n```\n\n```js\nCOMPONENT('counter', function(self) {\n\tself.add = function(count) {\n\t\tself.set((self.get() || 0) + count);\n\t};\n});\nON('ready', function() {\n\tSETTER('#visits/add', 2);\n\tconsole.log(stats.a);\n\n\tSETTER('counter/add', 1);\n\tconsole.log(stats.a, stats.b);\n\n\tconsole.log(FIND('counter').path.toString());\n\tconsole.log(FIND('counter', true).length);\n\tconsole.log(FIND('#visits').path.toString());\n\tconsole.log(FIND('.stats.b').path.toString());\n\tconsole.log($('#first').component().id);\n});\n```\n\n```text\n2\n3 1\nstats.a\n2\nstats.a\nstats.b\nvisits\n```\n\nAdd the flag `@important` when the component may not exist yet. The call is repeated until the component appears:\n\n```js\nSETTER('notify/show @important', 'Saved');\n\nsetTimeout(function() {\n\tCOMPONENT('notify', function(self) {\n\t\tself.show = message => console.log(message);\n\t});\n\t$(document.body).append('<ui-component name=\"notify\"></ui-component>');\n}, 100);\n```\n\n```text\nSaved\n```\n\n## Lazy components\n\nWith the prefix `LAZY`, a component is created at the first `SETTER()` call that targets it. This suits dialogs and other parts that many visitors never open.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n```\n\n```js\nCOMPONENT('dialog', function(self) {\n\tself.make = () => console.log('created');\n\tself.open = title => console.log('open', title);\n});\nON('ready', function() {\n\tSETTER('dialog/open', 'Settings');\n});\n```\n\n```text\ncreated\nopen Settings\n```\n\n## State\n\nThe library keeps the state of each component in its configuration and reflects it in CSS classes on the element:\n\n| CSS class | Configuration key | Meaning |\n| --- | --- | --- |\n| `ui-touched` | `touched` | The user has interacted with the component |\n| `ui-modified` | `modified` | The user has changed the value |\n| `ui-invalid` | `invalid` | The value did not pass the validation of the component |\n| `ui-disabled` | `disabled` | The component is disabled |\n\n```html\n<ui-component id=\"a\" name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component id=\"b\" name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\nAt startup, the first component has the class `ui-invalid` because its value is missing and the second has `ui-disabled`. Read more in [Forms and validation](../forms/).\n\n## Removing components\n\nRemove the element from the page like any other element. The library releases removed components once a minute, and `FREE()` does it immediately. The `destroy` delegate of the component runs at that moment.\n\n```js\nON('ready', function() {\n\t$('#area').empty();\n\tFREE();\n\tconsole.log(FIND('box', true).length);\n\n\t$('#area').html('<ui-component name=\"box\"></ui-component>');\n});\n```\n\n`FIND('name').remove()` removes one component and its element immediately.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNn24d61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/using-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Komponenten verwenden","summary":"Wie du Komponenten auf einer Seite platzierst, konfigurierst, findest und ihre Methoden aufrufst.","markdown":"---\ntitle: Komponenten verwenden\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/using-components/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Komponenten verwenden\n\n> Wie du Komponenten auf einer Seite platzierst, konfigurierst, findest und ihre Methoden aufrufst.\n\nEine Komponente ist ein wiederverwendbares Widget, das einmal deklariert und mit dem Element `<ui-component>` auf der Seite platziert wird. Diese Anleitung zeigt, wie du vorhandene Komponenten verwendest. Wie du eigene schreibst, erfährst du unter [Komponenten erstellen](../creating-components/).\n\n## Eine Komponente hinzufügen\n\n```html\n<ui-component name=\"label\" config=\"text:Hello\"></ui-component>\n<ui-component name=\"label\" path=\"user.name\"></ui-component>\n<ui-component name=\"label\" path=\"user.city\" default=\"'Bratislava'\"></ui-component>\n```\n\n| Attribut | Beschreibung |\n| --- | --- |\n| `name` | Der Name der Komponente |\n| `path` | Der Path des Werts, mit dem die Komponente arbeitet. Komponenten ohne Wert brauchen ihn nicht |\n| `config` | Die Konfiguration dieser Instanz |\n| `default` | Ein JavaScript-Ausdruck, der das Modell füllt, wenn der Wert beim Start `null` oder `undefined` ist |\n| `source` | Die URL, von der die Komponente heruntergeladen wird |\n\nIm Beispiel oben schreibt die dritte Komponente `Bratislava` in `user.city`, weil das Modell dort keinen Wert hat. Ein String in `default` braucht eigene Anführungszeichen.\n\nKomponenten funktionieren auch in HTML, das du später hinzufügst. Die Bibliothek initialisiert jedes `<ui-component>`-Element, sobald es auf der Seite erscheint.\n\n## Komponenten herunterladen\n\nIst beim Initialisieren des Elements keine Komponente mit dem angegebenen Namen deklariert, lädt die Bibliothek sie herunter. Die Adresse stammt aus `DEF.fallback`, standardmäßig `https://cdn.componentator.com/j-{0}.html`. Das Attribut `source` legt die Adresse für ein einzelnes Element fest.\n\n```html\n<ui-component name=\"chart\" path=\"stats.sales\"></ui-component>\n<ui-component name=\"gauge\" source=\"/components/gauge.html\"></ui-component>\n```\n\nDas erste Element fordert `https://cdn.componentator.com/j-chart.html` an und das zweite `/components/gauge.html`. Um Komponenten von deinem eigenen Server zu laden, änderst du das Muster:\n\n```js\nDEF.fallback = '/components/{0}.html';\n```\n\n## Konfiguration\n\nDas Attribut `config` enthält Paare der Form `key:value`, die durch Semikolons getrennt sind. Zahlen und die Wörter `true` und `false` werden in ihre Typen umgewandelt. Ein Semikolon schreibst du in einem Wert als `\\;` und einen Doppelpunkt als `\\:`.\n\n```html\n<ui-component name=\"box\" config=\"title:Orders\\: open;limit:10;ratio:0.5;active:true;note:a\\;b\"></ui-component>\n```\n\n```js\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n\tself.make = function() {\n\t\tconsole.log(config);\n\t};\n});\n```\n\n```text\n{\"limit\":10,\"color\":\"red\",\"title\":\"Orders: open\",\"ratio\":0.5,\"active\":true,\"note\":\"a;b\"}\n```\n\nDas Ergebnis kombiniert die Standardwerte der Komponente mit den Werten des Elements.\n\n### Spezielle Schlüssel\n\nDiese Schlüssel verarbeitet die Bibliothek, und sie funktionieren mit jeder Komponente:\n\n| Schlüssel | Beschreibung |\n| --- | --- |\n| `$id` | Setzt die Kennung der Instanz |\n| `$class` | Fügt dem Element CSS-Klassen hinzu |\n| `$assign` | Speichert die Instanz an einem Path |\n| `$init` | Ruft eine Funktion auf, wenn die Komponente initialisiert ist. Das Argument ist die Instanz |\n| `$setter` | Ruft bei jeder Wertänderung eine Funktion auf. Argumente: `value`, `path`, `flags` |\n| `=key` | Liest den Wert des Konfigurationsschlüssels `key` aus einem Path und folgt dessen Änderungen |\n\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$id:mainbox;$class:highlighted;$assign:refs.box;$init:FUNC.boxready;$setter:FUNC.boxchanged\"></ui-component>\n```\n\n```js\nFUNC.boxready = function(component) {\n\tconsole.log('ready', component.id);\n};\n\nFUNC.boxchanged = function(value, path, flags) {\n\tconsole.log('value', value);\n};\nON('ready', function() {\n\tSET('form.name', 'Ana');\n\tconsole.log(refs.box.name, FIND('#mainbox').element.attr('class'));\n});\n```\n\n```text\nready mainbox\nvalue undefined\nvalue Ana\nbox highlighted\n```\n\nEin mit einem Path verknüpfter Konfigurationsschlüssel ändert sich zusammen mit dem Modell:\n\n```html\n<ui-component name=\"title\" config=\"=text:settings.title\"></ui-component>\n```\n\n```js\nCOMPONENT('title', function(self) {\n\tself.configure = function(key, value) {\n\t\tif (key === 'text')\n\t\t\tself.text(value);\n\t};\n});\n\nSET('settings.title', 'First');\nON('ready', function() {\n\tSET('settings.title', 'Second');\n});\n```\n\nDie Komponente zeigt `First` und dann `Second`.\n\n### Viele Komponenten auf einmal konfigurieren\n\n`CONFIG(selector, config)` wendet eine Konfiguration auf vorhandene und später erstellte Komponenten an. Der Selektor ist ein Komponentenname, mehrere durch Kommas getrennte Namen oder `*` für alle Komponenten.\n\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\" config=\"color:blue\"></ui-component>\n```\n\n```js\nCONFIG('box', 'size:large');\nON('ready', function() {\n\tCONFIG('box', { color: 'green' });\n\tconsole.log(FIND('box', true).map(com => com.config.color));\n});\n```\n\n```text\nnew red large\nnew blue large\n[\"green\",\"green\"]\n```\n\n## Komponenten finden\n\n| Code | Gibt zurück |\n| --- | --- |\n| `FIND('name')` | Die erste Komponente mit diesem Namen |\n| `FIND('#id')` | Die Komponente mit dieser Kennung |\n| `FIND('.path')` | Die erste Komponente auf diesem Path |\n| `FIND('name', true)` | Ein Array aller Treffer |\n| `COMPONENTS('path')` | Ein Array der Komponenten auf dem Path. Filter findest du unter [Flags](../flags/) |\n| `$(element).component()` | Die Komponente des Elements oder seines nächsten übergeordneten Elements |\n\n`FIND()` gibt nur initialisierte Komponenten zurück. Führe deinen Code im Event `ready` aus, damit die Komponenten auf der Seite sicher existieren.\n\n## Methoden aufrufen\n\n`SETTER('selector/method', [a], [b], [c], [d])` ruft eine Methode auf allen passenden Komponenten auf. Der Selektor ist ein Komponentenname, `#id` oder `*` für alle Komponenten, die die Methode haben.\n\n```html\n<ui-component id=\"first\" name=\"counter\" path=\"stats.a\" config=\"$id:visits\"></ui-component>\n<ui-component name=\"counter\" path=\"stats.b\"></ui-component>\n```\n\n```js\nCOMPONENT('counter', function(self) {\n\tself.add = function(count) {\n\t\tself.set((self.get() || 0) + count);\n\t};\n});\nON('ready', function() {\n\tSETTER('#visits/add', 2);\n\tconsole.log(stats.a);\n\n\tSETTER('counter/add', 1);\n\tconsole.log(stats.a, stats.b);\n\n\tconsole.log(FIND('counter').path.toString());\n\tconsole.log(FIND('counter', true).length);\n\tconsole.log(FIND('#visits').path.toString());\n\tconsole.log(FIND('.stats.b').path.toString());\n\tconsole.log($('#first').component().id);\n});\n```\n\n```text\n2\n3 1\nstats.a\n2\nstats.a\nstats.b\nvisits\n```\n\nFüge das Flag `@important` hinzu, wenn die Komponente eventuell noch nicht existiert. Der Aufruf wird wiederholt, bis die Komponente erscheint:\n\n```js\nSETTER('notify/show @important', 'Saved');\n\nsetTimeout(function() {\n\tCOMPONENT('notify', function(self) {\n\t\tself.show = message => console.log(message);\n\t});\n\t$(document.body).append('<ui-component name=\"notify\"></ui-component>');\n}, 100);\n```\n\n```text\nSaved\n```\n\n## Lazy-Komponenten\n\nMit dem Präfix `LAZY` wird eine Komponente beim ersten `SETTER()`-Aufruf erstellt, der auf sie zielt. Das eignet sich für Dialoge und andere Teile, die viele Besucher nie öffnen.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n```\n\n```js\nCOMPONENT('dialog', function(self) {\n\tself.make = () => console.log('created');\n\tself.open = title => console.log('open', title);\n});\nON('ready', function() {\n\tSETTER('dialog/open', 'Settings');\n});\n```\n\n```text\ncreated\nopen Settings\n```\n\n## Zustand\n\nDie Bibliothek speichert den Zustand jeder Komponente in deren Konfiguration und spiegelt ihn in CSS-Klassen am Element wider:\n\n| CSS-Klasse | Konfigurationsschlüssel | Bedeutung |\n| --- | --- | --- |\n| `ui-touched` | `touched` | Der Benutzer hat mit der Komponente interagiert |\n| `ui-modified` | `modified` | Der Benutzer hat den Wert geändert |\n| `ui-invalid` | `invalid` | Der Wert hat die Validierung der Komponente nicht bestanden |\n| `ui-disabled` | `disabled` | Die Komponente ist deaktiviert |\n\n```html\n<ui-component id=\"a\" name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component id=\"b\" name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\nBeim Start hat die erste Komponente die Klasse `ui-invalid`, weil ihr Wert fehlt, und die zweite hat `ui-disabled`. Mehr dazu findest du unter [Formulare und Validierung](../forms/).\n\n## Komponenten entfernen\n\nEntferne das Element wie jedes andere Element von der Seite. Die Bibliothek gibt entfernte Komponenten einmal pro Minute frei, `FREE()` erledigt das sofort. In diesem Moment läuft das Delegate `destroy` der Komponente.\n\n```js\nON('ready', function() {\n\t$('#area').empty();\n\tFREE();\n\tconsole.log(FIND('box', true).length);\n\n\t$('#area').html('<ui-component name=\"box\"></ui-component>');\n});\n```\n\n`FIND('name').remove()` entfernt eine Komponente und ihr Element sofort.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNn24d61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/using-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Usar componentes","summary":"Cómo colocar componentes en una página, configurarlos, encontrarlos y llamar a sus métodos.","markdown":"---\ntitle: Usar componentes\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/using-components/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Usar componentes\n\n> Cómo colocar componentes en una página, configurarlos, encontrarlos y llamar a sus métodos.\n\nUn componente es un widget reutilizable que se declara una vez y se coloca en la página con el elemento `<ui-component>`. Esta guía explica cómo usar componentes existentes. Para escribir los tuyos, lee [Crear componentes](../creating-components/).\n\n## Añadir un componente\n\n```html\n<ui-component name=\"label\" config=\"text:Hello\"></ui-component>\n<ui-component name=\"label\" path=\"user.name\"></ui-component>\n<ui-component name=\"label\" path=\"user.city\" default=\"'Bratislava'\"></ui-component>\n```\n\n| Atributo | Descripción |\n| --- | --- |\n| `name` | El nombre del componente |\n| `path` | El path del valor con el que trabaja el componente. Los componentes sin valor no lo necesitan |\n| `config` | La configuración de esta instancia |\n| `default` | Una expresión JavaScript que rellena el modelo cuando el valor es `null` o `undefined` al arrancar |\n| `source` | La URL desde la que se descarga el componente |\n\nEn el ejemplo anterior, el tercer componente escribe `Bratislava` en `user.city` porque el modelo no tiene ningún valor ahí. Una cadena en `default` necesita sus propias comillas.\n\nLos componentes funcionan en el HTML que añadas más adelante. La biblioteca inicializa cada elemento `<ui-component>` cuando aparece en la página.\n\n## Descargar componentes\n\nSi en el momento de inicializarse el elemento no hay declarado ningún componente con ese nombre, la biblioteca lo descarga. La dirección sale de `DEF.fallback`, que de forma predeterminada es `https://cdn.componentator.com/j-{0}.html`. El atributo `source` establece la dirección para un solo elemento.\n\n```html\n<ui-component name=\"chart\" path=\"stats.sales\"></ui-component>\n<ui-component name=\"gauge\" source=\"/components/gauge.html\"></ui-component>\n```\n\nEl primer elemento solicita `https://cdn.componentator.com/j-chart.html` y el segundo solicita `/components/gauge.html`. Para cargar los componentes desde tu propio servidor, cambia el patrón:\n\n```js\nDEF.fallback = '/components/{0}.html';\n```\n\n## Configuración\n\nEl atributo `config` contiene pares con la forma `key:value` separados por punto y coma. Los números y las palabras `true` y `false` se convierten a sus tipos. En un valor, escribe un punto y coma literal como `\\;` y dos puntos como `\\:`.\n\n```html\n<ui-component name=\"box\" config=\"title:Orders\\: open;limit:10;ratio:0.5;active:true;note:a\\;b\"></ui-component>\n```\n\n```js\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n\tself.make = function() {\n\t\tconsole.log(config);\n\t};\n});\n```\n\n```text\n{\"limit\":10,\"color\":\"red\",\"title\":\"Orders: open\",\"ratio\":0.5,\"active\":true,\"note\":\"a;b\"}\n```\n\nEl resultado combina los valores predeterminados del componente con los valores del elemento.\n\n### Claves especiales\n\nLa biblioteca procesa estas claves, que funcionan con todos los componentes:\n\n| Clave | Descripción |\n| --- | --- |\n| `$id` | Establece el identificador de la instancia |\n| `$class` | Añade clases CSS al elemento |\n| `$assign` | Guarda la instancia en un path |\n| `$init` | Llama a una función cuando se inicializa el componente. El argumento es la instancia |\n| `$setter` | Llama a una función cada vez que cambia el valor. Argumentos: `value`, `path`, `flags` |\n| `=key` | Lee de un path el valor de la clave de configuración `key` y sigue sus cambios |\n\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$id:mainbox;$class:highlighted;$assign:refs.box;$init:FUNC.boxready;$setter:FUNC.boxchanged\"></ui-component>\n```\n\n```js\nFUNC.boxready = function(component) {\n\tconsole.log('ready', component.id);\n};\n\nFUNC.boxchanged = function(value, path, flags) {\n\tconsole.log('value', value);\n};\nON('ready', function() {\n\tSET('form.name', 'Ana');\n\tconsole.log(refs.box.name, FIND('#mainbox').element.attr('class'));\n});\n```\n\n```text\nready mainbox\nvalue undefined\nvalue Ana\nbox highlighted\n```\n\nUna clave de configuración vinculada a un path cambia junto con el modelo:\n\n```html\n<ui-component name=\"title\" config=\"=text:settings.title\"></ui-component>\n```\n\n```js\nCOMPONENT('title', function(self) {\n\tself.configure = function(key, value) {\n\t\tif (key === 'text')\n\t\t\tself.text(value);\n\t};\n});\n\nSET('settings.title', 'First');\nON('ready', function() {\n\tSET('settings.title', 'Second');\n});\n```\n\nEl componente muestra `First` y después `Second`.\n\n### Configurar muchos componentes a la vez\n\n`CONFIG(selector, config)` aplica una configuración a los componentes existentes y a los que se creen después. El selector es un nombre de componente, varios nombres separados por comas o `*` para todos los componentes.\n\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\" config=\"color:blue\"></ui-component>\n```\n\n```js\nCONFIG('box', 'size:large');\nON('ready', function() {\n\tCONFIG('box', { color: 'green' });\n\tconsole.log(FIND('box', true).map(com => com.config.color));\n});\n```\n\n```text\nnew red large\nnew blue large\n[\"green\",\"green\"]\n```\n\n## Encontrar componentes\n\n| Código | Devuelve |\n| --- | --- |\n| `FIND('name')` | El primer componente con este nombre |\n| `FIND('#id')` | El componente con este identificador |\n| `FIND('.path')` | El primer componente de este path |\n| `FIND('name', true)` | Un array con todas las coincidencias |\n| `COMPONENTS('path')` | Un array con los componentes del path. Consulta los [flags](../flags/) para ver los filtros |\n| `$(element).component()` | El componente del elemento o de su padre más cercano |\n\n`FIND()` solo devuelve componentes inicializados. Ejecuta tu código en el evento `ready` para asegurarte de que los componentes de la página existen.\n\n## Llamar a métodos\n\n`SETTER('selector/method', [a], [b], [c], [d])` llama a un método de todos los componentes que coincidan. El selector es un nombre de componente, `#id` o `*` para todos los componentes que tengan el método.\n\n```html\n<ui-component id=\"first\" name=\"counter\" path=\"stats.a\" config=\"$id:visits\"></ui-component>\n<ui-component name=\"counter\" path=\"stats.b\"></ui-component>\n```\n\n```js\nCOMPONENT('counter', function(self) {\n\tself.add = function(count) {\n\t\tself.set((self.get() || 0) + count);\n\t};\n});\nON('ready', function() {\n\tSETTER('#visits/add', 2);\n\tconsole.log(stats.a);\n\n\tSETTER('counter/add', 1);\n\tconsole.log(stats.a, stats.b);\n\n\tconsole.log(FIND('counter').path.toString());\n\tconsole.log(FIND('counter', true).length);\n\tconsole.log(FIND('#visits').path.toString());\n\tconsole.log(FIND('.stats.b').path.toString());\n\tconsole.log($('#first').component().id);\n});\n```\n\n```text\n2\n3 1\nstats.a\n2\nstats.a\nstats.b\nvisits\n```\n\nAñade el flag `@important` cuando el componente pueda no existir todavía. La llamada se repite hasta que aparece el componente:\n\n```js\nSETTER('notify/show @important', 'Saved');\n\nsetTimeout(function() {\n\tCOMPONENT('notify', function(self) {\n\t\tself.show = message => console.log(message);\n\t});\n\t$(document.body).append('<ui-component name=\"notify\"></ui-component>');\n}, 100);\n```\n\n```text\nSaved\n```\n\n## Componentes diferidos\n\nCon el prefijo `LAZY`, un componente se crea en la primera llamada a `SETTER()` dirigida a él. Esto va bien para diálogos y otras partes que muchos visitantes nunca abren.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n```\n\n```js\nCOMPONENT('dialog', function(self) {\n\tself.make = () => console.log('created');\n\tself.open = title => console.log('open', title);\n});\nON('ready', function() {\n\tSETTER('dialog/open', 'Settings');\n});\n```\n\n```text\ncreated\nopen Settings\n```\n\n## Estado\n\nLa biblioteca guarda el estado de cada componente en su configuración y lo refleja en clases CSS del elemento:\n\n| Clase CSS | Clave de configuración | Significado |\n| --- | --- | --- |\n| `ui-touched` | `touched` | El usuario ha interactuado con el componente |\n| `ui-modified` | `modified` | El usuario ha cambiado el valor |\n| `ui-invalid` | `invalid` | El valor no ha superado la validación del componente |\n| `ui-disabled` | `disabled` | El componente está desactivado |\n\n```html\n<ui-component id=\"a\" name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component id=\"b\" name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\nAl arrancar, el primer componente tiene la clase `ui-invalid` porque le falta el valor y el segundo tiene `ui-disabled`. Lee más en [Formularios y validación](../forms/).\n\n## Eliminar componentes\n\nElimina el elemento de la página como cualquier otro elemento. La biblioteca libera los componentes eliminados una vez por minuto, y `FREE()` lo hace de inmediato. En ese momento se ejecuta el delegate `destroy` del componente.\n\n```js\nON('ready', function() {\n\t$('#area').empty();\n\tFREE();\n\tconsole.log(FIND('box', true).length);\n\n\t$('#area').html('<ui-component name=\"box\"></ui-component>');\n});\n```\n\n`FIND('name').remove()` elimina un componente y su elemento de inmediato.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNn24d61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/using-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Utiliser les composants","summary":"Comment placer des composants sur une page, les configurer, les retrouver et appeler leurs méthodes.","markdown":"---\ntitle: Utiliser les composants\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/using-components/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Utiliser les composants\n\n> Comment placer des composants sur une page, les configurer, les retrouver et appeler leurs méthodes.\n\nUn composant est un widget réutilisable, déclaré une seule fois et placé sur la page avec l'élément `<ui-component>`. Ce guide explique comment utiliser des composants existants. Pour écrire les tiens, lis [Créer des composants](../creating-components/).\n\n## Ajouter un composant\n\n```html\n<ui-component name=\"label\" config=\"text:Hello\"></ui-component>\n<ui-component name=\"label\" path=\"user.name\"></ui-component>\n<ui-component name=\"label\" path=\"user.city\" default=\"'Bratislava'\"></ui-component>\n```\n\n| Attribut | Description |\n| --- | --- |\n| `name` | Le nom du composant |\n| `path` | Le path de la valeur avec laquelle le composant travaille. Les composants sans valeur n'en ont pas besoin |\n| `config` | La configuration de cette instance |\n| `default` | Une expression JavaScript qui remplit le modèle de données quand la valeur est `null` ou `undefined` au démarrage |\n| `source` | L'URL depuis laquelle télécharger le composant |\n\nDans l'exemple ci-dessus, le troisième composant écrit `Bratislava` dans `user.city`, car le modèle de données n'y contient aucune valeur. Une chaîne dans `default` a besoin de ses propres guillemets.\n\nLes composants fonctionnent dans le HTML que tu ajoutes plus tard. La bibliothèque initialise chaque élément `<ui-component>` lorsqu'il apparaît sur la page.\n\n## Télécharger des composants\n\nQuand aucun composant portant le nom indiqué n'est déclaré au moment où l'élément s'initialise, la bibliothèque le télécharge. L'adresse provient de `DEF.fallback`, qui vaut `https://cdn.componentator.com/j-{0}.html` par défaut. L'attribut `source` définit l'adresse pour un seul élément.\n\n```html\n<ui-component name=\"chart\" path=\"stats.sales\"></ui-component>\n<ui-component name=\"gauge\" source=\"/components/gauge.html\"></ui-component>\n```\n\nLe premier élément demande `https://cdn.componentator.com/j-chart.html` et le second `/components/gauge.html`. Pour charger des composants depuis ton propre serveur, change le motif :\n\n```js\nDEF.fallback = '/components/{0}.html';\n```\n\n## Configuration\n\nL'attribut `config` contient des paires de la forme `key:value` séparées par des points-virgules. Les nombres et les mots `true` et `false` sont convertis dans leur type. Dans une valeur, écris un point-virgule littéral sous la forme `\\;` et un deux-points sous la forme `\\:`.\n\n```html\n<ui-component name=\"box\" config=\"title:Orders\\: open;limit:10;ratio:0.5;active:true;note:a\\;b\"></ui-component>\n```\n\n```js\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n\tself.make = function() {\n\t\tconsole.log(config);\n\t};\n});\n```\n\n```text\n{\"limit\":10,\"color\":\"red\",\"title\":\"Orders: open\",\"ratio\":0.5,\"active\":true,\"note\":\"a;b\"}\n```\n\nLe résultat combine les valeurs par défaut du composant et celles de l'élément.\n\n### Clés spéciales\n\nCes clés sont traitées par la bibliothèque et fonctionnent avec tous les composants :\n\n| Clé | Description |\n| --- | --- |\n| `$id` | Définit l'identifiant de l'instance |\n| `$class` | Ajoute des classes CSS à l'élément |\n| `$assign` | Stocke l'instance dans un path |\n| `$init` | Appelle une fonction quand le composant est initialisé. L'argument est l'instance |\n| `$setter` | Appelle une fonction chaque fois que la valeur change. Arguments : `value`, `path`, `flags` |\n| `=key` | Lit la valeur de la clé de configuration `key` depuis un path et suit ses changements |\n\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$id:mainbox;$class:highlighted;$assign:refs.box;$init:FUNC.boxready;$setter:FUNC.boxchanged\"></ui-component>\n```\n\n```js\nFUNC.boxready = function(component) {\n\tconsole.log('ready', component.id);\n};\n\nFUNC.boxchanged = function(value, path, flags) {\n\tconsole.log('value', value);\n};\nON('ready', function() {\n\tSET('form.name', 'Ana');\n\tconsole.log(refs.box.name, FIND('#mainbox').element.attr('class'));\n});\n```\n\n```text\nready mainbox\nvalue undefined\nvalue Ana\nbox highlighted\n```\n\nUne clé de configuration liée à un path change en même temps que le modèle de données :\n\n```html\n<ui-component name=\"title\" config=\"=text:settings.title\"></ui-component>\n```\n\n```js\nCOMPONENT('title', function(self) {\n\tself.configure = function(key, value) {\n\t\tif (key === 'text')\n\t\t\tself.text(value);\n\t};\n});\n\nSET('settings.title', 'First');\nON('ready', function() {\n\tSET('settings.title', 'Second');\n});\n```\n\nLe composant affiche `First` puis `Second`.\n\n### Configurer plusieurs composants à la fois\n\n`CONFIG(selector, config)` applique une configuration aux composants existants et à ceux créés plus tard. Le sélecteur est un nom de composant, plusieurs noms séparés par des virgules, ou `*` pour tous les composants.\n\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\" config=\"color:blue\"></ui-component>\n```\n\n```js\nCONFIG('box', 'size:large');\nON('ready', function() {\n\tCONFIG('box', { color: 'green' });\n\tconsole.log(FIND('box', true).map(com => com.config.color));\n});\n```\n\n```text\nnew red large\nnew blue large\n[\"green\",\"green\"]\n```\n\n## Retrouver des composants\n\n| Code | Renvoie |\n| --- | --- |\n| `FIND('name')` | Le premier composant portant ce nom |\n| `FIND('#id')` | Le composant ayant cet identifiant |\n| `FIND('.path')` | Le premier composant de ce path |\n| `FIND('name', true)` | Un tableau de toutes les correspondances |\n| `COMPONENTS('path')` | Un tableau des composants du path. Consulte les [flags](../flags/) pour les filtres |\n| `$(element).component()` | Le composant de l'élément ou de son parent le plus proche |\n\n`FIND()` ne renvoie que les composants initialisés. Exécute ton code dans l'événement `ready` pour être sûr que les composants de la page existent.\n\n## Appeler des méthodes\n\n`SETTER('selector/method', [a], [b], [c], [d])` appelle une méthode sur tous les composants correspondants. Le sélecteur est un nom de composant, `#id`, ou `*` pour tous les composants qui possèdent la méthode.\n\n```html\n<ui-component id=\"first\" name=\"counter\" path=\"stats.a\" config=\"$id:visits\"></ui-component>\n<ui-component name=\"counter\" path=\"stats.b\"></ui-component>\n```\n\n```js\nCOMPONENT('counter', function(self) {\n\tself.add = function(count) {\n\t\tself.set((self.get() || 0) + count);\n\t};\n});\nON('ready', function() {\n\tSETTER('#visits/add', 2);\n\tconsole.log(stats.a);\n\n\tSETTER('counter/add', 1);\n\tconsole.log(stats.a, stats.b);\n\n\tconsole.log(FIND('counter').path.toString());\n\tconsole.log(FIND('counter', true).length);\n\tconsole.log(FIND('#visits').path.toString());\n\tconsole.log(FIND('.stats.b').path.toString());\n\tconsole.log($('#first').component().id);\n});\n```\n\n```text\n2\n3 1\nstats.a\n2\nstats.a\nstats.b\nvisits\n```\n\nAjoute le flag `@important` quand le composant risque de ne pas encore exister. L'appel est répété jusqu'à ce que le composant apparaisse :\n\n```js\nSETTER('notify/show @important', 'Saved');\n\nsetTimeout(function() {\n\tCOMPONENT('notify', function(self) {\n\t\tself.show = message => console.log(message);\n\t});\n\t$(document.body).append('<ui-component name=\"notify\"></ui-component>');\n}, 100);\n```\n\n```text\nSaved\n```\n\n## Composants différés\n\nAvec le préfixe `LAZY`, un composant est créé lors du premier appel à `SETTER()` qui le cible. Cela convient aux boîtes de dialogue et aux autres parties que beaucoup de visiteurs n'ouvrent jamais.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n```\n\n```js\nCOMPONENT('dialog', function(self) {\n\tself.make = () => console.log('created');\n\tself.open = title => console.log('open', title);\n});\nON('ready', function() {\n\tSETTER('dialog/open', 'Settings');\n});\n```\n\n```text\ncreated\nopen Settings\n```\n\n## État\n\nLa bibliothèque conserve l'état de chaque composant dans sa configuration et le reflète par des classes CSS sur l'élément :\n\n| Classe CSS | Clé de configuration | Signification |\n| --- | --- | --- |\n| `ui-touched` | `touched` | L'utilisateur a interagi avec le composant |\n| `ui-modified` | `modified` | L'utilisateur a modifié la valeur |\n| `ui-invalid` | `invalid` | La valeur n'a pas passé la validation du composant |\n| `ui-disabled` | `disabled` | Le composant est désactivé |\n\n```html\n<ui-component id=\"a\" name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component id=\"b\" name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\nAu démarrage, le premier composant a la classe `ui-invalid`, car sa valeur manque, et le second a `ui-disabled`. Pour en savoir plus, lis [Formulaires et validation](../forms/).\n\n## Supprimer des composants\n\nRetire l'élément de la page comme n'importe quel autre élément. La bibliothèque libère les composants supprimés une fois par minute, et `FREE()` le fait immédiatement. Le delegate `destroy` du composant s'exécute à ce moment-là.\n\n```js\nON('ready', function() {\n\t$('#area').empty();\n\tFREE();\n\tconsole.log(FIND('box', true).length);\n\n\t$('#area').html('<ui-component name=\"box\"></ui-component>');\n});\n```\n\n`FIND('name').remove()` supprime immédiatement un composant et son élément.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNn24d61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/using-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Usare i componenti","summary":"Come inserire i componenti in una pagina, configurarli, trovarli e chiamare i loro metodi.","markdown":"---\ntitle: Usare i componenti\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/using-components/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Usare i componenti\n\n> Come inserire i componenti in una pagina, configurarli, trovarli e chiamare i loro metodi.\n\nUn componente è un widget riutilizzabile che dichiari una sola volta e inserisci nella pagina con l'elemento `<ui-component>`. Questa guida spiega come usare i componenti esistenti. Per scriverne di tuoi, leggi [Creare componenti](../creating-components/).\n\n## Aggiungere un componente\n\n```html\n<ui-component name=\"label\" config=\"text:Hello\"></ui-component>\n<ui-component name=\"label\" path=\"user.name\"></ui-component>\n<ui-component name=\"label\" path=\"user.city\" default=\"'Bratislava'\"></ui-component>\n```\n\n| Attributo | Descrizione |\n| --- | --- |\n| `name` | Il nome del componente |\n| `path` | Il path del valore con cui lavora il componente. I componenti senza valore non ne hanno bisogno |\n| `config` | La configurazione di questa istanza |\n| `default` | Un'espressione JavaScript che riempie il modello quando il valore è `null` o `undefined` all'avvio |\n| `source` | L'URL da cui scaricare il componente |\n\nNell'esempio precedente, il terzo componente scrive `Bratislava` in `user.city` perché lì il modello non ha alcun valore. Una stringa in `default` ha bisogno delle proprie virgolette.\n\nI componenti funzionano anche nell'HTML che aggiungi in seguito. La libreria inizializza ogni elemento `<ui-component>` quando compare nella pagina.\n\n## Scaricare i componenti\n\nSe al momento dell'inizializzazione dell'elemento non è dichiarato alcun componente con quel nome, la libreria lo scarica. L'indirizzo proviene da `DEF.fallback`, che per impostazione predefinita è `https://cdn.componentator.com/j-{0}.html`. L'attributo `source` imposta l'indirizzo per un singolo elemento.\n\n```html\n<ui-component name=\"chart\" path=\"stats.sales\"></ui-component>\n<ui-component name=\"gauge\" source=\"/components/gauge.html\"></ui-component>\n```\n\nIl primo elemento richiede `https://cdn.componentator.com/j-chart.html` e il secondo `/components/gauge.html`. Per caricare i componenti dal tuo server, cambia il modello dell'indirizzo:\n\n```js\nDEF.fallback = '/components/{0}.html';\n```\n\n## Configurazione\n\nL'attributo `config` contiene coppie nella forma `key:value` separate da punti e virgola. I numeri e le parole `true` e `false` vengono convertiti nei rispettivi tipi. In un valore, scrivi un punto e virgola letterale come `\\;` e i due punti come `\\:`.\n\n```html\n<ui-component name=\"box\" config=\"title:Orders\\: open;limit:10;ratio:0.5;active:true;note:a\\;b\"></ui-component>\n```\n\n```js\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n\tself.make = function() {\n\t\tconsole.log(config);\n\t};\n});\n```\n\n```text\n{\"limit\":10,\"color\":\"red\",\"title\":\"Orders: open\",\"ratio\":0.5,\"active\":true,\"note\":\"a;b\"}\n```\n\nIl risultato combina i valori predefiniti del componente con quelli dell'elemento.\n\n### Chiavi speciali\n\nQueste chiavi vengono elaborate dalla libreria e funzionano con ogni componente:\n\n| Chiave | Descrizione |\n| --- | --- |\n| `$id` | Imposta l'identificatore dell'istanza |\n| `$class` | Aggiunge classi CSS all'elemento |\n| `$assign` | Salva l'istanza in un path |\n| `$init` | Chiama una funzione quando il componente viene inizializzato. L'argomento è l'istanza |\n| `$setter` | Chiama una funzione ogni volta che il valore cambia. Argomenti: `value`, `path`, `flags` |\n| `=key` | Legge da un path il valore della chiave di configurazione `key` e ne segue le modifiche |\n\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$id:mainbox;$class:highlighted;$assign:refs.box;$init:FUNC.boxready;$setter:FUNC.boxchanged\"></ui-component>\n```\n\n```js\nFUNC.boxready = function(component) {\n\tconsole.log('ready', component.id);\n};\n\nFUNC.boxchanged = function(value, path, flags) {\n\tconsole.log('value', value);\n};\nON('ready', function() {\n\tSET('form.name', 'Ana');\n\tconsole.log(refs.box.name, FIND('#mainbox').element.attr('class'));\n});\n```\n\n```text\nready mainbox\nvalue undefined\nvalue Ana\nbox highlighted\n```\n\nUna chiave di configurazione collegata a un path cambia insieme al modello:\n\n```html\n<ui-component name=\"title\" config=\"=text:settings.title\"></ui-component>\n```\n\n```js\nCOMPONENT('title', function(self) {\n\tself.configure = function(key, value) {\n\t\tif (key === 'text')\n\t\t\tself.text(value);\n\t};\n});\n\nSET('settings.title', 'First');\nON('ready', function() {\n\tSET('settings.title', 'Second');\n});\n```\n\nIl componente mostra `First` e poi `Second`.\n\n### Configurare più componenti insieme\n\n`CONFIG(selector, config)` applica una configurazione ai componenti esistenti e a quelli creati in seguito. Il selettore è il nome di un componente, più nomi separati da virgole oppure `*` per tutti i componenti.\n\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\" config=\"color:blue\"></ui-component>\n```\n\n```js\nCONFIG('box', 'size:large');\nON('ready', function() {\n\tCONFIG('box', { color: 'green' });\n\tconsole.log(FIND('box', true).map(com => com.config.color));\n});\n```\n\n```text\nnew red large\nnew blue large\n[\"green\",\"green\"]\n```\n\n## Trovare i componenti\n\n| Codice | Restituisce |\n| --- | --- |\n| `FIND('name')` | Il primo componente con questo nome |\n| `FIND('#id')` | Il componente con questo identificatore |\n| `FIND('.path')` | Il primo componente su questo path |\n| `FIND('name', true)` | Un array di tutte le corrispondenze |\n| `COMPONENTS('path')` | Un array dei componenti sul path. Per i filtri, consulta i [flag](../flags/) |\n| `$(element).component()` | Il componente dell'elemento o del suo genitore più vicino |\n\n`FIND()` restituisce solo i componenti inizializzati. Esegui il tuo codice nell'evento `ready` per essere certo che i componenti della pagina esistano.\n\n## Chiamare i metodi\n\n`SETTER('selector/method', [a], [b], [c], [d])` chiama un metodo su tutti i componenti corrispondenti. Il selettore è il nome di un componente, `#id` oppure `*` per tutti i componenti che hanno il metodo.\n\n```html\n<ui-component id=\"first\" name=\"counter\" path=\"stats.a\" config=\"$id:visits\"></ui-component>\n<ui-component name=\"counter\" path=\"stats.b\"></ui-component>\n```\n\n```js\nCOMPONENT('counter', function(self) {\n\tself.add = function(count) {\n\t\tself.set((self.get() || 0) + count);\n\t};\n});\nON('ready', function() {\n\tSETTER('#visits/add', 2);\n\tconsole.log(stats.a);\n\n\tSETTER('counter/add', 1);\n\tconsole.log(stats.a, stats.b);\n\n\tconsole.log(FIND('counter').path.toString());\n\tconsole.log(FIND('counter', true).length);\n\tconsole.log(FIND('#visits').path.toString());\n\tconsole.log(FIND('.stats.b').path.toString());\n\tconsole.log($('#first').component().id);\n});\n```\n\n```text\n2\n3 1\nstats.a\n2\nstats.a\nstats.b\nvisits\n```\n\nAggiungi il flag `@important` quando il componente potrebbe non esistere ancora. La chiamata viene ripetuta finché il componente non compare:\n\n```js\nSETTER('notify/show @important', 'Saved');\n\nsetTimeout(function() {\n\tCOMPONENT('notify', function(self) {\n\t\tself.show = message => console.log(message);\n\t});\n\t$(document.body).append('<ui-component name=\"notify\"></ui-component>');\n}, 100);\n```\n\n```text\nSaved\n```\n\n## Componenti lazy\n\nCon il prefisso `LAZY`, un componente viene creato alla prima chiamata `SETTER()` che lo riguarda. È la soluzione adatta per le finestre di dialogo e le altre parti che molti visitatori non aprono mai.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n```\n\n```js\nCOMPONENT('dialog', function(self) {\n\tself.make = () => console.log('created');\n\tself.open = title => console.log('open', title);\n});\nON('ready', function() {\n\tSETTER('dialog/open', 'Settings');\n});\n```\n\n```text\ncreated\nopen Settings\n```\n\n## Stato\n\nLa libreria conserva lo stato di ogni componente nella sua configurazione e lo riflette nelle classi CSS dell'elemento:\n\n| Classe CSS | Chiave di configurazione | Significato |\n| --- | --- | --- |\n| `ui-touched` | `touched` | L'utente ha interagito con il componente |\n| `ui-modified` | `modified` | L'utente ha modificato il valore |\n| `ui-invalid` | `invalid` | Il valore non ha superato la validazione del componente |\n| `ui-disabled` | `disabled` | Il componente è disabilitato |\n\n```html\n<ui-component id=\"a\" name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component id=\"b\" name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\nAll'avvio, il primo componente ha la classe `ui-invalid` perché il suo valore manca e il secondo ha `ui-disabled`. Approfondisci in [Moduli e validazione](../forms/).\n\n## Rimuovere i componenti\n\nRimuovi l'elemento dalla pagina come faresti con qualsiasi altro elemento. La libreria rilascia i componenti rimossi una volta al minuto, mentre `FREE()` lo fa subito. In quel momento viene eseguito il delegate `destroy` del componente.\n\n```js\nON('ready', function() {\n\t$('#area').empty();\n\tFREE();\n\tconsole.log(FIND('box', true).length);\n\n\t$('#area').html('<ui-component name=\"box\"></ui-component>');\n});\n```\n\n`FIND('name').remove()` rimuove subito un componente e il suo elemento.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNn24d61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/using-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Používanie komponentov","summary":"Ako umiestniť komponenty na stránku, nakonfigurovať ich, nájsť ich a volať ich metódy.","markdown":"---\ntitle: \"Používanie komponentov\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/using-components/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Používanie komponentov\n\n> Ako umiestniť komponenty na stránku, nakonfigurovať ich, nájsť ich a volať ich metódy.\n\nKomponent je opakovane použiteľný widget, ktorý raz deklaruješ a na stránku umiestniš elementom `<ui-component>`. Táto príručka opisuje, ako používať existujúce komponenty. Ak chceš napísať vlastný, prečítaj si [Vytváranie komponentov](../creating-components/).\n\n## Pridanie komponentu\n\n```html\n<ui-component name=\"label\" config=\"text:Hello\"></ui-component>\n<ui-component name=\"label\" path=\"user.name\"></ui-component>\n<ui-component name=\"label\" path=\"user.city\" default=\"'Bratislava'\"></ui-component>\n```\n\n| Atribút | Popis |\n| --- | --- |\n| `name` | Názov komponentu |\n| `path` | Path hodnoty, s ktorou komponent pracuje. Komponenty bez hodnoty ju nepotrebujú |\n| `config` | Konfigurácia tejto inštancie |\n| `default` | JavaScriptový výraz, ktorý pri štarte doplní model, keď je hodnota `null` alebo `undefined` |\n| `source` | URL, z ktorej sa komponent stiahne |\n\nV príklade vyššie tretí komponent zapíše `Bratislava` do `user.city`, pretože model tam nemá žiadnu hodnotu. Reťazec v `default` potrebuje vlastné úvodzovky.\n\nKomponenty fungujú aj v HTML, ktoré pridáš neskôr. Knižnica inicializuje každý element `<ui-component>`, keď sa objaví na stránke.\n\n## Sťahovanie komponentov\n\nKeď v čase inicializácie elementu nie je deklarovaný žiadny komponent s daným názvom, knižnica ho stiahne. Adresa pochádza z `DEF.fallback`, čo je predvolene `https://cdn.componentator.com/j-{0}.html`. Atribút `source` nastaví adresu pre jeden element.\n\n```html\n<ui-component name=\"chart\" path=\"stats.sales\"></ui-component>\n<ui-component name=\"gauge\" source=\"/components/gauge.html\"></ui-component>\n```\n\nPrvý element si vyžiada `https://cdn.componentator.com/j-chart.html` a druhý `/components/gauge.html`. Ak chceš načítavať komponenty z vlastného servera, zmeň vzor:\n\n```js\nDEF.fallback = '/components/{0}.html';\n```\n\n## Konfigurácia\n\nAtribút `config` obsahuje dvojice v tvare `key:value` oddelené bodkočiarkami. Čísla a slová `true` a `false` sa prevedú na príslušné typy. Bodkočiarku v hodnote zapíš ako `\\;` a dvojbodku ako `\\:`.\n\n```html\n<ui-component name=\"box\" config=\"title:Orders\\: open;limit:10;ratio:0.5;active:true;note:a\\;b\"></ui-component>\n```\n\n```js\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n\tself.make = function() {\n\t\tconsole.log(config);\n\t};\n});\n```\n\n```text\n{\"limit\":10,\"color\":\"red\",\"title\":\"Orders: open\",\"ratio\":0.5,\"active\":true,\"note\":\"a;b\"}\n```\n\nVýsledok spája predvolené hodnoty komponentu s hodnotami elementu.\n\n### Špeciálne kľúče\n\nTieto kľúče spracúva knižnica a fungujú s každým komponentom:\n\n| Kľúč | Popis |\n| --- | --- |\n| `$id` | Nastaví identifikátor inštancie |\n| `$class` | Pridá elementu CSS triedy |\n| `$assign` | Uloží inštanciu na path |\n| `$init` | Zavolá funkciu po inicializácii komponentu. Argumentom je inštancia |\n| `$setter` | Zavolá funkciu pri každej zmene hodnoty. Argumenty: `value`, `path`, `flags` |\n| `=key` | Načíta hodnotu konfiguračného kľúča `key` z path a sleduje jej zmeny |\n\n```html\n<ui-component name=\"box\" path=\"form.name\" config=\"$id:mainbox;$class:highlighted;$assign:refs.box;$init:FUNC.boxready;$setter:FUNC.boxchanged\"></ui-component>\n```\n\n```js\nFUNC.boxready = function(component) {\n\tconsole.log('ready', component.id);\n};\n\nFUNC.boxchanged = function(value, path, flags) {\n\tconsole.log('value', value);\n};\nON('ready', function() {\n\tSET('form.name', 'Ana');\n\tconsole.log(refs.box.name, FIND('#mainbox').element.attr('class'));\n});\n```\n\n```text\nready mainbox\nvalue undefined\nvalue Ana\nbox highlighted\n```\n\nKonfiguračný kľúč prepojený s path sa mení spolu s modelom:\n\n```html\n<ui-component name=\"title\" config=\"=text:settings.title\"></ui-component>\n```\n\n```js\nCOMPONENT('title', function(self) {\n\tself.configure = function(key, value) {\n\t\tif (key === 'text')\n\t\t\tself.text(value);\n\t};\n});\n\nSET('settings.title', 'First');\nON('ready', function() {\n\tSET('settings.title', 'Second');\n});\n```\n\nKomponent zobrazí `First` a potom `Second`.\n\n### Konfigurácia viacerých komponentov naraz\n\n`CONFIG(selector, config)` použije konfiguráciu na existujúce komponenty aj na tie, ktoré vzniknú neskôr. Selektor je názov komponentu, niekoľko názvov oddelených čiarkami alebo `*` pre všetky komponenty.\n\n```html\n<ui-component name=\"box\"></ui-component>\n<ui-component name=\"box\" config=\"color:blue\"></ui-component>\n```\n\n```js\nCONFIG('box', 'size:large');\nON('ready', function() {\n\tCONFIG('box', { color: 'green' });\n\tconsole.log(FIND('box', true).map(com => com.config.color));\n});\n```\n\n```text\nnew red large\nnew blue large\n[\"green\",\"green\"]\n```\n\n## Hľadanie komponentov\n\n| Kód | Vráti |\n| --- | --- |\n| `FIND('name')` | Prvý komponent s týmto názvom |\n| `FIND('#id')` | Komponent s týmto identifikátorom |\n| `FIND('.path')` | Prvý komponent na tejto path |\n| `FIND('name', true)` | Pole všetkých zhôd |\n| `COMPONENTS('path')` | Pole komponentov na path. Filtre nájdeš vo [flagoch](../flags/) |\n| `$(element).component()` | Komponent elementu alebo jeho najbližšieho nadradeného elementu |\n\n`FIND()` vracia iba inicializované komponenty. Spusti svoj kód v udalosti `ready`, aby si mal istotu, že komponenty na stránke existujú.\n\n## Volanie metód\n\n`SETTER('selector/method', [a], [b], [c], [d])` zavolá metódu na všetkých zodpovedajúcich komponentoch. Selektor je názov komponentu, `#id` alebo `*` pre všetky komponenty, ktoré danú metódu majú.\n\n```html\n<ui-component id=\"first\" name=\"counter\" path=\"stats.a\" config=\"$id:visits\"></ui-component>\n<ui-component name=\"counter\" path=\"stats.b\"></ui-component>\n```\n\n```js\nCOMPONENT('counter', function(self) {\n\tself.add = function(count) {\n\t\tself.set((self.get() || 0) + count);\n\t};\n});\nON('ready', function() {\n\tSETTER('#visits/add', 2);\n\tconsole.log(stats.a);\n\n\tSETTER('counter/add', 1);\n\tconsole.log(stats.a, stats.b);\n\n\tconsole.log(FIND('counter').path.toString());\n\tconsole.log(FIND('counter', true).length);\n\tconsole.log(FIND('#visits').path.toString());\n\tconsole.log(FIND('.stats.b').path.toString());\n\tconsole.log($('#first').component().id);\n});\n```\n\n```text\n2\n3 1\nstats.a\n2\nstats.a\nstats.b\nvisits\n```\n\nPridaj flag `@important`, keď komponent ešte nemusí existovať. Volanie sa opakuje, kým sa komponent neobjaví:\n\n```js\nSETTER('notify/show @important', 'Saved');\n\nsetTimeout(function() {\n\tCOMPONENT('notify', function(self) {\n\t\tself.show = message => console.log(message);\n\t});\n\t$(document.body).append('<ui-component name=\"notify\"></ui-component>');\n}, 100);\n```\n\n```text\nSaved\n```\n\n## Lenivé komponenty\n\nS prefixom `LAZY` sa komponent vytvorí pri prvom volaní `SETTER()`, ktoré naň mieri. Hodí sa to pre dialógy a ďalšie časti, ktoré mnohí návštevníci nikdy neotvoria.\n\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n```\n\n```js\nCOMPONENT('dialog', function(self) {\n\tself.make = () => console.log('created');\n\tself.open = title => console.log('open', title);\n});\nON('ready', function() {\n\tSETTER('dialog/open', 'Settings');\n});\n```\n\n```text\ncreated\nopen Settings\n```\n\n## Stav\n\nKnižnica uchováva stav každého komponentu v jeho konfigurácii a premieta ho do CSS tried na elemente:\n\n| CSS trieda | Konfiguračný kľúč | Význam |\n| --- | --- | --- |\n| `ui-touched` | `touched` | Používateľ s komponentom pracoval |\n| `ui-modified` | `modified` | Používateľ zmenil hodnotu |\n| `ui-invalid` | `invalid` | Hodnota neprešla validáciou komponentu |\n| `ui-disabled` | `disabled` | Komponent je vypnutý |\n\n```html\n<ui-component id=\"a\" name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component id=\"b\" name=\"field\" path=\"form.note\" config=\"disabled:true\"></ui-component>\n```\n\nPri štarte má prvý komponent triedu `ui-invalid`, pretože mu chýba hodnota, a druhý má `ui-disabled`. Viac sa dočítaš v časti [Formuláre a validácia](../forms/).\n\n## Odstraňovanie komponentov\n\nElement odstráň zo stránky ako každý iný element. Knižnica uvoľňuje odstránené komponenty raz za minútu a `FREE()` to urobí okamžite. V tej chvíli sa spustí delegate `destroy` komponentu.\n\n```js\nON('ready', function() {\n\t$('#area').empty();\n\tFREE();\n\tconsole.log(FIND('box', true).length);\n\n\t$('#area').html('<ui-component name=\"box\"></ui-component>');\n});\n```\n\n`FIND('name').remove()` okamžite odstráni jeden komponent aj s jeho elementom.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNA1gd61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/creating-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Creating components","summary":"How to declare your own components, handle values and configuration, validate input and clean up.","markdown":"---\ntitle: Creating components\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/creating-components/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# Creating components\n\n> How to declare your own components, handle values and configuration, validate input and clean up.\n\nA component joins HTML, behaviour and a value from the model into one reusable widget. You declare it once with `COMPONENT()` and use it on the page as described in [Using components](../using-components/).\n\n## Declaring a component\n\n```js\nCOMPONENT(name, [config], callback, [dependencies], [css]);\n```\n\n| Argument | Type | Description |\n| --- | --- | --- |\n| `name` | String | The name used in `<ui-component name=\"...\">` |\n| `config` | String | The default configuration in the form `key:value;key:value` |\n| `callback` | Function | Runs for each instance with the arguments `self`, `config` and `cls` |\n| `dependencies` | String or Array | Resources to load ahead of the initialization. A string can list several URLs separated by commas |\n| `css` | String | The CSS of the component |\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\"></ui-component>\n```\n\n```js\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.text('Hello ' + config.name);\n\t};\n});\n```\n\nThe rendered element:\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\" class=\"ui-hello\">Hello Ana</ui-component>\n```\n\nThe callback receives:\n\n- `self`, the component instance\n- `config`, the merged configuration of the instance\n- `cls`, the CSS class name of the component in the form `ui-name`. The library does not add it to the element, so call `self.aclass(cls)`\n\nDeclare components while the page loads. A name that is unknown when its element initializes is [downloaded from the CDN](../using-components/).\n\n## Lifecycle\n\nYou define the behaviour of a component by assigning functions, called delegates, to `self`. The library calls them in this order:\n\n```html\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n```\n\n```js\nCOMPONENT('demo', 'color:red', function(self, config) {\n\tconsole.log('declaration');\n\tself.init = () => console.log('init');\n\tself.make = () => console.log('make');\n\tself.configure = (key, value, init) => console.log('configure', key, value, init);\n\tself.setter = (value, path, flags) => console.log('setter', value, path, flags);\n\tself.validate = () => true;\n\tself.state = () => console.log('state');\n\tself.done = () => console.log('done');\n});\n\nSET('app.value', 1);\n```\n\n```text\ndeclaration\ninit\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\ndeclaration\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\n```\n\n| Delegate | When it runs |\n| --- | --- |\n| `self.init()` | Once for the component type, on its first instance |\n| `self.make()` | Once for each instance. Create the HTML here |\n| `self.configure(key, value, init)` | For each configuration key at startup, with `init` set to `true`, and at each later change |\n| `self.setter(value, path, flags)` | When the value in the model changes |\n| `self.setter2(value, path, flags)` | After `setter`, also for values written by the component itself |\n| `self.validate(value)` | After each change of the value. It decides if the value is valid |\n| `self.state()` | When the library updates the touched, modified, invalid or disabled state |\n| `self.done()` | Once for each instance, at the end of the initialization |\n| `self.destroy()` | When the component is removed |\n\nThe configuration keys that the library maintains, such as `invalid`, also go through `configure`.\n\n## Useful properties\n\n| Property | Description |\n| --- | --- |\n| `self.element` | The element as a jQuery object |\n| `self.dom` | The DOM element |\n| `self.config` | The configuration |\n| `self.path` | The path of the component. Use `self.path.toString()` to get a string |\n| `self.name` | The name of the component |\n| `self.id` | The identifier of the instance |\n\nThe complete list is in the [Component reference](../../reference/component/).\n\n## Receiving values\n\n`self.setter` runs at startup and on each change of the value. The `path` argument contains the path that was changed, which can be a parent of the component's path. The `flags` argument contains the [flags](../flags/) of the operation. The library adds `init` for the first call and `refresh` for `self.refresh()`.\n\n```html\n<ui-component name=\"badge\" path=\"inbox.count\"></ui-component>\n```\n\n```js\nCOMPONENT('badge', function(self) {\n\n\tself.setter = function(value, path, flags) {\n\t\tself.text(value == null ? 'none' : value + ' new');\n\t\tconsole.log(self.text(), path, flags);\n\t};\n\n});\n\nSET('inbox.count', 3);\nON('ready', function() {\n\tSET('inbox.count', 5);\n\tSET('inbox @reload', { count: 7 });\n\tFIND('badge').refresh();\n});\n```\n\n```text\n3 new inbox.count {\"init\":1}\n5 new inbox.count {}\n7 new inbox {\"reload\":1}\n7 new inbox.count {\"refresh\":1}\n```\n\nA component without its own `setter` writes the value into the first `input`, `select` or `textarea` inside its element.\n\n## Sending values\n\n| Method | Effect |\n| --- | --- |\n| `self.get()` | Reads the value from the model |\n| `self.set(value, [flags])` | Writes the value and calls the setters of all components on the path |\n| `self.modify(value, [flags])` | Marks the component as touched and modified, and then writes the value |\n| `self.rewrite(value, [flags])` | Writes the value without calling the `setter` of this component |\n\n```html\n<ui-component name=\"stepper\" path=\"cart.quantity\" config=\"step:2\"></ui-component>\n<p>Quantity: <ui-bind path=\"cart.quantity\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('stepper', 'step:1', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<button name=\"minus\">-</button><b></b><button name=\"plus\">+</button>');\n\t\tself.event('click', 'button', function() {\n\t\t\tvar diff = this.name === 'plus' ? config.step : -config.step;\n\t\t\tself.modify((self.get() || 0) + diff);\n\t\t});\n\t};\n\n\tself.setter = function(value) {\n\t\tself.find('b').text(value);\n\t};\n\n});\n\nSET('cart.quantity', 4);\n```\n\nClicking `+` changes the quantity from `4` to `6`. The element receives the classes `ui-touched` and `ui-modified`, and the paragraph follows the model.\n\n`self.rewrite()` suits components that already display the value they write. Their `setter` is skipped, while `setter2` still runs:\n\n```html\n<ui-component name=\"search\" path=\"filter.query\"></ui-component>\n```\n\n```js\nCOMPONENT('search', function(self) {\n\n\tself.setter = value => console.log('setter', value);\n\tself.setter2 = value => console.log('setter2', value);\n\n\tself.write = function(value) {\n\t\tself.rewrite(value);\n\t};\n\n});\nON('ready', function() {\n\tSET('filter.query', 'pen');\n\tFIND('search').write('book');\n\tconsole.log(filter.query);\n});\n```\n\n```text\nsetter pen\nsetter2 pen\nsetter2 book\nbook\n```\n\n## Binding inputs\n\n`self.autobind20([delay])` connects the `input`, `select` and `textarea` elements inside the component to the model. It writes the value while the user types, after a delay of 200 milliseconds by default, and marks the component as touched and modified.\n\nThe value passes through these steps on its way to the model:\n\n1. The function registered with `self.parser()` changes the value.\n2. The configuration key `type` converts it. Supported types are `number`, `currency`, `float`, `boolean`, `bool`, `date` and `datetime`.\n\nOn its way to the input, the default setter passes the value through the function registered with `self.formatter()`.\n\n```html\n<ui-component name=\"input\" path=\"order.count\" config=\"type:number\"></ui-component>\n<ui-component name=\"input\" path=\"order.code\" config=\"upper:true\"></ui-component>\n```\n\n```js\nCOMPONENT('input', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.parser(function(path, value) {\n\t\treturn config.upper ? value.toUpperCase() : value;\n\t});\n\n\tself.formatter(function(path, value) {\n\t\treturn config.upper && value ? value.toLowerCase() : value;\n\t});\n\n});\n\nSET('order.code', 'ABC');\n```\n\nAfter typing `42` into the first input and `xyz` into the second, the model contains:\n\n```text\n{\"code\":\"XYZ\",\"count\":42}\n```\n\nThe second input showed `abc` at startup, because the formatter converts the stored `ABC` for display. To process a value from your own widget in the same way, call `self.getter(value)`.\n\n## Configuration\n\nRead the configuration from the `config` object. Use `self.configure` to apply the values and to react to later changes. `self.reconfigure()` changes the configuration of a running component. It accepts a string or an object.\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\"></ui-component>\n```\n\n```js\nCOMPONENT('textbox', 'maxlength:10', function(self, config) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t};\n\tself.configure = function(key, value) {\n\t\tif (key === 'maxlength')\n\t\t\tself.find('input').attr(key, value);\n\t};\n});\n\nEXTENSION('textbox', 'maxlength:5', function(self, config) {\n\tself.clear = () => self.set('');\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').config.maxlength);\n\tconsole.log(typeof FIND('textbox').clear);\n\n\tFIND('textbox').reconfigure('maxlength:3');\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n\n\tFIND('textbox').reconfigure({ maxlength: 8 });\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n});\n```\n\n```text\n5\nfunction\n3\n8\n```\n\n`EXTENSION(name, [config], callback)` adds behaviour to a component that you did not write. It works for existing instances and for those created later. In the example above, it changes the default `maxlength` and adds the method `clear()`.\n\n## Validation and state\n\n`self.validate` returns `true` for a valid value. Return `false` or a string for an invalid one. A string is stored in `config.invalid`, so it can serve as the error message.\n\n```html\n<ui-component id=\"pin\" name=\"pin\" path=\"login.pin\"></ui-component>\n```\n\n```js\nCOMPONENT('pin', function(self, config) {\n\n\tself.validate = function(value) {\n\t\treturn value && value.length === 4 ? true : 'Enter 4 digits';\n\t};\n\n\tself.state = function() {\n\t\tself.text(config.invalid && config.touched ? config.invalid : 'OK or untouched');\n\t};\n\n});\nON('ready', function() {\n\tvar pin = FIND('pin');\n\n\tpin.touch();\n\tconsole.log(pin.config.touched, pin.config.invalid);\n\n\tSET('login.pin', '1234');\n\tconsole.log(pin.config.invalid);\n\n\tpin.reset();\n\tconsole.log(pin.config.touched);\n});\n```\n\n```text\n1 Enter 4 digits\nfalse\n0\n```\n\n| Method | Effect |\n| --- | --- |\n| `self.touch()` | Marks the component as touched and validates it |\n| `self.change()` | Marks the component as touched and modified, and validates it |\n| `self.reset()` | Clears the touched and modified state and validates the component |\n\nRead the current state from `config.touched`, `config.modified`, `config.invalid` and `config.disabled` in `self.state`. The library maintains the CSS classes `ui-touched`, `ui-modified`, `ui-invalid` and `ui-disabled` for you.\n\n## Styles\n\nThe last argument of `COMPONENT()` contains the CSS. The word `CLASS` is replaced by the class name of the component.\n\n```html\n<ui-component name=\"card\"><b>Title</b></ui-component>\n```\n\n```js\nCOMPONENT('card', '', function(self, config, cls) {\n\tself.make = () => self.aclass(cls);\n}, null, '.CLASS { border: 1px solid #ccc; } .CLASS b { color: red; }');\n```\n\nThe library adds this rule to the page:\n\n```css\n.ui-card { border: 1px solid #ccc; } .ui-card b { color: red; }\n```\n\n## Methods and commands\n\nEach function that you assign to `self` is a public method, which others call with `SETTER()`. A command is a named action with any number of handlers, registered with `self.command(name, callback)` and executed on an instance with `self.CMD(name, [a], [b], [c], [d])`, or on every component that has it with the global `CMD(name, [a], [b], [c], [d])`.\n\n```html\n<ui-component name=\"list\" path=\"data.rows\"></ui-component>\n```\n\n```js\nCOMPONENT('list', function(self) {\n\n\t// A public method\n\tself.clear = function() {\n\t\tself.set([]);\n\t};\n\n\t// A named command, a command name can have several handlers\n\tself.command('highlight', index => console.log('first handler', index));\n\tself.command('highlight', index => console.log('second handler', index));\n\n});\n\nSET('data.rows', [1, 2, 3]);\nON('ready', function() {\n\tSETTER('list/clear');\n\tconsole.log(data.rows);\n\n\tFIND('list').CMD('highlight', 2);\n});\n```\n\n```text\n[]\nfirst handler 2\nsecond handler 2\n```\n\n## Events and watchers\n\n| Method | Description |\n| --- | --- |\n| `self.event(name, [selector], callback)` | Registers a DOM event on the element |\n| `self.on(name, callback)` | Registers a global event sent with `EMIT()` |\n| `self.watch(path, callback, [init])` | Watches a path of the model |\n| `self.watch(callback)` | Watches the path of the component |\n\n```html\n<ui-component name=\"status\" path=\"app.state\"></ui-component>\n```\n\n```js\nCOMPONENT('status', function(self) {\n\n\tself.make = function() {\n\n\t\t// Any path of the model\n\t\tself.watch('app.user', function(value, flags, path) {\n\t\t\tconsole.log('user', value, path);\n\t\t});\n\n\t\t// The path of the component\n\t\tself.watch(value => console.log('own path', value));\n\n\t\t// A global event\n\t\tself.on('logout', reason => console.log('logout', reason));\n\t};\n\n});\nON('ready', function() {\n\tSET('app.user', 'Ana');\n\tSET('app.state', 'online');\n\tEMIT('logout', 'timeout');\n});\n```\n\n```text\nuser Ana app.user\nown path online\nlogout timeout\n```\n\n## Cleaning up\n\nRelease timers and other resources in `self.destroy`:\n\n```html\n<ui-component name=\"ticker\"></ui-component>\n```\n\n```js\nCOMPONENT('ticker', function(self) {\n\n\tvar timer;\n\n\tself.make = function() {\n\t\ttimer = setInterval(() => self.text(new Date().toISOString()), 1000);\n\t};\n\n\tself.destroy = function() {\n\t\tclearInterval(timer);\n\t\tconsole.log('stopped');\n\t};\n\n});\n```\n\n## Special kinds of components\n\n| Method | Effect |\n| --- | --- |\n| `self.singleton()` | Allows one instance on the page. The library removes the elements of other instances |\n| `self.blind()` | The component does not react to changes in the model |\n| `self.readonly()` | The component only displays content. It has no setter, no getter and no validation |\n\n```html\n<ui-component name=\"toast\"></ui-component>\n<ui-component name=\"toast\"></ui-component>\n```\n\n```js\nCOMPONENT('toast', function(self) {\n\tself.singleton();\n\tself.make = () => console.log('created once');\n});\n```\n\nThe delegate `make` runs once and one `<ui-component>` element stays on the page.\n\n```html\n<ui-component name=\"clock\" path=\"app.time\"></ui-component>\n<ui-component name=\"logo\" path=\"app.time\"></ui-component>\n```\n\n```js\nCOMPONENT('clock', function(self) {\n\tself.blind();\n\tself.setter = value => console.log('clock setter', value);\n});\n\nCOMPONENT('logo', function(self) {\n\tself.readonly();\n\tself.make = () => self.text('Logo');\n});\nON('ready', function() {\n\tSET('app.time', 1);\n\tconsole.log(FIND('logo').config.invalid);\n});\n```\n\nAfter `SET('app.time', 1)`, the `clock` component does not run its setter, and `logo` stays valid.\n\n## Dependencies\n\nThe fourth argument lists what a component needs. A string is a URL loaded with `IMPORT()`, and a function receives a `next` callback. The instance starts when all dependencies are ready.\n\n```html\n<ui-component name=\"map\"></ui-component>\n```\n\n```js\nCOMPONENT('map', '', function(self) {\n\tself.make = () => console.log('ready to use', W.mapsdk);\n}, [\n\t'https://example.com/maps.js',\n\tfunction(next) {\n\t\tW.mapsdk = 'loaded';\n\t\tnext();\n\t}\n]);\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcNA1gd61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/creating-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Komponenten erstellen","summary":"Wie du eigene Komponenten deklarierst, Werte und Konfiguration verarbeitest, Eingaben validierst und aufräumst.","markdown":"---\ntitle: Komponenten erstellen\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/creating-components/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# Komponenten erstellen\n\n> Wie du eigene Komponenten deklarierst, Werte und Konfiguration verarbeitest, Eingaben validierst und aufräumst.\n\nEine Komponente vereint HTML, Verhalten und einen Wert aus dem Modell in einem wiederverwendbaren Widget. Du deklarierst sie einmal mit `COMPONENT()` und verwendest sie auf der Seite wie unter [Komponenten verwenden](../using-components/) beschrieben.\n\n## Eine Komponente deklarieren\n\n```js\nCOMPONENT(name, [config], callback, [dependencies], [css]);\n```\n\n| Argument | Typ | Beschreibung |\n| --- | --- | --- |\n| `name` | String | Der Name, der in `<ui-component name=\"...\">` verwendet wird |\n| `config` | String | Die Standardkonfiguration in der Form `key:value;key:value` |\n| `callback` | Function | Läuft für jede Instanz mit den Argumenten `self`, `config` und `cls` |\n| `dependencies` | String oder Array | Ressourcen, die vor der Initialisierung geladen werden. Ein String kann mehrere durch Kommas getrennte URLs enthalten |\n| `css` | String | Das CSS der Komponente |\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\"></ui-component>\n```\n\n```js\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.text('Hello ' + config.name);\n\t};\n});\n```\n\nDas gerenderte Element:\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\" class=\"ui-hello\">Hello Ana</ui-component>\n```\n\nDer Callback erhält:\n\n- `self`, die Instanz der Komponente\n- `config`, die zusammengeführte Konfiguration der Instanz\n- `cls`, den Namen der CSS-Klasse der Komponente in der Form `ui-name`. Die Bibliothek fügt ihn dem Element nicht hinzu, rufe also `self.aclass(cls)` auf\n\nDeklariere Komponenten, während die Seite lädt. Ein Name, der beim Initialisieren seines Elements unbekannt ist, wird [aus dem CDN heruntergeladen](../using-components/).\n\n## Lebenszyklus\n\nDas Verhalten einer Komponente legst du fest, indem du `self` Funktionen zuweist, die Delegates genannt werden. Die Bibliothek ruft sie in dieser Reihenfolge auf:\n\n```html\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n```\n\n```js\nCOMPONENT('demo', 'color:red', function(self, config) {\n\tconsole.log('declaration');\n\tself.init = () => console.log('init');\n\tself.make = () => console.log('make');\n\tself.configure = (key, value, init) => console.log('configure', key, value, init);\n\tself.setter = (value, path, flags) => console.log('setter', value, path, flags);\n\tself.validate = () => true;\n\tself.state = () => console.log('state');\n\tself.done = () => console.log('done');\n});\n\nSET('app.value', 1);\n```\n\n```text\ndeclaration\ninit\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\ndeclaration\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\n```\n\n| Delegate | Wann es läuft |\n| --- | --- |\n| `self.init()` | Einmal pro Komponententyp, bei dessen erster Instanz |\n| `self.make()` | Einmal pro Instanz. Erzeuge hier das HTML |\n| `self.configure(key, value, init)` | Beim Start für jeden Konfigurationsschlüssel, mit `init` auf `true`, und bei jeder späteren Änderung |\n| `self.setter(value, path, flags)` | Wenn sich der Wert im Modell ändert |\n| `self.setter2(value, path, flags)` | Nach `setter`, auch für Werte, die die Komponente selbst geschrieben hat |\n| `self.validate(value)` | Nach jeder Änderung des Werts. Es entscheidet, ob der Wert gültig ist |\n| `self.state()` | Wenn die Bibliothek den Zustand „berührt“, „geändert“, „ungültig“ oder „deaktiviert“ aktualisiert |\n| `self.done()` | Einmal pro Instanz, am Ende der Initialisierung |\n| `self.destroy()` | Wenn die Komponente entfernt wird |\n\nAuch die Konfigurationsschlüssel, die die Bibliothek selbst pflegt, wie `invalid`, laufen durch `configure`.\n\n## Nützliche Eigenschaften\n\n| Eigenschaft | Beschreibung |\n| --- | --- |\n| `self.element` | Das Element als jQuery-Objekt |\n| `self.dom` | Das DOM-Element |\n| `self.config` | Die Konfiguration |\n| `self.path` | Der Path der Komponente. Mit `self.path.toString()` erhältst du einen String |\n| `self.name` | Der Name der Komponente |\n| `self.id` | Die Kennung der Instanz |\n\nDie vollständige Liste steht in der [Referenz zu Component](../../reference/component/).\n\n## Werte empfangen\n\n`self.setter` läuft beim Start und bei jeder Änderung des Werts. Das Argument `path` enthält den geänderten Path, der dem Path der Komponente übergeordnet sein kann. Das Argument `flags` enthält die [Flags](../flags/) der Operation. Die Bibliothek ergänzt `init` beim ersten Aufruf und `refresh` bei `self.refresh()`.\n\n```html\n<ui-component name=\"badge\" path=\"inbox.count\"></ui-component>\n```\n\n```js\nCOMPONENT('badge', function(self) {\n\n\tself.setter = function(value, path, flags) {\n\t\tself.text(value == null ? 'none' : value + ' new');\n\t\tconsole.log(self.text(), path, flags);\n\t};\n\n});\n\nSET('inbox.count', 3);\nON('ready', function() {\n\tSET('inbox.count', 5);\n\tSET('inbox @reload', { count: 7 });\n\tFIND('badge').refresh();\n});\n```\n\n```text\n3 new inbox.count {\"init\":1}\n5 new inbox.count {}\n7 new inbox {\"reload\":1}\n7 new inbox.count {\"refresh\":1}\n```\n\nEine Komponente ohne eigenen `setter` schreibt den Wert in das erste `input`, `select` oder `textarea` innerhalb ihres Elements.\n\n## Werte senden\n\n| Methode | Wirkung |\n| --- | --- |\n| `self.get()` | Liest den Wert aus dem Modell |\n| `self.set(value, [flags])` | Schreibt den Wert und ruft die Setter aller Komponenten auf dem Path auf |\n| `self.modify(value, [flags])` | Markiert die Komponente als berührt und geändert und schreibt dann den Wert |\n| `self.rewrite(value, [flags])` | Schreibt den Wert, ohne den `setter` dieser Komponente aufzurufen |\n\n```html\n<ui-component name=\"stepper\" path=\"cart.quantity\" config=\"step:2\"></ui-component>\n<p>Quantity: <ui-bind path=\"cart.quantity\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('stepper', 'step:1', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<button name=\"minus\">-</button><b></b><button name=\"plus\">+</button>');\n\t\tself.event('click', 'button', function() {\n\t\t\tvar diff = this.name === 'plus' ? config.step : -config.step;\n\t\t\tself.modify((self.get() || 0) + diff);\n\t\t});\n\t};\n\n\tself.setter = function(value) {\n\t\tself.find('b').text(value);\n\t};\n\n});\n\nSET('cart.quantity', 4);\n```\n\nEin Klick auf `+` ändert die Menge von `4` auf `6`. Das Element erhält die Klassen `ui-touched` und `ui-modified`, und der Absatz folgt dem Modell.\n\n`self.rewrite()` eignet sich für Komponenten, die den geschriebenen Wert bereits anzeigen. Der `setter` solcher Komponenten wird übersprungen, `setter2` läuft aber weiterhin:\n\n```html\n<ui-component name=\"search\" path=\"filter.query\"></ui-component>\n```\n\n```js\nCOMPONENT('search', function(self) {\n\n\tself.setter = value => console.log('setter', value);\n\tself.setter2 = value => console.log('setter2', value);\n\n\tself.write = function(value) {\n\t\tself.rewrite(value);\n\t};\n\n});\nON('ready', function() {\n\tSET('filter.query', 'pen');\n\tFIND('search').write('book');\n\tconsole.log(filter.query);\n});\n```\n\n```text\nsetter pen\nsetter2 pen\nsetter2 book\nbook\n```\n\n## Eingabefelder binden\n\n`self.autobind20([delay])` verbindet die Elemente `input`, `select` und `textarea` innerhalb der Komponente mit dem Modell. Es schreibt den Wert, während der Benutzer tippt, standardmäßig mit einer Verzögerung von 200 Millisekunden, und markiert die Komponente als berührt und geändert.\n\nAuf dem Weg zum Modell durchläuft der Wert diese Schritte:\n\n1. Die mit `self.parser()` registrierte Funktion ändert den Wert.\n2. Der Konfigurationsschlüssel `type` wandelt ihn um. Unterstützte Typen sind `number`, `currency`, `float`, `boolean`, `bool`, `date` und `datetime`.\n\nAuf dem Weg zum Eingabefeld leitet der Standard-Setter den Wert durch die mit `self.formatter()` registrierte Funktion.\n\n```html\n<ui-component name=\"input\" path=\"order.count\" config=\"type:number\"></ui-component>\n<ui-component name=\"input\" path=\"order.code\" config=\"upper:true\"></ui-component>\n```\n\n```js\nCOMPONENT('input', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.parser(function(path, value) {\n\t\treturn config.upper ? value.toUpperCase() : value;\n\t});\n\n\tself.formatter(function(path, value) {\n\t\treturn config.upper && value ? value.toLowerCase() : value;\n\t});\n\n});\n\nSET('order.code', 'ABC');\n```\n\nNachdem du `42` in das erste und `xyz` in das zweite Eingabefeld getippt hast, enthält das Modell:\n\n```text\n{\"code\":\"XYZ\",\"count\":42}\n```\n\nDas zweite Eingabefeld zeigte beim Start `abc`, weil der Formatter das gespeicherte `ABC` für die Anzeige umwandelt. Um einen Wert aus deinem eigenen Widget genauso zu verarbeiten, rufst du `self.getter(value)` auf.\n\n## Konfiguration\n\nLies die Konfiguration aus dem Objekt `config`. Mit `self.configure` wendest du die Werte an und reagierst auf spätere Änderungen. `self.reconfigure()` ändert die Konfiguration einer laufenden Komponente. Es akzeptiert einen String oder ein Objekt.\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\"></ui-component>\n```\n\n```js\nCOMPONENT('textbox', 'maxlength:10', function(self, config) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t};\n\tself.configure = function(key, value) {\n\t\tif (key === 'maxlength')\n\t\t\tself.find('input').attr(key, value);\n\t};\n});\n\nEXTENSION('textbox', 'maxlength:5', function(self, config) {\n\tself.clear = () => self.set('');\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').config.maxlength);\n\tconsole.log(typeof FIND('textbox').clear);\n\n\tFIND('textbox').reconfigure('maxlength:3');\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n\n\tFIND('textbox').reconfigure({ maxlength: 8 });\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n});\n```\n\n```text\n5\nfunction\n3\n8\n```\n\n`EXTENSION(name, [config], callback)` ergänzt das Verhalten einer Komponente, die du nicht selbst geschrieben hast. Das gilt für vorhandene und später erstellte Instanzen. Im Beispiel oben ändert es das Standard-`maxlength` und fügt die Methode `clear()` hinzu.\n\n## Validierung und Zustand\n\n`self.validate` gibt bei einem gültigen Wert `true` zurück. Gib bei einem ungültigen Wert `false` oder einen String zurück. Ein String wird in `config.invalid` gespeichert und kann so als Fehlermeldung dienen.\n\n```html\n<ui-component id=\"pin\" name=\"pin\" path=\"login.pin\"></ui-component>\n```\n\n```js\nCOMPONENT('pin', function(self, config) {\n\n\tself.validate = function(value) {\n\t\treturn value && value.length === 4 ? true : 'Enter 4 digits';\n\t};\n\n\tself.state = function() {\n\t\tself.text(config.invalid && config.touched ? config.invalid : 'OK or untouched');\n\t};\n\n});\nON('ready', function() {\n\tvar pin = FIND('pin');\n\n\tpin.touch();\n\tconsole.log(pin.config.touched, pin.config.invalid);\n\n\tSET('login.pin', '1234');\n\tconsole.log(pin.config.invalid);\n\n\tpin.reset();\n\tconsole.log(pin.config.touched);\n});\n```\n\n```text\n1 Enter 4 digits\nfalse\n0\n```\n\n| Methode | Wirkung |\n| --- | --- |\n| `self.touch()` | Markiert die Komponente als berührt und validiert sie |\n| `self.change()` | Markiert die Komponente als berührt und geändert und validiert sie |\n| `self.reset()` | Löscht den Zustand „berührt“ und „geändert“ und validiert die Komponente |\n\nDen aktuellen Zustand liest du in `self.state` aus `config.touched`, `config.modified`, `config.invalid` und `config.disabled`. Die CSS-Klassen `ui-touched`, `ui-modified`, `ui-invalid` und `ui-disabled` pflegt die Bibliothek für dich.\n\n## Styles\n\nDas letzte Argument von `COMPONENT()` enthält das CSS. Das Wort `CLASS` wird durch den Klassennamen der Komponente ersetzt.\n\n```html\n<ui-component name=\"card\"><b>Title</b></ui-component>\n```\n\n```js\nCOMPONENT('card', '', function(self, config, cls) {\n\tself.make = () => self.aclass(cls);\n}, null, '.CLASS { border: 1px solid #ccc; } .CLASS b { color: red; }');\n```\n\nDie Bibliothek fügt der Seite diese Regel hinzu:\n\n```css\n.ui-card { border: 1px solid #ccc; } .ui-card b { color: red; }\n```\n\n## Methoden und Befehle\n\nJede Funktion, die du `self` zuweist, ist eine öffentliche Methode, die andere mit `SETTER()` aufrufen. Ein Befehl ist eine benannte Aktion mit beliebig vielen Handlern, die mit `self.command(name, callback)` registriert und auf einer Instanz mit `self.CMD(name, [a], [b], [c], [d])` ausgeführt wird oder mit dem globalen `CMD(name, [a], [b], [c], [d])` auf jeder Komponente, die ihn hat.\n\n```html\n<ui-component name=\"list\" path=\"data.rows\"></ui-component>\n```\n\n```js\nCOMPONENT('list', function(self) {\n\n\t// A public method\n\tself.clear = function() {\n\t\tself.set([]);\n\t};\n\n\t// A named command, a command name can have several handlers\n\tself.command('highlight', index => console.log('first handler', index));\n\tself.command('highlight', index => console.log('second handler', index));\n\n});\n\nSET('data.rows', [1, 2, 3]);\nON('ready', function() {\n\tSETTER('list/clear');\n\tconsole.log(data.rows);\n\n\tFIND('list').CMD('highlight', 2);\n});\n```\n\n```text\n[]\nfirst handler 2\nsecond handler 2\n```\n\n## Events und Watcher\n\n| Methode | Beschreibung |\n| --- | --- |\n| `self.event(name, [selector], callback)` | Registriert ein DOM-Event am Element |\n| `self.on(name, callback)` | Registriert ein globales Event, das mit `EMIT()` gesendet wird |\n| `self.watch(path, callback, [init])` | Beobachtet einen Path des Modells |\n| `self.watch(callback)` | Beobachtet den Path der Komponente |\n\n```html\n<ui-component name=\"status\" path=\"app.state\"></ui-component>\n```\n\n```js\nCOMPONENT('status', function(self) {\n\n\tself.make = function() {\n\n\t\t// Any path of the model\n\t\tself.watch('app.user', function(value, flags, path) {\n\t\t\tconsole.log('user', value, path);\n\t\t});\n\n\t\t// The path of the component\n\t\tself.watch(value => console.log('own path', value));\n\n\t\t// A global event\n\t\tself.on('logout', reason => console.log('logout', reason));\n\t};\n\n});\nON('ready', function() {\n\tSET('app.user', 'Ana');\n\tSET('app.state', 'online');\n\tEMIT('logout', 'timeout');\n});\n```\n\n```text\nuser Ana app.user\nown path online\nlogout timeout\n```\n\n## Aufräumen\n\nGib Timer und andere Ressourcen in `self.destroy` frei:\n\n```html\n<ui-component name=\"ticker\"></ui-component>\n```\n\n```js\nCOMPONENT('ticker', function(self) {\n\n\tvar timer;\n\n\tself.make = function() {\n\t\ttimer = setInterval(() => self.text(new Date().toISOString()), 1000);\n\t};\n\n\tself.destroy = function() {\n\t\tclearInterval(timer);\n\t\tconsole.log('stopped');\n\t};\n\n});\n```\n\n## Besondere Arten von Komponenten\n\n| Methode | Wirkung |\n| --- | --- |\n| `self.singleton()` | Erlaubt eine Instanz auf der Seite. Die Bibliothek entfernt die Elemente weiterer Instanzen |\n| `self.blind()` | Die Komponente reagiert nicht auf Änderungen im Modell |\n| `self.readonly()` | Die Komponente zeigt nur Inhalt an. Es gibt keinen Setter, keinen Getter und keine Validierung |\n\n```html\n<ui-component name=\"toast\"></ui-component>\n<ui-component name=\"toast\"></ui-component>\n```\n\n```js\nCOMPONENT('toast', function(self) {\n\tself.singleton();\n\tself.make = () => console.log('created once');\n});\n```\n\nDas Delegate `make` läuft einmal, und ein `<ui-component>`-Element bleibt auf der Seite.\n\n```html\n<ui-component name=\"clock\" path=\"app.time\"></ui-component>\n<ui-component name=\"logo\" path=\"app.time\"></ui-component>\n```\n\n```js\nCOMPONENT('clock', function(self) {\n\tself.blind();\n\tself.setter = value => console.log('clock setter', value);\n});\n\nCOMPONENT('logo', function(self) {\n\tself.readonly();\n\tself.make = () => self.text('Logo');\n});\nON('ready', function() {\n\tSET('app.time', 1);\n\tconsole.log(FIND('logo').config.invalid);\n});\n```\n\nNach `SET('app.time', 1)` führt die Komponente `clock` ihren Setter nicht aus, und `logo` bleibt gültig.\n\n## Abhängigkeiten\n\nDas vierte Argument listet auf, was eine Komponente braucht. Ein String ist eine URL, die mit `IMPORT()` geladen wird, und eine Funktion erhält einen Callback `next`. Die Instanz startet, sobald alle Abhängigkeiten bereit sind.\n\n```html\n<ui-component name=\"map\"></ui-component>\n```\n\n```js\nCOMPONENT('map', '', function(self) {\n\tself.make = () => console.log('ready to use', W.mapsdk);\n}, [\n\t'https://example.com/maps.js',\n\tfunction(next) {\n\t\tW.mapsdk = 'loaded';\n\t\tnext();\n\t}\n]);\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcNA1gd61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/creating-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Crear componentes","summary":"Cómo declarar tus propios componentes, gestionar valores y configuración, validar la entrada y limpiar recursos.","markdown":"---\ntitle: Crear componentes\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/creating-components/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# Crear componentes\n\n> Cómo declarar tus propios componentes, gestionar valores y configuración, validar la entrada y limpiar recursos.\n\nUn componente une HTML, comportamiento y un valor del modelo en un único widget reutilizable. Lo declaras una vez con `COMPONENT()` y lo usas en la página como se describe en [Usar componentes](../using-components/).\n\n## Declarar un componente\n\n```js\nCOMPONENT(name, [config], callback, [dependencies], [css]);\n```\n\n| Argumento | Tipo | Descripción |\n| --- | --- | --- |\n| `name` | String | El nombre que se usa en `<ui-component name=\"...\">` |\n| `config` | String | La configuración predeterminada con la forma `key:value;key:value` |\n| `callback` | Function | Se ejecuta para cada instancia con los argumentos `self`, `config` y `cls` |\n| `dependencies` | String o Array | Recursos que se cargan antes de la inicialización. Una cadena puede enumerar varias URL separadas por comas |\n| `css` | String | El CSS del componente |\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\"></ui-component>\n```\n\n```js\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.text('Hello ' + config.name);\n\t};\n});\n```\n\nEl elemento renderizado:\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\" class=\"ui-hello\">Hello Ana</ui-component>\n```\n\nEl callback recibe:\n\n- `self`, la instancia del componente\n- `config`, la configuración combinada de la instancia\n- `cls`, el nombre de la clase CSS del componente con la forma `ui-name`. La biblioteca no la añade al elemento, así que llama a `self.aclass(cls)`\n\nDeclara los componentes mientras se carga la página. Un nombre desconocido cuando se inicializa su elemento se [descarga desde el CDN](../using-components/).\n\n## Ciclo de vida\n\nDefines el comportamiento de un componente asignando a `self` funciones llamadas delegates. La biblioteca las llama en este orden:\n\n```html\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n```\n\n```js\nCOMPONENT('demo', 'color:red', function(self, config) {\n\tconsole.log('declaration');\n\tself.init = () => console.log('init');\n\tself.make = () => console.log('make');\n\tself.configure = (key, value, init) => console.log('configure', key, value, init);\n\tself.setter = (value, path, flags) => console.log('setter', value, path, flags);\n\tself.validate = () => true;\n\tself.state = () => console.log('state');\n\tself.done = () => console.log('done');\n});\n\nSET('app.value', 1);\n```\n\n```text\ndeclaration\ninit\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\ndeclaration\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\n```\n\n| Delegate | Cuándo se ejecuta |\n| --- | --- |\n| `self.init()` | Una vez por tipo de componente, en su primera instancia |\n| `self.make()` | Una vez por cada instancia. Crea aquí el HTML |\n| `self.configure(key, value, init)` | Para cada clave de configuración al arrancar, con `init` a `true`, y en cada cambio posterior |\n| `self.setter(value, path, flags)` | Cuando cambia el valor en el modelo |\n| `self.setter2(value, path, flags)` | Después de `setter`, también para los valores que escribe el propio componente |\n| `self.validate(value)` | Después de cada cambio del valor. Decide si el valor es válido |\n| `self.state()` | Cuando la biblioteca actualiza el estado de tocado, modificado, no válido o desactivado |\n| `self.done()` | Una vez por cada instancia, al final de la inicialización |\n| `self.destroy()` | Cuando se elimina el componente |\n\nLas claves de configuración que mantiene la biblioteca, como `invalid`, también pasan por `configure`.\n\n## Propiedades útiles\n\n| Propiedad | Descripción |\n| --- | --- |\n| `self.element` | El elemento como objeto jQuery |\n| `self.dom` | El elemento DOM |\n| `self.config` | La configuración |\n| `self.path` | El path del componente. Usa `self.path.toString()` para obtener una cadena |\n| `self.name` | El nombre del componente |\n| `self.id` | El identificador de la instancia |\n\nLa lista completa está en la [referencia de Component](../../reference/component/).\n\n## Recibir valores\n\n`self.setter` se ejecuta al arrancar y en cada cambio del valor. El argumento `path` contiene el path que ha cambiado, que puede ser un padre del path del componente. El argumento `flags` contiene los [flags](../flags/) de la operación. La biblioteca añade `init` en la primera llamada y `refresh` en `self.refresh()`.\n\n```html\n<ui-component name=\"badge\" path=\"inbox.count\"></ui-component>\n```\n\n```js\nCOMPONENT('badge', function(self) {\n\n\tself.setter = function(value, path, flags) {\n\t\tself.text(value == null ? 'none' : value + ' new');\n\t\tconsole.log(self.text(), path, flags);\n\t};\n\n});\n\nSET('inbox.count', 3);\nON('ready', function() {\n\tSET('inbox.count', 5);\n\tSET('inbox @reload', { count: 7 });\n\tFIND('badge').refresh();\n});\n```\n\n```text\n3 new inbox.count {\"init\":1}\n5 new inbox.count {}\n7 new inbox {\"reload\":1}\n7 new inbox.count {\"refresh\":1}\n```\n\nUn componente sin `setter` propio escribe el valor en el primer `input`, `select` o `textarea` que haya dentro de su elemento.\n\n## Enviar valores\n\n| Método | Efecto |\n| --- | --- |\n| `self.get()` | Lee el valor del modelo |\n| `self.set(value, [flags])` | Escribe el valor y llama a los setters de todos los componentes del path |\n| `self.modify(value, [flags])` | Marca el componente como tocado y modificado, y después escribe el valor |\n| `self.rewrite(value, [flags])` | Escribe el valor sin llamar al `setter` de este componente |\n\n```html\n<ui-component name=\"stepper\" path=\"cart.quantity\" config=\"step:2\"></ui-component>\n<p>Quantity: <ui-bind path=\"cart.quantity\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('stepper', 'step:1', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<button name=\"minus\">-</button><b></b><button name=\"plus\">+</button>');\n\t\tself.event('click', 'button', function() {\n\t\t\tvar diff = this.name === 'plus' ? config.step : -config.step;\n\t\t\tself.modify((self.get() || 0) + diff);\n\t\t});\n\t};\n\n\tself.setter = function(value) {\n\t\tself.find('b').text(value);\n\t};\n\n});\n\nSET('cart.quantity', 4);\n```\n\nAl hacer clic en `+`, la cantidad pasa de `4` a `6`. El elemento recibe las clases `ui-touched` y `ui-modified`, y el párrafo sigue al modelo.\n\n`self.rewrite()` va bien para los componentes que ya muestran el valor que escriben. Su `setter` se omite, mientras que `setter2` sigue ejecutándose:\n\n```html\n<ui-component name=\"search\" path=\"filter.query\"></ui-component>\n```\n\n```js\nCOMPONENT('search', function(self) {\n\n\tself.setter = value => console.log('setter', value);\n\tself.setter2 = value => console.log('setter2', value);\n\n\tself.write = function(value) {\n\t\tself.rewrite(value);\n\t};\n\n});\nON('ready', function() {\n\tSET('filter.query', 'pen');\n\tFIND('search').write('book');\n\tconsole.log(filter.query);\n});\n```\n\n```text\nsetter pen\nsetter2 pen\nsetter2 book\nbook\n```\n\n## Enlazar campos\n\n`self.autobind20([delay])` conecta con el modelo los elementos `input`, `select` y `textarea` que hay dentro del componente. Escribe el valor mientras el usuario teclea, tras un retardo predeterminado de 200 milisegundos, y marca el componente como tocado y modificado.\n\nEl valor pasa por estos pasos en su camino hacia el modelo:\n\n1. La función registrada con `self.parser()` cambia el valor.\n2. La clave de configuración `type` lo convierte. Los tipos admitidos son `number`, `currency`, `float`, `boolean`, `bool`, `date` y `datetime`.\n\nEn su camino hacia el campo, el setter predeterminado pasa el valor por la función registrada con `self.formatter()`.\n\n```html\n<ui-component name=\"input\" path=\"order.count\" config=\"type:number\"></ui-component>\n<ui-component name=\"input\" path=\"order.code\" config=\"upper:true\"></ui-component>\n```\n\n```js\nCOMPONENT('input', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.parser(function(path, value) {\n\t\treturn config.upper ? value.toUpperCase() : value;\n\t});\n\n\tself.formatter(function(path, value) {\n\t\treturn config.upper && value ? value.toLowerCase() : value;\n\t});\n\n});\n\nSET('order.code', 'ABC');\n```\n\nTras escribir `42` en el primer campo y `xyz` en el segundo, el modelo contiene:\n\n```text\n{\"code\":\"XYZ\",\"count\":42}\n```\n\nEl segundo campo mostraba `abc` al arrancar, porque el formatter convierte el `ABC` guardado para mostrarlo. Para procesar de la misma manera un valor de tu propio widget, llama a `self.getter(value)`.\n\n## Configuración\n\nLee la configuración del objeto `config`. Usa `self.configure` para aplicar los valores y reaccionar a cambios posteriores. `self.reconfigure()` cambia la configuración de un componente en ejecución. Acepta una cadena o un objeto.\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\"></ui-component>\n```\n\n```js\nCOMPONENT('textbox', 'maxlength:10', function(self, config) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t};\n\tself.configure = function(key, value) {\n\t\tif (key === 'maxlength')\n\t\t\tself.find('input').attr(key, value);\n\t};\n});\n\nEXTENSION('textbox', 'maxlength:5', function(self, config) {\n\tself.clear = () => self.set('');\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').config.maxlength);\n\tconsole.log(typeof FIND('textbox').clear);\n\n\tFIND('textbox').reconfigure('maxlength:3');\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n\n\tFIND('textbox').reconfigure({ maxlength: 8 });\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n});\n```\n\n```text\n5\nfunction\n3\n8\n```\n\n`EXTENSION(name, [config], callback)` añade comportamiento a un componente que no has escrito tú. Funciona con las instancias existentes y con las que se creen después. En el ejemplo anterior, cambia el `maxlength` predeterminado y añade el método `clear()`.\n\n## Validación y estado\n\n`self.validate` devuelve `true` para un valor válido. Devuelve `false` o una cadena para uno no válido. La cadena se guarda en `config.invalid`, así que puede servir como mensaje de error.\n\n```html\n<ui-component id=\"pin\" name=\"pin\" path=\"login.pin\"></ui-component>\n```\n\n```js\nCOMPONENT('pin', function(self, config) {\n\n\tself.validate = function(value) {\n\t\treturn value && value.length === 4 ? true : 'Enter 4 digits';\n\t};\n\n\tself.state = function() {\n\t\tself.text(config.invalid && config.touched ? config.invalid : 'OK or untouched');\n\t};\n\n});\nON('ready', function() {\n\tvar pin = FIND('pin');\n\n\tpin.touch();\n\tconsole.log(pin.config.touched, pin.config.invalid);\n\n\tSET('login.pin', '1234');\n\tconsole.log(pin.config.invalid);\n\n\tpin.reset();\n\tconsole.log(pin.config.touched);\n});\n```\n\n```text\n1 Enter 4 digits\nfalse\n0\n```\n\n| Método | Efecto |\n| --- | --- |\n| `self.touch()` | Marca el componente como tocado y lo valida |\n| `self.change()` | Marca el componente como tocado y modificado, y lo valida |\n| `self.reset()` | Borra el estado de tocado y modificado y valida el componente |\n\nLee el estado actual de `config.touched`, `config.modified`, `config.invalid` y `config.disabled` en `self.state`. La biblioteca mantiene por ti las clases CSS `ui-touched`, `ui-modified`, `ui-invalid` y `ui-disabled`.\n\n## Estilos\n\nEl último argumento de `COMPONENT()` contiene el CSS. La palabra `CLASS` se sustituye por el nombre de la clase del componente.\n\n```html\n<ui-component name=\"card\"><b>Title</b></ui-component>\n```\n\n```js\nCOMPONENT('card', '', function(self, config, cls) {\n\tself.make = () => self.aclass(cls);\n}, null, '.CLASS { border: 1px solid #ccc; } .CLASS b { color: red; }');\n```\n\nLa biblioteca añade esta regla a la página:\n\n```css\n.ui-card { border: 1px solid #ccc; } .ui-card b { color: red; }\n```\n\n## Métodos y comandos\n\nCada función que asignas a `self` es un método público, al que otros llaman con `SETTER()`. Un comando es una acción con nombre y cualquier número de manejadores, que se registra con `self.command(name, callback)` y se ejecuta en una instancia con `self.CMD(name, [a], [b], [c], [d])`, o en todos los componentes que lo tienen con la función global `CMD(name, [a], [b], [c], [d])`.\n\n```html\n<ui-component name=\"list\" path=\"data.rows\"></ui-component>\n```\n\n```js\nCOMPONENT('list', function(self) {\n\n\t// A public method\n\tself.clear = function() {\n\t\tself.set([]);\n\t};\n\n\t// A named command, a command name can have several handlers\n\tself.command('highlight', index => console.log('first handler', index));\n\tself.command('highlight', index => console.log('second handler', index));\n\n});\n\nSET('data.rows', [1, 2, 3]);\nON('ready', function() {\n\tSETTER('list/clear');\n\tconsole.log(data.rows);\n\n\tFIND('list').CMD('highlight', 2);\n});\n```\n\n```text\n[]\nfirst handler 2\nsecond handler 2\n```\n\n## Eventos y observadores\n\n| Método | Descripción |\n| --- | --- |\n| `self.event(name, [selector], callback)` | Registra un evento DOM en el elemento |\n| `self.on(name, callback)` | Registra un evento global enviado con `EMIT()` |\n| `self.watch(path, callback, [init])` | Observa un path del modelo |\n| `self.watch(callback)` | Observa el path del componente |\n\n```html\n<ui-component name=\"status\" path=\"app.state\"></ui-component>\n```\n\n```js\nCOMPONENT('status', function(self) {\n\n\tself.make = function() {\n\n\t\t// Any path of the model\n\t\tself.watch('app.user', function(value, flags, path) {\n\t\t\tconsole.log('user', value, path);\n\t\t});\n\n\t\t// The path of the component\n\t\tself.watch(value => console.log('own path', value));\n\n\t\t// A global event\n\t\tself.on('logout', reason => console.log('logout', reason));\n\t};\n\n});\nON('ready', function() {\n\tSET('app.user', 'Ana');\n\tSET('app.state', 'online');\n\tEMIT('logout', 'timeout');\n});\n```\n\n```text\nuser Ana app.user\nown path online\nlogout timeout\n```\n\n## Limpieza\n\nLibera los temporizadores y otros recursos en `self.destroy`:\n\n```html\n<ui-component name=\"ticker\"></ui-component>\n```\n\n```js\nCOMPONENT('ticker', function(self) {\n\n\tvar timer;\n\n\tself.make = function() {\n\t\ttimer = setInterval(() => self.text(new Date().toISOString()), 1000);\n\t};\n\n\tself.destroy = function() {\n\t\tclearInterval(timer);\n\t\tconsole.log('stopped');\n\t};\n\n});\n```\n\n## Tipos especiales de componentes\n\n| Método | Efecto |\n| --- | --- |\n| `self.singleton()` | Permite una sola instancia en la página. La biblioteca elimina los elementos de las demás instancias |\n| `self.blind()` | El componente no reacciona a los cambios del modelo |\n| `self.readonly()` | El componente solo muestra contenido. No tiene setter, getter ni validación |\n\n```html\n<ui-component name=\"toast\"></ui-component>\n<ui-component name=\"toast\"></ui-component>\n```\n\n```js\nCOMPONENT('toast', function(self) {\n\tself.singleton();\n\tself.make = () => console.log('created once');\n});\n```\n\nEl delegate `make` se ejecuta una vez y en la página queda un solo elemento `<ui-component>`.\n\n```html\n<ui-component name=\"clock\" path=\"app.time\"></ui-component>\n<ui-component name=\"logo\" path=\"app.time\"></ui-component>\n```\n\n```js\nCOMPONENT('clock', function(self) {\n\tself.blind();\n\tself.setter = value => console.log('clock setter', value);\n});\n\nCOMPONENT('logo', function(self) {\n\tself.readonly();\n\tself.make = () => self.text('Logo');\n});\nON('ready', function() {\n\tSET('app.time', 1);\n\tconsole.log(FIND('logo').config.invalid);\n});\n```\n\nTras `SET('app.time', 1)`, el componente `clock` no ejecuta su setter y `logo` sigue siendo válido.\n\n## Dependencias\n\nEl cuarto argumento enumera lo que necesita un componente. Una cadena es una URL que se carga con `IMPORT()`, y una función recibe un callback `next`. La instancia arranca cuando todas las dependencias están listas.\n\n```html\n<ui-component name=\"map\"></ui-component>\n```\n\n```js\nCOMPONENT('map', '', function(self) {\n\tself.make = () => console.log('ready to use', W.mapsdk);\n}, [\n\t'https://example.com/maps.js',\n\tfunction(next) {\n\t\tW.mapsdk = 'loaded';\n\t\tnext();\n\t}\n]);\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcNA1gd61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/creating-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Créer des composants","summary":"Comment déclarer tes propres composants, gérer les valeurs et la configuration, valider les saisies et faire le ménage.","markdown":"---\ntitle: \"Créer des composants\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/creating-components/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# Créer des composants\n\n> Comment déclarer tes propres composants, gérer les valeurs et la configuration, valider les saisies et faire le ménage.\n\nUn composant réunit du HTML, un comportement et une valeur du modèle de données en un seul widget réutilisable. Tu le déclares une seule fois avec `COMPONENT()` et tu l'utilises sur la page comme décrit dans [Utiliser les composants](../using-components/).\n\n## Déclarer un composant\n\n```js\nCOMPONENT(name, [config], callback, [dependencies], [css]);\n```\n\n| Argument | Type | Description |\n| --- | --- | --- |\n| `name` | String | Le nom utilisé dans `<ui-component name=\"...\">` |\n| `config` | String | La configuration par défaut sous la forme `key:value;key:value` |\n| `callback` | Function | S'exécute pour chaque instance avec les arguments `self`, `config` et `cls` |\n| `dependencies` | String ou Array | Les ressources à charger avant l'initialisation. Une chaîne peut lister plusieurs URL séparées par des virgules |\n| `css` | String | Le CSS du composant |\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\"></ui-component>\n```\n\n```js\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.text('Hello ' + config.name);\n\t};\n});\n```\n\nL'élément affiché :\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\" class=\"ui-hello\">Hello Ana</ui-component>\n```\n\nLe callback reçoit :\n\n- `self`, l'instance du composant\n- `config`, la configuration fusionnée de l'instance\n- `cls`, le nom de la classe CSS du composant sous la forme `ui-name`. La bibliothèque ne l'ajoute pas à l'élément : appelle donc `self.aclass(cls)`\n\nDéclare les composants pendant le chargement de la page. Un nom inconnu au moment où son élément s'initialise est [téléchargé depuis le CDN](../using-components/).\n\n## Cycle de vie\n\nTu définis le comportement d'un composant en assignant à `self` des fonctions appelées delegates. La bibliothèque les appelle dans cet ordre :\n\n```html\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n```\n\n```js\nCOMPONENT('demo', 'color:red', function(self, config) {\n\tconsole.log('declaration');\n\tself.init = () => console.log('init');\n\tself.make = () => console.log('make');\n\tself.configure = (key, value, init) => console.log('configure', key, value, init);\n\tself.setter = (value, path, flags) => console.log('setter', value, path, flags);\n\tself.validate = () => true;\n\tself.state = () => console.log('state');\n\tself.done = () => console.log('done');\n});\n\nSET('app.value', 1);\n```\n\n```text\ndeclaration\ninit\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\ndeclaration\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\n```\n\n| Delegate | Quand il s'exécute |\n| --- | --- |\n| `self.init()` | Une fois pour le type de composant, lors de sa première instance |\n| `self.make()` | Une fois pour chaque instance. Crée le HTML ici |\n| `self.configure(key, value, init)` | Pour chaque clé de configuration au démarrage, avec `init` à `true`, puis à chaque changement ultérieur |\n| `self.setter(value, path, flags)` | Quand la valeur change dans le modèle de données |\n| `self.setter2(value, path, flags)` | Après `setter`, y compris pour les valeurs écrites par le composant lui-même |\n| `self.validate(value)` | Après chaque changement de la valeur. Il décide si la valeur est valide |\n| `self.state()` | Quand la bibliothèque met à jour l'état touché, modifié, invalide ou désactivé |\n| `self.done()` | Une fois pour chaque instance, à la fin de l'initialisation |\n| `self.destroy()` | Quand le composant est supprimé |\n\nLes clés de configuration gérées par la bibliothèque, comme `invalid`, passent aussi par `configure`.\n\n## Propriétés utiles\n\n| Propriété | Description |\n| --- | --- |\n| `self.element` | L'élément sous forme d'objet jQuery |\n| `self.dom` | L'élément DOM |\n| `self.config` | La configuration |\n| `self.path` | Le path du composant. Utilise `self.path.toString()` pour obtenir une chaîne |\n| `self.name` | Le nom du composant |\n| `self.id` | L'identifiant de l'instance |\n\nLa liste complète se trouve dans la [référence de Component](../../reference/component/).\n\n## Recevoir des valeurs\n\n`self.setter` s'exécute au démarrage et à chaque changement de la valeur. L'argument `path` contient le path qui a été modifié, qui peut être un parent du path du composant. L'argument `flags` contient les [flags](../flags/) de l'opération. La bibliothèque ajoute `init` pour le premier appel et `refresh` pour `self.refresh()`.\n\n```html\n<ui-component name=\"badge\" path=\"inbox.count\"></ui-component>\n```\n\n```js\nCOMPONENT('badge', function(self) {\n\n\tself.setter = function(value, path, flags) {\n\t\tself.text(value == null ? 'none' : value + ' new');\n\t\tconsole.log(self.text(), path, flags);\n\t};\n\n});\n\nSET('inbox.count', 3);\nON('ready', function() {\n\tSET('inbox.count', 5);\n\tSET('inbox @reload', { count: 7 });\n\tFIND('badge').refresh();\n});\n```\n\n```text\n3 new inbox.count {\"init\":1}\n5 new inbox.count {}\n7 new inbox {\"reload\":1}\n7 new inbox.count {\"refresh\":1}\n```\n\nUn composant sans `setter` propre écrit la valeur dans le premier `input`, `select` ou `textarea` de son élément.\n\n## Envoyer des valeurs\n\n| Méthode | Effet |\n| --- | --- |\n| `self.get()` | Lit la valeur dans le modèle de données |\n| `self.set(value, [flags])` | Écrit la valeur et appelle les setters de tous les composants du path |\n| `self.modify(value, [flags])` | Marque le composant comme touché et modifié, puis écrit la valeur |\n| `self.rewrite(value, [flags])` | Écrit la valeur sans appeler le `setter` de ce composant |\n\n```html\n<ui-component name=\"stepper\" path=\"cart.quantity\" config=\"step:2\"></ui-component>\n<p>Quantity: <ui-bind path=\"cart.quantity\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('stepper', 'step:1', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<button name=\"minus\">-</button><b></b><button name=\"plus\">+</button>');\n\t\tself.event('click', 'button', function() {\n\t\t\tvar diff = this.name === 'plus' ? config.step : -config.step;\n\t\t\tself.modify((self.get() || 0) + diff);\n\t\t});\n\t};\n\n\tself.setter = function(value) {\n\t\tself.find('b').text(value);\n\t};\n\n});\n\nSET('cart.quantity', 4);\n```\n\nUn clic sur `+` fait passer la quantité de `4` à `6`. L'élément reçoit les classes `ui-touched` et `ui-modified`, et le paragraphe suit le modèle de données.\n\n`self.rewrite()` convient aux composants qui affichent déjà la valeur qu'ils écrivent. Leur `setter` est ignoré, tandis que `setter2` s'exécute quand même :\n\n```html\n<ui-component name=\"search\" path=\"filter.query\"></ui-component>\n```\n\n```js\nCOMPONENT('search', function(self) {\n\n\tself.setter = value => console.log('setter', value);\n\tself.setter2 = value => console.log('setter2', value);\n\n\tself.write = function(value) {\n\t\tself.rewrite(value);\n\t};\n\n});\nON('ready', function() {\n\tSET('filter.query', 'pen');\n\tFIND('search').write('book');\n\tconsole.log(filter.query);\n});\n```\n\n```text\nsetter pen\nsetter2 pen\nsetter2 book\nbook\n```\n\n## Lier des champs de saisie\n\n`self.autobind20([delay])` relie au modèle de données les éléments `input`, `select` et `textarea` du composant. Il écrit la valeur pendant la saisie, après un délai de 200 millisecondes par défaut, et marque le composant comme touché et modifié.\n\nLa valeur passe par ces étapes sur le chemin du modèle de données :\n\n1. La fonction enregistrée avec `self.parser()` modifie la valeur.\n2. La clé de configuration `type` la convertit. Les types pris en charge sont `number`, `currency`, `float`, `boolean`, `bool`, `date` et `datetime`.\n\nSur le chemin du champ de saisie, le setter par défaut fait passer la valeur par la fonction enregistrée avec `self.formatter()`.\n\n```html\n<ui-component name=\"input\" path=\"order.count\" config=\"type:number\"></ui-component>\n<ui-component name=\"input\" path=\"order.code\" config=\"upper:true\"></ui-component>\n```\n\n```js\nCOMPONENT('input', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.parser(function(path, value) {\n\t\treturn config.upper ? value.toUpperCase() : value;\n\t});\n\n\tself.formatter(function(path, value) {\n\t\treturn config.upper && value ? value.toLowerCase() : value;\n\t});\n\n});\n\nSET('order.code', 'ABC');\n```\n\nAprès la saisie de `42` dans le premier champ et de `xyz` dans le second, le modèle de données contient :\n\n```text\n{\"code\":\"XYZ\",\"count\":42}\n```\n\nLe second champ affichait `abc` au démarrage, car le formateur convertit la valeur stockée `ABC` pour l'affichage. Pour traiter de la même façon une valeur issue de ton propre widget, appelle `self.getter(value)`.\n\n## Configuration\n\nLis la configuration dans l'objet `config`. Utilise `self.configure` pour appliquer les valeurs et réagir aux changements ultérieurs. `self.reconfigure()` modifie la configuration d'un composant en cours d'exécution. Il accepte une chaîne ou un objet.\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\"></ui-component>\n```\n\n```js\nCOMPONENT('textbox', 'maxlength:10', function(self, config) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t};\n\tself.configure = function(key, value) {\n\t\tif (key === 'maxlength')\n\t\t\tself.find('input').attr(key, value);\n\t};\n});\n\nEXTENSION('textbox', 'maxlength:5', function(self, config) {\n\tself.clear = () => self.set('');\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').config.maxlength);\n\tconsole.log(typeof FIND('textbox').clear);\n\n\tFIND('textbox').reconfigure('maxlength:3');\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n\n\tFIND('textbox').reconfigure({ maxlength: 8 });\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n});\n```\n\n```text\n5\nfunction\n3\n8\n```\n\n`EXTENSION(name, [config], callback)` ajoute un comportement à un composant que tu n'as pas écrit. Cela fonctionne pour les instances existantes et pour celles créées plus tard. Dans l'exemple ci-dessus, il change la valeur par défaut de `maxlength` et ajoute la méthode `clear()`.\n\n## Validation et état\n\n`self.validate` renvoie `true` pour une valeur valide. Renvoie `false` ou une chaîne pour une valeur invalide. Une chaîne est stockée dans `config.invalid` et peut donc servir de message d'erreur.\n\n```html\n<ui-component id=\"pin\" name=\"pin\" path=\"login.pin\"></ui-component>\n```\n\n```js\nCOMPONENT('pin', function(self, config) {\n\n\tself.validate = function(value) {\n\t\treturn value && value.length === 4 ? true : 'Enter 4 digits';\n\t};\n\n\tself.state = function() {\n\t\tself.text(config.invalid && config.touched ? config.invalid : 'OK or untouched');\n\t};\n\n});\nON('ready', function() {\n\tvar pin = FIND('pin');\n\n\tpin.touch();\n\tconsole.log(pin.config.touched, pin.config.invalid);\n\n\tSET('login.pin', '1234');\n\tconsole.log(pin.config.invalid);\n\n\tpin.reset();\n\tconsole.log(pin.config.touched);\n});\n```\n\n```text\n1 Enter 4 digits\nfalse\n0\n```\n\n| Méthode | Effet |\n| --- | --- |\n| `self.touch()` | Marque le composant comme touché et le valide |\n| `self.change()` | Marque le composant comme touché et modifié, et le valide |\n| `self.reset()` | Efface l'état touché et modifié et valide le composant |\n\nDans `self.state`, lis l'état actuel dans `config.touched`, `config.modified`, `config.invalid` et `config.disabled`. La bibliothèque gère pour toi les classes CSS `ui-touched`, `ui-modified`, `ui-invalid` et `ui-disabled`.\n\n## Styles\n\nLe dernier argument de `COMPONENT()` contient le CSS. Le mot `CLASS` est remplacé par le nom de classe du composant.\n\n```html\n<ui-component name=\"card\"><b>Title</b></ui-component>\n```\n\n```js\nCOMPONENT('card', '', function(self, config, cls) {\n\tself.make = () => self.aclass(cls);\n}, null, '.CLASS { border: 1px solid #ccc; } .CLASS b { color: red; }');\n```\n\nLa bibliothèque ajoute cette règle à la page :\n\n```css\n.ui-card { border: 1px solid #ccc; } .ui-card b { color: red; }\n```\n\n## Méthodes et commandes\n\nChaque fonction que tu assignes à `self` est une méthode publique, que les autres appellent avec `SETTER()`. Une commande est une action nommée qui peut avoir un nombre quelconque de gestionnaires, enregistrée avec `self.command(name, callback)` et exécutée sur une instance avec `self.CMD(name, [a], [b], [c], [d])`, ou sur tous les composants qui l'ont avec la fonction globale `CMD(name, [a], [b], [c], [d])`.\n\n```html\n<ui-component name=\"list\" path=\"data.rows\"></ui-component>\n```\n\n```js\nCOMPONENT('list', function(self) {\n\n\t// A public method\n\tself.clear = function() {\n\t\tself.set([]);\n\t};\n\n\t// A named command, a command name can have several handlers\n\tself.command('highlight', index => console.log('first handler', index));\n\tself.command('highlight', index => console.log('second handler', index));\n\n});\n\nSET('data.rows', [1, 2, 3]);\nON('ready', function() {\n\tSETTER('list/clear');\n\tconsole.log(data.rows);\n\n\tFIND('list').CMD('highlight', 2);\n});\n```\n\n```text\n[]\nfirst handler 2\nsecond handler 2\n```\n\n## Événements et observateurs\n\n| Méthode | Description |\n| --- | --- |\n| `self.event(name, [selector], callback)` | Enregistre un événement DOM sur l'élément |\n| `self.on(name, callback)` | Enregistre un événement global envoyé avec `EMIT()` |\n| `self.watch(path, callback, [init])` | Observe un path du modèle de données |\n| `self.watch(callback)` | Observe le path du composant |\n\n```html\n<ui-component name=\"status\" path=\"app.state\"></ui-component>\n```\n\n```js\nCOMPONENT('status', function(self) {\n\n\tself.make = function() {\n\n\t\t// Any path of the model\n\t\tself.watch('app.user', function(value, flags, path) {\n\t\t\tconsole.log('user', value, path);\n\t\t});\n\n\t\t// The path of the component\n\t\tself.watch(value => console.log('own path', value));\n\n\t\t// A global event\n\t\tself.on('logout', reason => console.log('logout', reason));\n\t};\n\n});\nON('ready', function() {\n\tSET('app.user', 'Ana');\n\tSET('app.state', 'online');\n\tEMIT('logout', 'timeout');\n});\n```\n\n```text\nuser Ana app.user\nown path online\nlogout timeout\n```\n\n## Faire le ménage\n\nLibère les minuteurs et les autres ressources dans `self.destroy` :\n\n```html\n<ui-component name=\"ticker\"></ui-component>\n```\n\n```js\nCOMPONENT('ticker', function(self) {\n\n\tvar timer;\n\n\tself.make = function() {\n\t\ttimer = setInterval(() => self.text(new Date().toISOString()), 1000);\n\t};\n\n\tself.destroy = function() {\n\t\tclearInterval(timer);\n\t\tconsole.log('stopped');\n\t};\n\n});\n```\n\n## Types particuliers de composants\n\n| Méthode | Effet |\n| --- | --- |\n| `self.singleton()` | Autorise une seule instance sur la page. La bibliothèque supprime les éléments des autres instances |\n| `self.blind()` | Le composant ne réagit pas aux changements du modèle de données |\n| `self.readonly()` | Le composant ne fait qu'afficher du contenu. Il n'a ni setter, ni getter, ni validation |\n\n```html\n<ui-component name=\"toast\"></ui-component>\n<ui-component name=\"toast\"></ui-component>\n```\n\n```js\nCOMPONENT('toast', function(self) {\n\tself.singleton();\n\tself.make = () => console.log('created once');\n});\n```\n\nLe delegate `make` s'exécute une seule fois et un seul élément `<ui-component>` reste sur la page.\n\n```html\n<ui-component name=\"clock\" path=\"app.time\"></ui-component>\n<ui-component name=\"logo\" path=\"app.time\"></ui-component>\n```\n\n```js\nCOMPONENT('clock', function(self) {\n\tself.blind();\n\tself.setter = value => console.log('clock setter', value);\n});\n\nCOMPONENT('logo', function(self) {\n\tself.readonly();\n\tself.make = () => self.text('Logo');\n});\nON('ready', function() {\n\tSET('app.time', 1);\n\tconsole.log(FIND('logo').config.invalid);\n});\n```\n\nAprès `SET('app.time', 1)`, le composant `clock` n'exécute pas son setter et `logo` reste valide.\n\n## Dépendances\n\nLe quatrième argument liste ce dont un composant a besoin. Une chaîne est une URL chargée avec `IMPORT()`, et une fonction reçoit un callback `next`. L'instance démarre quand toutes les dépendances sont prêtes.\n\n```html\n<ui-component name=\"map\"></ui-component>\n```\n\n```js\nCOMPONENT('map', '', function(self) {\n\tself.make = () => console.log('ready to use', W.mapsdk);\n}, [\n\t'https://example.com/maps.js',\n\tfunction(next) {\n\t\tW.mapsdk = 'loaded';\n\t\tnext();\n\t}\n]);\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcNA1gd61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/creating-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Creare componenti","summary":"Come dichiarare i tuoi componenti, gestire valori e configurazione, validare l'input e fare pulizia.","markdown":"---\ntitle: Creare componenti\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/creating-components/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# Creare componenti\n\n> Come dichiarare i tuoi componenti, gestire valori e configurazione, validare l'input e fare pulizia.\n\nUn componente riunisce HTML, comportamento e un valore del modello in un unico widget riutilizzabile. Lo dichiari una sola volta con `COMPONENT()` e lo usi nella pagina come descritto in [Usare i componenti](../using-components/).\n\n## Dichiarare un componente\n\n```js\nCOMPONENT(name, [config], callback, [dependencies], [css]);\n```\n\n| Argomento | Tipo | Descrizione |\n| --- | --- | --- |\n| `name` | String | Il nome usato in `<ui-component name=\"...\">` |\n| `config` | String | La configurazione predefinita nella forma `key:value;key:value` |\n| `callback` | Function | Viene eseguita per ogni istanza con gli argomenti `self`, `config` e `cls` |\n| `dependencies` | String o Array | Le risorse da caricare prima dell'inizializzazione. Una stringa può elencare più URL separati da virgole |\n| `css` | String | Il CSS del componente |\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\"></ui-component>\n```\n\n```js\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.text('Hello ' + config.name);\n\t};\n});\n```\n\nL'elemento visualizzato:\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\" class=\"ui-hello\">Hello Ana</ui-component>\n```\n\nLa callback riceve:\n\n- `self`, l'istanza del componente\n- `config`, la configurazione unificata dell'istanza\n- `cls`, il nome della classe CSS del componente nella forma `ui-name`. La libreria non la aggiunge all'elemento, quindi chiama `self.aclass(cls)`\n\nDichiara i componenti durante il caricamento della pagina. Un nome sconosciuto al momento dell'inizializzazione del suo elemento viene [scaricato dal CDN](../using-components/).\n\n## Ciclo di vita\n\nDefinisci il comportamento di un componente assegnando a `self` delle funzioni, chiamate delegate. La libreria le chiama in questo ordine:\n\n```html\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n```\n\n```js\nCOMPONENT('demo', 'color:red', function(self, config) {\n\tconsole.log('declaration');\n\tself.init = () => console.log('init');\n\tself.make = () => console.log('make');\n\tself.configure = (key, value, init) => console.log('configure', key, value, init);\n\tself.setter = (value, path, flags) => console.log('setter', value, path, flags);\n\tself.validate = () => true;\n\tself.state = () => console.log('state');\n\tself.done = () => console.log('done');\n});\n\nSET('app.value', 1);\n```\n\n```text\ndeclaration\ninit\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\ndeclaration\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\n```\n\n| Delegate | Quando viene eseguito |\n| --- | --- |\n| `self.init()` | Una volta per tipo di componente, alla sua prima istanza |\n| `self.make()` | Una volta per ogni istanza. Crea qui l'HTML |\n| `self.configure(key, value, init)` | Per ogni chiave di configurazione all'avvio, con `init` impostato a `true`, e a ogni modifica successiva |\n| `self.setter(value, path, flags)` | Quando il valore nel modello cambia |\n| `self.setter2(value, path, flags)` | Dopo `setter`, anche per i valori scritti dal componente stesso |\n| `self.validate(value)` | Dopo ogni modifica del valore. Stabilisce se il valore è valido |\n| `self.state()` | Quando la libreria aggiorna lo stato di toccato, modificato, non valido o disabilitato |\n| `self.done()` | Una volta per ogni istanza, al termine dell'inizializzazione |\n| `self.destroy()` | Quando il componente viene rimosso |\n\nAnche le chiavi di configurazione gestite dalla libreria, come `invalid`, passano da `configure`.\n\n## Proprietà utili\n\n| Proprietà | Descrizione |\n| --- | --- |\n| `self.element` | L'elemento come oggetto jQuery |\n| `self.dom` | L'elemento DOM |\n| `self.config` | La configurazione |\n| `self.path` | Il path del componente. Usa `self.path.toString()` per ottenere una stringa |\n| `self.name` | Il nome del componente |\n| `self.id` | L'identificatore dell'istanza |\n\nL'elenco completo si trova nel [riferimento di Component](../../reference/component/).\n\n## Ricevere i valori\n\n`self.setter` viene eseguito all'avvio e a ogni modifica del valore. L'argomento `path` contiene il path modificato, che può essere un genitore del path del componente. L'argomento `flags` contiene i [flag](../flags/) dell'operazione. La libreria aggiunge `init` per la prima chiamata e `refresh` per `self.refresh()`.\n\n```html\n<ui-component name=\"badge\" path=\"inbox.count\"></ui-component>\n```\n\n```js\nCOMPONENT('badge', function(self) {\n\n\tself.setter = function(value, path, flags) {\n\t\tself.text(value == null ? 'none' : value + ' new');\n\t\tconsole.log(self.text(), path, flags);\n\t};\n\n});\n\nSET('inbox.count', 3);\nON('ready', function() {\n\tSET('inbox.count', 5);\n\tSET('inbox @reload', { count: 7 });\n\tFIND('badge').refresh();\n});\n```\n\n```text\n3 new inbox.count {\"init\":1}\n5 new inbox.count {}\n7 new inbox {\"reload\":1}\n7 new inbox.count {\"refresh\":1}\n```\n\nUn componente senza un proprio `setter` scrive il valore nel primo `input`, `select` o `textarea` dentro il suo elemento.\n\n## Inviare i valori\n\n| Metodo | Effetto |\n| --- | --- |\n| `self.get()` | Legge il valore dal modello |\n| `self.set(value, [flags])` | Scrive il valore e chiama i setter di tutti i componenti sul path |\n| `self.modify(value, [flags])` | Segna il componente come toccato e modificato, poi scrive il valore |\n| `self.rewrite(value, [flags])` | Scrive il valore senza chiamare il `setter` di questo componente |\n\n```html\n<ui-component name=\"stepper\" path=\"cart.quantity\" config=\"step:2\"></ui-component>\n<p>Quantity: <ui-bind path=\"cart.quantity\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('stepper', 'step:1', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<button name=\"minus\">-</button><b></b><button name=\"plus\">+</button>');\n\t\tself.event('click', 'button', function() {\n\t\t\tvar diff = this.name === 'plus' ? config.step : -config.step;\n\t\t\tself.modify((self.get() || 0) + diff);\n\t\t});\n\t};\n\n\tself.setter = function(value) {\n\t\tself.find('b').text(value);\n\t};\n\n});\n\nSET('cart.quantity', 4);\n```\n\nUn clic su `+` porta la quantità da `4` a `6`. L'elemento riceve le classi `ui-touched` e `ui-modified` e il paragrafo segue il modello.\n\n`self.rewrite()` è adatto ai componenti che mostrano già il valore che scrivono. Il loro `setter` viene saltato, mentre `setter2` viene comunque eseguito:\n\n```html\n<ui-component name=\"search\" path=\"filter.query\"></ui-component>\n```\n\n```js\nCOMPONENT('search', function(self) {\n\n\tself.setter = value => console.log('setter', value);\n\tself.setter2 = value => console.log('setter2', value);\n\n\tself.write = function(value) {\n\t\tself.rewrite(value);\n\t};\n\n});\nON('ready', function() {\n\tSET('filter.query', 'pen');\n\tFIND('search').write('book');\n\tconsole.log(filter.query);\n});\n```\n\n```text\nsetter pen\nsetter2 pen\nsetter2 book\nbook\n```\n\n## Collegare gli input\n\n`self.autobind20([delay])` collega al modello gli elementi `input`, `select` e `textarea` dentro il componente. Scrive il valore mentre l'utente digita, con un ritardo predefinito di 200 millisecondi, e segna il componente come toccato e modificato.\n\nNel percorso verso il modello, il valore attraversa questi passaggi:\n\n1. La funzione registrata con `self.parser()` modifica il valore.\n2. La chiave di configurazione `type` lo converte. I tipi supportati sono `number`, `currency`, `float`, `boolean`, `bool`, `date` e `datetime`.\n\nNel percorso verso l'input, il setter predefinito fa passare il valore dalla funzione registrata con `self.formatter()`.\n\n```html\n<ui-component name=\"input\" path=\"order.count\" config=\"type:number\"></ui-component>\n<ui-component name=\"input\" path=\"order.code\" config=\"upper:true\"></ui-component>\n```\n\n```js\nCOMPONENT('input', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.parser(function(path, value) {\n\t\treturn config.upper ? value.toUpperCase() : value;\n\t});\n\n\tself.formatter(function(path, value) {\n\t\treturn config.upper && value ? value.toLowerCase() : value;\n\t});\n\n});\n\nSET('order.code', 'ABC');\n```\n\nDopo aver digitato `42` nel primo input e `xyz` nel secondo, il modello contiene:\n\n```text\n{\"code\":\"XYZ\",\"count\":42}\n```\n\nAll'avvio il secondo input mostrava `abc`, perché il formatter converte per la visualizzazione il valore salvato `ABC`. Per elaborare allo stesso modo un valore del tuo widget, chiama `self.getter(value)`.\n\n## Configurazione\n\nLeggi la configurazione dall'oggetto `config`. Usa `self.configure` per applicare i valori e reagire alle modifiche successive. `self.reconfigure()` cambia la configurazione di un componente in esecuzione e accetta una stringa o un oggetto.\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\"></ui-component>\n```\n\n```js\nCOMPONENT('textbox', 'maxlength:10', function(self, config) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t};\n\tself.configure = function(key, value) {\n\t\tif (key === 'maxlength')\n\t\t\tself.find('input').attr(key, value);\n\t};\n});\n\nEXTENSION('textbox', 'maxlength:5', function(self, config) {\n\tself.clear = () => self.set('');\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').config.maxlength);\n\tconsole.log(typeof FIND('textbox').clear);\n\n\tFIND('textbox').reconfigure('maxlength:3');\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n\n\tFIND('textbox').reconfigure({ maxlength: 8 });\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n});\n```\n\n```text\n5\nfunction\n3\n8\n```\n\n`EXTENSION(name, [config], callback)` aggiunge un comportamento a un componente che non hai scritto tu. Funziona per le istanze esistenti e per quelle create in seguito. Nell'esempio precedente, cambia il valore predefinito di `maxlength` e aggiunge il metodo `clear()`.\n\n## Validazione e stato\n\n`self.validate` restituisce `true` per un valore valido. Restituisci `false` o una stringa per un valore non valido. Una stringa viene salvata in `config.invalid`, quindi può servire come messaggio di errore.\n\n```html\n<ui-component id=\"pin\" name=\"pin\" path=\"login.pin\"></ui-component>\n```\n\n```js\nCOMPONENT('pin', function(self, config) {\n\n\tself.validate = function(value) {\n\t\treturn value && value.length === 4 ? true : 'Enter 4 digits';\n\t};\n\n\tself.state = function() {\n\t\tself.text(config.invalid && config.touched ? config.invalid : 'OK or untouched');\n\t};\n\n});\nON('ready', function() {\n\tvar pin = FIND('pin');\n\n\tpin.touch();\n\tconsole.log(pin.config.touched, pin.config.invalid);\n\n\tSET('login.pin', '1234');\n\tconsole.log(pin.config.invalid);\n\n\tpin.reset();\n\tconsole.log(pin.config.touched);\n});\n```\n\n```text\n1 Enter 4 digits\nfalse\n0\n```\n\n| Metodo | Effetto |\n| --- | --- |\n| `self.touch()` | Segna il componente come toccato e lo valida |\n| `self.change()` | Segna il componente come toccato e modificato e lo valida |\n| `self.reset()` | Azzera lo stato di toccato e modificato e valida il componente |\n\nIn `self.state`, leggi lo stato corrente da `config.touched`, `config.modified`, `config.invalid` e `config.disabled`. La libreria gestisce per te le classi CSS `ui-touched`, `ui-modified`, `ui-invalid` e `ui-disabled`.\n\n## Stili\n\nL'ultimo argomento di `COMPONENT()` contiene il CSS. La parola `CLASS` viene sostituita dal nome della classe del componente.\n\n```html\n<ui-component name=\"card\"><b>Title</b></ui-component>\n```\n\n```js\nCOMPONENT('card', '', function(self, config, cls) {\n\tself.make = () => self.aclass(cls);\n}, null, '.CLASS { border: 1px solid #ccc; } .CLASS b { color: red; }');\n```\n\nLa libreria aggiunge questa regola alla pagina:\n\n```css\n.ui-card { border: 1px solid #ccc; } .ui-card b { color: red; }\n```\n\n## Metodi e comandi\n\nOgni funzione che assegni a `self` è un metodo pubblico, che altri possono chiamare con `SETTER()`. Un comando è un'azione con nome e un numero qualsiasi di gestori, registrata con `self.command(name, callback)` ed eseguita su un'istanza con `self.CMD(name, [a], [b], [c], [d])`, oppure su ogni componente che lo possiede con la funzione globale `CMD(name, [a], [b], [c], [d])`.\n\n```html\n<ui-component name=\"list\" path=\"data.rows\"></ui-component>\n```\n\n```js\nCOMPONENT('list', function(self) {\n\n\t// A public method\n\tself.clear = function() {\n\t\tself.set([]);\n\t};\n\n\t// A named command, a command name can have several handlers\n\tself.command('highlight', index => console.log('first handler', index));\n\tself.command('highlight', index => console.log('second handler', index));\n\n});\n\nSET('data.rows', [1, 2, 3]);\nON('ready', function() {\n\tSETTER('list/clear');\n\tconsole.log(data.rows);\n\n\tFIND('list').CMD('highlight', 2);\n});\n```\n\n```text\n[]\nfirst handler 2\nsecond handler 2\n```\n\n## Eventi e osservatori\n\n| Metodo | Descrizione |\n| --- | --- |\n| `self.event(name, [selector], callback)` | Registra un evento DOM sull'elemento |\n| `self.on(name, callback)` | Registra un evento globale inviato con `EMIT()` |\n| `self.watch(path, callback, [init])` | Osserva un path del modello |\n| `self.watch(callback)` | Osserva il path del componente |\n\n```html\n<ui-component name=\"status\" path=\"app.state\"></ui-component>\n```\n\n```js\nCOMPONENT('status', function(self) {\n\n\tself.make = function() {\n\n\t\t// Any path of the model\n\t\tself.watch('app.user', function(value, flags, path) {\n\t\t\tconsole.log('user', value, path);\n\t\t});\n\n\t\t// The path of the component\n\t\tself.watch(value => console.log('own path', value));\n\n\t\t// A global event\n\t\tself.on('logout', reason => console.log('logout', reason));\n\t};\n\n});\nON('ready', function() {\n\tSET('app.user', 'Ana');\n\tSET('app.state', 'online');\n\tEMIT('logout', 'timeout');\n});\n```\n\n```text\nuser Ana app.user\nown path online\nlogout timeout\n```\n\n## Fare pulizia\n\nRilascia i timer e le altre risorse in `self.destroy`:\n\n```html\n<ui-component name=\"ticker\"></ui-component>\n```\n\n```js\nCOMPONENT('ticker', function(self) {\n\n\tvar timer;\n\n\tself.make = function() {\n\t\ttimer = setInterval(() => self.text(new Date().toISOString()), 1000);\n\t};\n\n\tself.destroy = function() {\n\t\tclearInterval(timer);\n\t\tconsole.log('stopped');\n\t};\n\n});\n```\n\n## Tipi speciali di componenti\n\n| Metodo | Effetto |\n| --- | --- |\n| `self.singleton()` | Consente una sola istanza nella pagina. La libreria rimuove gli elementi delle altre istanze |\n| `self.blind()` | Il componente non reagisce alle modifiche del modello |\n| `self.readonly()` | Il componente mostra solo contenuti. Non ha setter, getter né validazione |\n\n```html\n<ui-component name=\"toast\"></ui-component>\n<ui-component name=\"toast\"></ui-component>\n```\n\n```js\nCOMPONENT('toast', function(self) {\n\tself.singleton();\n\tself.make = () => console.log('created once');\n});\n```\n\nIl delegate `make` viene eseguito una sola volta e nella pagina resta un solo elemento `<ui-component>`.\n\n```html\n<ui-component name=\"clock\" path=\"app.time\"></ui-component>\n<ui-component name=\"logo\" path=\"app.time\"></ui-component>\n```\n\n```js\nCOMPONENT('clock', function(self) {\n\tself.blind();\n\tself.setter = value => console.log('clock setter', value);\n});\n\nCOMPONENT('logo', function(self) {\n\tself.readonly();\n\tself.make = () => self.text('Logo');\n});\nON('ready', function() {\n\tSET('app.time', 1);\n\tconsole.log(FIND('logo').config.invalid);\n});\n```\n\nDopo `SET('app.time', 1)`, il componente `clock` non esegue il suo setter e `logo` resta valido.\n\n## Dipendenze\n\nIl quarto argomento elenca ciò di cui un componente ha bisogno. Una stringa è un URL caricato con `IMPORT()`, mentre una funzione riceve una callback `next`. L'istanza si avvia quando tutte le dipendenze sono pronte.\n\n```html\n<ui-component name=\"map\"></ui-component>\n```\n\n```js\nCOMPONENT('map', '', function(self) {\n\tself.make = () => console.log('ready to use', W.mapsdk);\n}, [\n\t'https://example.com/maps.js',\n\tfunction(next) {\n\t\tW.mapsdk = 'loaded';\n\t\tnext();\n\t}\n]);\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcNA1gd61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/creating-components/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Vytváranie komponentov","summary":"Ako deklarovať vlastné komponenty, pracovať s hodnotami a konfiguráciou, validovať vstup a upratať po sebe.","markdown":"---\ntitle: \"Vytváranie komponentov\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/creating-components/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# Vytváranie komponentov\n\n> Ako deklarovať vlastné komponenty, pracovať s hodnotami a konfiguráciou, validovať vstup a upratať po sebe.\n\nKomponent spája HTML, správanie a hodnotu z modelu do jedného opakovane použiteľného widgetu. Raz ho deklaruješ pomocou `COMPONENT()` a na stránke ho používaš tak, ako opisuje časť [Používanie komponentov](../using-components/).\n\n## Deklarácia komponentu\n\n```js\nCOMPONENT(name, [config], callback, [dependencies], [css]);\n```\n\n| Argument | Typ | Popis |\n| --- | --- | --- |\n| `name` | String | Názov použitý v `<ui-component name=\"...\">` |\n| `config` | String | Predvolená konfigurácia v tvare `key:value;key:value` |\n| `callback` | Function | Spustí sa pre každú inštanciu s argumentmi `self`, `config` a `cls` |\n| `dependencies` | String alebo Array | Zdroje, ktoré sa načítajú pred inicializáciou. Reťazec môže obsahovať niekoľko URL oddelených čiarkami |\n| `css` | String | CSS komponentu |\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\"></ui-component>\n```\n\n```js\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.aclass(cls);\n\t\tself.text('Hello ' + config.name);\n\t};\n});\n```\n\nVykreslený element:\n\n```html\n<ui-component name=\"hello\" config=\"name:Ana\" class=\"ui-hello\">Hello Ana</ui-component>\n```\n\nCallback dostane:\n\n- `self`, inštanciu komponentu\n- `config`, zlúčenú konfiguráciu inštancie\n- `cls`, názov CSS triedy komponentu v tvare `ui-name`. Knižnica ju elementu nepridá, preto zavolaj `self.aclass(cls)`\n\nKomponenty deklaruj počas načítavania stránky. Názov, ktorý v čase inicializácie elementu nie je známy, sa [stiahne z CDN](../using-components/).\n\n## Životný cyklus\n\nSprávanie komponentu určíš tak, že do `self` priradíš funkcie, ktoré sa nazývajú delegate. Knižnica ich volá v tomto poradí:\n\n```html\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n<ui-component name=\"demo\" path=\"app.value\"></ui-component>\n```\n\n```js\nCOMPONENT('demo', 'color:red', function(self, config) {\n\tconsole.log('declaration');\n\tself.init = () => console.log('init');\n\tself.make = () => console.log('make');\n\tself.configure = (key, value, init) => console.log('configure', key, value, init);\n\tself.setter = (value, path, flags) => console.log('setter', value, path, flags);\n\tself.validate = () => true;\n\tself.state = () => console.log('state');\n\tself.done = () => console.log('done');\n});\n\nSET('app.value', 1);\n```\n\n```text\ndeclaration\ninit\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\ndeclaration\nmake\nconfigure color red true\nsetter 1 app.value {\"init\":1}\nconfigure invalid false undefined\nstate\ndone\n```\n\n| Delegate | Kedy sa spustí |\n| --- | --- |\n| `self.init()` | Raz pre typ komponentu, pri jeho prvej inštancii |\n| `self.make()` | Raz pre každú inštanciu. Tu vytvor HTML |\n| `self.configure(key, value, init)` | Pre každý konfiguračný kľúč pri štarte, s `init` nastaveným na `true`, a pri každej neskoršej zmene |\n| `self.setter(value, path, flags)` | Keď sa zmení hodnota v modeli |\n| `self.setter2(value, path, flags)` | Po `setter`, aj pre hodnoty, ktoré zapísal samotný komponent |\n| `self.validate(value)` | Po každej zmene hodnoty. Rozhoduje, či je hodnota platná |\n| `self.state()` | Keď knižnica aktualizuje stav dotknutia, úpravy, neplatnosti alebo vypnutia |\n| `self.done()` | Raz pre každú inštanciu, na konci inicializácie |\n| `self.destroy()` | Keď sa komponent odstráni |\n\nCez `configure` prechádzajú aj konfiguračné kľúče, ktoré spravuje knižnica, napríklad `invalid`.\n\n## Užitočné vlastnosti\n\n| Vlastnosť | Popis |\n| --- | --- |\n| `self.element` | Element ako objekt jQuery |\n| `self.dom` | DOM element |\n| `self.config` | Konfigurácia |\n| `self.path` | Path komponentu. Reťazec získaš cez `self.path.toString()` |\n| `self.name` | Názov komponentu |\n| `self.id` | Identifikátor inštancie |\n\nÚplný zoznam nájdeš v [referencii komponentu](../../reference/component/).\n\n## Prijímanie hodnôt\n\n`self.setter` sa spustí pri štarte a pri každej zmene hodnoty. Argument `path` obsahuje path, ktorá sa zmenila, a môže to byť aj nadradená path komponentu. Argument `flags` obsahuje [flagy](../flags/) operácie. Knižnica pridáva `init` pri prvom volaní a `refresh` pri `self.refresh()`.\n\n```html\n<ui-component name=\"badge\" path=\"inbox.count\"></ui-component>\n```\n\n```js\nCOMPONENT('badge', function(self) {\n\n\tself.setter = function(value, path, flags) {\n\t\tself.text(value == null ? 'none' : value + ' new');\n\t\tconsole.log(self.text(), path, flags);\n\t};\n\n});\n\nSET('inbox.count', 3);\nON('ready', function() {\n\tSET('inbox.count', 5);\n\tSET('inbox @reload', { count: 7 });\n\tFIND('badge').refresh();\n});\n```\n\n```text\n3 new inbox.count {\"init\":1}\n5 new inbox.count {}\n7 new inbox {\"reload\":1}\n7 new inbox.count {\"refresh\":1}\n```\n\nKomponent bez vlastného `setter` zapíše hodnotu do prvého prvku `input`, `select` alebo `textarea` vo svojom elemente.\n\n## Odosielanie hodnôt\n\n| Metóda | Účinok |\n| --- | --- |\n| `self.get()` | Prečíta hodnotu z modelu |\n| `self.set(value, [flags])` | Zapíše hodnotu a zavolá settery všetkých komponentov na path |\n| `self.modify(value, [flags])` | Označí komponent ako dotknutý a upravený a potom zapíše hodnotu |\n| `self.rewrite(value, [flags])` | Zapíše hodnotu bez zavolania `setter` tohto komponentu |\n\n```html\n<ui-component name=\"stepper\" path=\"cart.quantity\" config=\"step:2\"></ui-component>\n<p>Quantity: <ui-bind path=\"cart.quantity\" config=\"text\"></ui-bind></p>\n```\n\n```js\nCOMPONENT('stepper', 'step:1', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<button name=\"minus\">-</button><b></b><button name=\"plus\">+</button>');\n\t\tself.event('click', 'button', function() {\n\t\t\tvar diff = this.name === 'plus' ? config.step : -config.step;\n\t\t\tself.modify((self.get() || 0) + diff);\n\t\t});\n\t};\n\n\tself.setter = function(value) {\n\t\tself.find('b').text(value);\n\t};\n\n});\n\nSET('cart.quantity', 4);\n```\n\nKliknutie na `+` zmení množstvo zo `4` na `6`. Element dostane triedy `ui-touched` a `ui-modified` a odsek sa prispôsobí modelu.\n\n`self.rewrite()` sa hodí pre komponenty, ktoré hodnotu, ktorú zapisujú, už zobrazujú. Ich `setter` sa preskočí, no `setter2` sa stále spustí:\n\n```html\n<ui-component name=\"search\" path=\"filter.query\"></ui-component>\n```\n\n```js\nCOMPONENT('search', function(self) {\n\n\tself.setter = value => console.log('setter', value);\n\tself.setter2 = value => console.log('setter2', value);\n\n\tself.write = function(value) {\n\t\tself.rewrite(value);\n\t};\n\n});\nON('ready', function() {\n\tSET('filter.query', 'pen');\n\tFIND('search').write('book');\n\tconsole.log(filter.query);\n});\n```\n\n```text\nsetter pen\nsetter2 pen\nsetter2 book\nbook\n```\n\n## Prepojenie vstupných polí\n\n`self.autobind20([delay])` prepojí elementy `input`, `select` a `textarea` vo vnútri komponentu s modelom. Hodnotu zapisuje počas písania, predvolene s oneskorením 200 milisekúnd, a komponent označí ako dotknutý a upravený.\n\nHodnota prechádza na ceste do modelu týmito krokmi:\n\n1. Funkcia zaregistrovaná cez `self.parser()` hodnotu upraví.\n2. Konfiguračný kľúč `type` ju prevedie. Podporované typy sú `number`, `currency`, `float`, `boolean`, `bool`, `date` a `datetime`.\n\nNa ceste do vstupného poľa predvolený setter odovzdá hodnotu funkcii zaregistrovanej cez `self.formatter()`.\n\n```html\n<ui-component name=\"input\" path=\"order.count\" config=\"type:number\"></ui-component>\n<ui-component name=\"input\" path=\"order.code\" config=\"upper:true\"></ui-component>\n```\n\n```js\nCOMPONENT('input', function(self, config) {\n\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t\tself.autobind20();\n\t};\n\n\tself.parser(function(path, value) {\n\t\treturn config.upper ? value.toUpperCase() : value;\n\t});\n\n\tself.formatter(function(path, value) {\n\t\treturn config.upper && value ? value.toLowerCase() : value;\n\t});\n\n});\n\nSET('order.code', 'ABC');\n```\n\nPo napísaní `42` do prvého poľa a `xyz` do druhého obsahuje model:\n\n```text\n{\"code\":\"XYZ\",\"count\":42}\n```\n\nDruhé pole pri štarte zobrazilo `abc`, pretože formátovač prevádza uložené `ABC` na zobrazenie. Ak chceš rovnako spracovať hodnotu zo svojho vlastného widgetu, zavolaj `self.getter(value)`.\n\n## Konfigurácia\n\nKonfiguráciu čítaj z objektu `config`. Pomocou `self.configure` hodnoty použiješ a zareaguješ na neskoršie zmeny. `self.reconfigure()` mení konfiguráciu bežiaceho komponentu. Prijíma reťazec alebo objekt.\n\n```html\n<ui-component name=\"textbox\" path=\"form.name\"></ui-component>\n```\n\n```js\nCOMPONENT('textbox', 'maxlength:10', function(self, config) {\n\tself.make = function() {\n\t\tself.html('<input type=\"text\" />');\n\t};\n\tself.configure = function(key, value) {\n\t\tif (key === 'maxlength')\n\t\t\tself.find('input').attr(key, value);\n\t};\n});\n\nEXTENSION('textbox', 'maxlength:5', function(self, config) {\n\tself.clear = () => self.set('');\n});\nON('ready', function() {\n\tconsole.log(FIND('textbox').config.maxlength);\n\tconsole.log(typeof FIND('textbox').clear);\n\n\tFIND('textbox').reconfigure('maxlength:3');\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n\n\tFIND('textbox').reconfigure({ maxlength: 8 });\n\tconsole.log(FIND('textbox').find('input').attr('maxlength'));\n});\n```\n\n```text\n5\nfunction\n3\n8\n```\n\n`EXTENSION(name, [config], callback)` pridá správanie komponentu, ktorý si nenapísal. Funguje pre existujúce inštancie aj pre tie, ktoré vzniknú neskôr. V príklade vyššie mení predvolený `maxlength` a pridáva metódu `clear()`.\n\n## Validácia a stav\n\n`self.validate` vráti pre platnú hodnotu `true`. Pre neplatnú vráť `false` alebo reťazec. Reťazec sa uloží do `config.invalid`, takže môže slúžiť ako chybová správa.\n\n```html\n<ui-component id=\"pin\" name=\"pin\" path=\"login.pin\"></ui-component>\n```\n\n```js\nCOMPONENT('pin', function(self, config) {\n\n\tself.validate = function(value) {\n\t\treturn value && value.length === 4 ? true : 'Enter 4 digits';\n\t};\n\n\tself.state = function() {\n\t\tself.text(config.invalid && config.touched ? config.invalid : 'OK or untouched');\n\t};\n\n});\nON('ready', function() {\n\tvar pin = FIND('pin');\n\n\tpin.touch();\n\tconsole.log(pin.config.touched, pin.config.invalid);\n\n\tSET('login.pin', '1234');\n\tconsole.log(pin.config.invalid);\n\n\tpin.reset();\n\tconsole.log(pin.config.touched);\n});\n```\n\n```text\n1 Enter 4 digits\nfalse\n0\n```\n\n| Metóda | Účinok |\n| --- | --- |\n| `self.touch()` | Označí komponent ako dotknutý a zvaliduje ho |\n| `self.change()` | Označí komponent ako dotknutý a upravený a zvaliduje ho |\n| `self.reset()` | Vymaže stav dotknutia a úpravy a zvaliduje komponent |\n\nAktuálny stav v `self.state` prečítaš z `config.touched`, `config.modified`, `config.invalid` a `config.disabled`. CSS triedy `ui-touched`, `ui-modified`, `ui-invalid` a `ui-disabled` spravuje knižnica za teba.\n\n## Štýly\n\nPosledný argument `COMPONENT()` obsahuje CSS. Slovo `CLASS` sa nahradí názvom triedy komponentu.\n\n```html\n<ui-component name=\"card\"><b>Title</b></ui-component>\n```\n\n```js\nCOMPONENT('card', '', function(self, config, cls) {\n\tself.make = () => self.aclass(cls);\n}, null, '.CLASS { border: 1px solid #ccc; } .CLASS b { color: red; }');\n```\n\nKnižnica pridá na stránku toto pravidlo:\n\n```css\n.ui-card { border: 1px solid #ccc; } .ui-card b { color: red; }\n```\n\n## Metódy a príkazy\n\nKaždá funkcia, ktorú priradíš do `self`, je verejná metóda, ktorú môžu ostatní volať cez `SETTER()`. Príkaz je pomenovaná akcia s ľubovoľným počtom obslužných funkcií. Registruješ ho cez `self.command(name, callback)` a vykonáš ho na inštancii cez `self.CMD(name, [a], [b], [c], [d])` alebo na každom komponente, ktorý ho má, cez globálne `CMD(name, [a], [b], [c], [d])`.\n\n```html\n<ui-component name=\"list\" path=\"data.rows\"></ui-component>\n```\n\n```js\nCOMPONENT('list', function(self) {\n\n\t// A public method\n\tself.clear = function() {\n\t\tself.set([]);\n\t};\n\n\t// A named command, a command name can have several handlers\n\tself.command('highlight', index => console.log('first handler', index));\n\tself.command('highlight', index => console.log('second handler', index));\n\n});\n\nSET('data.rows', [1, 2, 3]);\nON('ready', function() {\n\tSETTER('list/clear');\n\tconsole.log(data.rows);\n\n\tFIND('list').CMD('highlight', 2);\n});\n```\n\n```text\n[]\nfirst handler 2\nsecond handler 2\n```\n\n## Udalosti a sledovače\n\n| Metóda | Popis |\n| --- | --- |\n| `self.event(name, [selector], callback)` | Zaregistruje DOM udalosť na elemente |\n| `self.on(name, callback)` | Zaregistruje globálnu udalosť odoslanú cez `EMIT()` |\n| `self.watch(path, callback, [init])` | Sleduje path modelu |\n| `self.watch(callback)` | Sleduje path komponentu |\n\n```html\n<ui-component name=\"status\" path=\"app.state\"></ui-component>\n```\n\n```js\nCOMPONENT('status', function(self) {\n\n\tself.make = function() {\n\n\t\t// Any path of the model\n\t\tself.watch('app.user', function(value, flags, path) {\n\t\t\tconsole.log('user', value, path);\n\t\t});\n\n\t\t// The path of the component\n\t\tself.watch(value => console.log('own path', value));\n\n\t\t// A global event\n\t\tself.on('logout', reason => console.log('logout', reason));\n\t};\n\n});\nON('ready', function() {\n\tSET('app.user', 'Ana');\n\tSET('app.state', 'online');\n\tEMIT('logout', 'timeout');\n});\n```\n\n```text\nuser Ana app.user\nown path online\nlogout timeout\n```\n\n## Upratovanie\n\nČasovače a ďalšie zdroje uvoľni v `self.destroy`:\n\n```html\n<ui-component name=\"ticker\"></ui-component>\n```\n\n```js\nCOMPONENT('ticker', function(self) {\n\n\tvar timer;\n\n\tself.make = function() {\n\t\ttimer = setInterval(() => self.text(new Date().toISOString()), 1000);\n\t};\n\n\tself.destroy = function() {\n\t\tclearInterval(timer);\n\t\tconsole.log('stopped');\n\t};\n\n});\n```\n\n## Špeciálne druhy komponentov\n\n| Metóda | Účinok |\n| --- | --- |\n| `self.singleton()` | Povolí na stránke jednu inštanciu. Knižnica odstráni elementy ostatných inštancií |\n| `self.blind()` | Komponent nereaguje na zmeny v modeli |\n| `self.readonly()` | Komponent iba zobrazuje obsah. Nemá setter, getter ani validáciu |\n\n```html\n<ui-component name=\"toast\"></ui-component>\n<ui-component name=\"toast\"></ui-component>\n```\n\n```js\nCOMPONENT('toast', function(self) {\n\tself.singleton();\n\tself.make = () => console.log('created once');\n});\n```\n\nDelegate `make` sa spustí raz a na stránke zostane jeden element `<ui-component>`.\n\n```html\n<ui-component name=\"clock\" path=\"app.time\"></ui-component>\n<ui-component name=\"logo\" path=\"app.time\"></ui-component>\n```\n\n```js\nCOMPONENT('clock', function(self) {\n\tself.blind();\n\tself.setter = value => console.log('clock setter', value);\n});\n\nCOMPONENT('logo', function(self) {\n\tself.readonly();\n\tself.make = () => self.text('Logo');\n});\nON('ready', function() {\n\tSET('app.time', 1);\n\tconsole.log(FIND('logo').config.invalid);\n});\n```\n\nPo `SET('app.time', 1)` komponent `clock` nespustí svoj setter a `logo` zostane platný.\n\n## Závislosti\n\nŠtvrtý argument uvádza, čo komponent potrebuje. Reťazec je URL načítaná cez `IMPORT()` a funkcia dostane callback `next`. Inštancia sa spustí, keď sú všetky závislosti pripravené.\n\n```html\n<ui-component name=\"map\"></ui-component>\n```\n\n```js\nCOMPONENT('map', '', function(self) {\n\tself.make = () => console.log('ready to use', W.mapsdk);\n}, [\n\t'https://example.com/maps.js',\n\tfunction(next) {\n\t\tW.mapsdk = 'loaded';\n\t\tnext();\n\t}\n]);\n```\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcNe1yd61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/plugins/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Plugins","summary":"How to group the data, the logic and the markup of one part of an application into a plugin.","markdown":"---\ntitle: Plugins\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/plugins/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Plugins\n\n> How to group the data, the logic and the markup of one part of an application into a plugin.\n\nA plugin holds one part of an application: a page, a form, a dialog. It owns a piece of the data model, keeps the logic that works with it, and gives the markup inside its element short relative paths. A plugin has two parts: a declaration made with `PLUGIN()` and a `<ui-plugin>` element that creates an instance of it.\n\n## Declaring a plugin\n\n`PLUGIN(name, [config], callback, [dependencies])` registers a declaration. The `path` attribute of `<ui-plugin>` selects the declaration and sets where the plugin keeps its data.\n\n```html\n<ui-plugin path=\"counter\" config=\"step:2\">\n  <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n  <button class=\"exec\" data-exec=\"?/plus\">Add</button>\n</ui-plugin>\n\n<script>\nPLUGIN('counter', 'step:1;label:Clicks', function(exports, config) {\n\n  exports.make = function() {\n    exports.set('count', 0);\n    console.log(exports.name, config.step, config.label);\n  };\n\n  exports.plus = function() {\n    exports.inc('count', config.step);\n  };\n\n});\n</script>\n```\n\nThe console prints `counter 2 Clicks`, and two clicks on the button leave `4` in `counter.count`.\n\nThe callback receives three arguments:\n\n| Argument | Description |\n| --- | --- |\n| `exports` | The plugin instance. It is also the value of `this`. |\n| `config` | The merged configuration. |\n| `cls` | The value of the `path` attribute of the element. |\n\nThe instance exposes `name`, `path`, `element`, `dom` and `config`. All its methods are listed in the [Plugin](../../reference/plugin/) reference.\n\n## Working with the plugin data\n\nInside the markup of a plugin, `?` stands for the plugin path. `?.count` in the plugin `counter` is the global path `counter.count`. Read more about paths in [Paths](../paths/).\n\nIn the code, the methods of `exports` take a path relative to the plugin:\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.make = function() {\n    exports.set('title', 'My cart');\n    exports.push('items', 'Apple');\n    exports.push('items', ['Pear', 'Plum']);\n    exports.inc('count', 3);\n    exports.toggle('open');\n    exports.nul('title');\n    console.log(JSON.stringify(exports.model));\n    console.log(exports.get('items.length'));\n  };\n});\n```\n\n```text\n{\"title\":null,\"items\":[\"Apple\",\"Pear\",\"Plum\"],\"count\":3,\"open\":true}\n3\n```\n\n`exports.model` reads or replaces the whole plugin data, and `exports.data` is the same value. Every write notifies the components, bindings and watchers on that path. `exports.upd(path)` sends the notification without changing the value.\n\n## Methods\n\nEach function assigned to `exports` is a method that other code can call:\n\n| Where | How to call it |\n| --- | --- |\n| Any script | `EXEC('inbox/clear')` |\n| Markup inside the plugin | `<button class=\"exec\" data-exec=\"?/clear\">` |\n| The plugin itself | `exports.exec('clear')` |\n\nA click on an element with the class `exec` calls the method with the element and the event as arguments. Every instance is also available as `PLUGINS.name`.\n\n## Watching data and listening to events\n\n`exports.watch(path, callback, [autoinit])` reacts to changes under the plugin path. `exports.on(name, callback)` listens to a global event sent with `EMIT()`.\n\n```js\nPLUGIN('inbox', function(exports) {\n\n  exports.watch('unread', function(value, flags, path) {\n    console.log('watch', path, value);\n  });\n\n  exports.on('message', function(text) {\n    exports.inc('unread');\n    console.log('event', text);\n  });\n\n  exports.clear = function() {\n    exports.set('unread', 0);\n  };\n});\n\nEMIT('message', 'Hello');\nEXEC('inbox/clear');\nSET('inbox.unread', 5);\n```\n\n```text\nwatch inbox.unread 1\nevent Hello\nwatch inbox.unread 0\nwatch inbox.unread 5\n```\n\nCall `EMIT()` and `EXEC()` once the plugin exists, for example in `ON('ready', callback)`.\n\n## Configuration\n\nThe configuration of the element overrides the configuration of the declaration. Three keys have a special meaning:\n\n| Key | Description |\n| --- | --- |\n| `init` | The name of a function to call with the plugin element when the plugin starts. |\n| `class` | CSS classes to toggle on the element shortly after the plugin starts. |\n| `aclass` | When truthy, adds the plugin name to the element as a CSS class. |\n\n```html\n<ui-plugin path=\"panel\" config=\"color:red;init:FUNC.panelready;class:loaded;aclass:1\"></ui-plugin>\n\n<script>\nFUNC.panelready = function(element) {\n  console.log('init', element.prop('tagName'));\n};\n\nPLUGIN('panel', 'color:blue;size:10', function(exports, config, cls) {\n  console.log(config.color, config.size, cls);\n});\n</script>\n```\n\n```text\nred 10 panel\ninit UI-PLUGIN\n```\n\nThe element ends up with the classes `panel loaded`.\n\n## Lifecycle\n\n1. The callback of `PLUGIN()` runs. Assign methods and register watchers here.\n2. `exports.make()` runs, if defined, when the instance is ready.\n3. `exports.destroy()` runs, if defined, when the plugin is removed.\n\nThe library looks for removed elements once per minute. `FREE()` runs that clean-up at once:\n\n```js\nPLUGIN('chart', function(exports) {\n  exports.destroy = function() {\n    console.log('destroy');\n  };\n});\n\n$('#area').empty();\nconsole.log(typeof PLUGINS.chart); // object\nFREE();                            // destroy\nconsole.log(typeof PLUGINS.chart); // undefined\n```\n\n## One declaration, several instances\n\nWhen the `path` attribute has two words, the first is the path of the instance and the second is the name of the declaration. Use `?` as the first word to get a generated path.\n\n```html\n<ui-plugin path=\"left timer\"></ui-plugin>\n<ui-plugin path=\"right timer\"></ui-plugin>\n<ui-plugin path=\"? timer\"></ui-plugin>\n\n<script>\nPLUGIN('timer', function(exports) {\n  exports.make = function() {\n    exports.set('value', exports.name.length);\n  };\n});\n</script>\n```\n\n`left.value` is `4` and `right.value` is `5`. Each instance keeps its own data. The third instance has a unique path that starts with `jComponent.data.`.\n\n## The common plugin\n\nThe name `*` is a shortcut for the plugin `common`, a convenient place for what the whole application shares:\n\n```html\n<ui-plugin path=\"*\"></ui-plugin>\n\n<script>\nPLUGIN('*', function(exports) {\n  exports.hello = function() {\n    console.log('hello from', exports.name);\n  };\n});\n\nEXEC('common/hello'); // hello from common\n</script>\n```\n\n## Nested plugins\n\nA plugin can live inside another plugin. `?` in its `path` is replaced by the path of the parent, `?1` in its markup points one plugin up, and `exports.parent` returns the parent instance.\n\n```html\n<ui-plugin path=\"order\">\n  <ui-plugin path=\"?.customer\">\n    <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n    /\n    <ui-bind path=\"?1.number\" config=\"text\"></ui-bind>\n  </ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('order', function(exports) {\n  exports.set('number', 'A-100');\n});\n\nPLUGIN('order.customer', function(exports) {\n  exports.make = function() {\n    exports.set('name', 'Ann');\n    console.log(exports.name, exports.parent.name); // order.customer order\n  };\n});\n</script>\n```\n\nThe inner plugin renders `Ann / A-100`, and the data is `{\"number\":\"A-100\",\"customer\":{\"name\":\"Ann\"}}`.\n\n## Loading data from a server\n\n`exports.ajax(url, [data], [callback])` sends a request. When the last argument is a string, the response is written to that path of the plugin:\n\n```js\nPLUGIN('products', function(exports) {\n  exports.make = function() {\n\n    // Writes the response to \"products.items\"\n    exports.ajax('GET /api/products/', 'items');\n\n    exports.ajax('GET /api/products/', function(response) {\n      console.log(response.length);\n    });\n  };\n});\n```\n\n## Dependencies\n\nThe last argument of `PLUGIN()` lists what must be ready before the plugin starts. It is a comma-separated string of URLs or an array of URLs and functions. A function receives a `next` callback.\n\n```js\nvar loadmaps = function(next) {\n  window.MAPS = { ready: true };\n  next();\n};\n\nPLUGIN('map', function(exports) {\n  console.log(window.MAPS.ready); // true\n}, ['/js/geo.js', loadmaps]);\n```\n\nURLs are loaded with `IMPORT()`. To load a whole plugin from a file, see [Importing content](../importing/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNe1yd61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/plugins/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Plugins","summary":"Wie du die Daten, die Logik und das Markup eines Anwendungsteils in einem Plugin bündelst.","markdown":"---\ntitle: Plugins\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/plugins/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Plugins\n\n> Wie du die Daten, die Logik und das Markup eines Anwendungsteils in einem Plugin bündelst.\n\nEin Plugin enthält einen Teil einer Anwendung: eine Seite, ein Formular, einen Dialog. Es besitzt einen Ausschnitt des Datenmodells, enthält die Logik, die damit arbeitet, und gibt dem Markup in seinem Element kurze relative Paths. Ein Plugin besteht aus zwei Teilen: einer mit `PLUGIN()` erstellten Deklaration und einem `<ui-plugin>`-Element, das eine Instanz davon erzeugt.\n\n## Ein Plugin deklarieren\n\n`PLUGIN(name, [config], callback, [dependencies])` registriert eine Deklaration. Das Attribut `path` von `<ui-plugin>` wählt die Deklaration aus und legt fest, wo das Plugin seine Daten speichert.\n\n```html\n<ui-plugin path=\"counter\" config=\"step:2\">\n  <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n  <button class=\"exec\" data-exec=\"?/plus\">Add</button>\n</ui-plugin>\n\n<script>\nPLUGIN('counter', 'step:1;label:Clicks', function(exports, config) {\n\n  exports.make = function() {\n    exports.set('count', 0);\n    console.log(exports.name, config.step, config.label);\n  };\n\n  exports.plus = function() {\n    exports.inc('count', config.step);\n  };\n\n});\n</script>\n```\n\nDie Konsole gibt `counter 2 Clicks` aus, und nach zwei Klicks auf den Button steht `4` in `counter.count`.\n\nDer Callback erhält drei Argumente:\n\n| Argument | Beschreibung |\n| --- | --- |\n| `exports` | Die Plugin-Instanz. Das ist auch der Wert von `this`. |\n| `config` | Die zusammengeführte Konfiguration. |\n| `cls` | Der Wert des Attributs `path` des Elements. |\n\nDie Instanz stellt `name`, `path`, `element`, `dom` und `config` bereit. Alle Methoden findest du in der Referenz zu [Plugin](../../reference/plugin/).\n\n## Mit den Plugin-Daten arbeiten\n\nIm Markup eines Plugins steht `?` für den Path des Plugins. `?.count` im Plugin `counter` ist der globale Path `counter.count`. Mehr über Paths erfährst du unter [Paths](../paths/).\n\nIm Code nehmen die Methoden von `exports` einen Path relativ zum Plugin entgegen:\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.make = function() {\n    exports.set('title', 'My cart');\n    exports.push('items', 'Apple');\n    exports.push('items', ['Pear', 'Plum']);\n    exports.inc('count', 3);\n    exports.toggle('open');\n    exports.nul('title');\n    console.log(JSON.stringify(exports.model));\n    console.log(exports.get('items.length'));\n  };\n});\n```\n\n```text\n{\"title\":null,\"items\":[\"Apple\",\"Pear\",\"Plum\"],\"count\":3,\"open\":true}\n3\n```\n\n`exports.model` liest oder ersetzt alle Plugin-Daten, und `exports.data` ist derselbe Wert. Jeder Schreibvorgang benachrichtigt die Komponenten, Bindungen und Watcher auf diesem Path. `exports.upd(path)` sendet die Benachrichtigung, ohne den Wert zu ändern.\n\n## Methoden\n\nJede Funktion, die du `exports` zuweist, ist eine Methode, die anderer Code aufrufen kann:\n\n| Wo | Wie du sie aufrufst |\n| --- | --- |\n| Beliebiges Skript | `EXEC('inbox/clear')` |\n| Markup im Plugin | `<button class=\"exec\" data-exec=\"?/clear\">` |\n| Das Plugin selbst | `exports.exec('clear')` |\n\nEin Klick auf ein Element mit der Klasse `exec` ruft die Methode mit dem Element und dem Event als Argumenten auf. Jede Instanz ist außerdem als `PLUGINS.name` verfügbar.\n\n## Daten beobachten und auf Events hören\n\n`exports.watch(path, callback, [autoinit])` reagiert auf Änderungen unterhalb des Plugin-Paths. `exports.on(name, callback)` hört auf ein globales Event, das mit `EMIT()` gesendet wird.\n\n```js\nPLUGIN('inbox', function(exports) {\n\n  exports.watch('unread', function(value, flags, path) {\n    console.log('watch', path, value);\n  });\n\n  exports.on('message', function(text) {\n    exports.inc('unread');\n    console.log('event', text);\n  });\n\n  exports.clear = function() {\n    exports.set('unread', 0);\n  };\n});\n\nEMIT('message', 'Hello');\nEXEC('inbox/clear');\nSET('inbox.unread', 5);\n```\n\n```text\nwatch inbox.unread 1\nevent Hello\nwatch inbox.unread 0\nwatch inbox.unread 5\n```\n\nRufe `EMIT()` und `EXEC()` auf, sobald das Plugin existiert, zum Beispiel in `ON('ready', callback)`.\n\n## Konfiguration\n\nDie Konfiguration des Elements überschreibt die Konfiguration der Deklaration. Drei Schlüssel haben eine besondere Bedeutung:\n\n| Schlüssel | Beschreibung |\n| --- | --- |\n| `init` | Der Name einer Funktion, die beim Start des Plugins mit dem Plugin-Element aufgerufen wird. |\n| `class` | CSS-Klassen, die kurz nach dem Start des Plugins am Element umgeschaltet werden. |\n| `aclass` | Fügt dem Element bei einem truthy Wert den Plugin-Namen als CSS-Klasse hinzu. |\n\n```html\n<ui-plugin path=\"panel\" config=\"color:red;init:FUNC.panelready;class:loaded;aclass:1\"></ui-plugin>\n\n<script>\nFUNC.panelready = function(element) {\n  console.log('init', element.prop('tagName'));\n};\n\nPLUGIN('panel', 'color:blue;size:10', function(exports, config, cls) {\n  console.log(config.color, config.size, cls);\n});\n</script>\n```\n\n```text\nred 10 panel\ninit UI-PLUGIN\n```\n\nDas Element hat am Ende die Klassen `panel loaded`.\n\n## Lebenszyklus\n\n1. Der Callback von `PLUGIN()` läuft. Weise hier Methoden zu und registriere Watcher.\n2. `exports.make()` läuft, falls definiert, wenn die Instanz bereit ist.\n3. `exports.destroy()` läuft, falls definiert, wenn das Plugin entfernt wird.\n\nDie Bibliothek sucht einmal pro Minute nach entfernten Elementen. `FREE()` führt diese Bereinigung sofort aus:\n\n```js\nPLUGIN('chart', function(exports) {\n  exports.destroy = function() {\n    console.log('destroy');\n  };\n});\n\n$('#area').empty();\nconsole.log(typeof PLUGINS.chart); // object\nFREE();                            // destroy\nconsole.log(typeof PLUGINS.chart); // undefined\n```\n\n## Eine Deklaration, mehrere Instanzen\n\nHat das Attribut `path` zwei Wörter, ist das erste der Path der Instanz und das zweite der Name der Deklaration. Verwende `?` als erstes Wort, um einen generierten Path zu erhalten.\n\n```html\n<ui-plugin path=\"left timer\"></ui-plugin>\n<ui-plugin path=\"right timer\"></ui-plugin>\n<ui-plugin path=\"? timer\"></ui-plugin>\n\n<script>\nPLUGIN('timer', function(exports) {\n  exports.make = function() {\n    exports.set('value', exports.name.length);\n  };\n});\n</script>\n```\n\n`left.value` ist `4` und `right.value` ist `5`. Jede Instanz behält ihre eigenen Daten. Die dritte Instanz hat einen eindeutigen Path, der mit `jComponent.data.` beginnt.\n\n## Das Plugin common\n\nDer Name `*` ist eine Kurzform für das Plugin `common`, einen praktischen Ort für alles, was die gesamte Anwendung gemeinsam nutzt:\n\n```html\n<ui-plugin path=\"*\"></ui-plugin>\n\n<script>\nPLUGIN('*', function(exports) {\n  exports.hello = function() {\n    console.log('hello from', exports.name);\n  };\n});\n\nEXEC('common/hello'); // hello from common\n</script>\n```\n\n## Verschachtelte Plugins\n\nEin Plugin kann in einem anderen Plugin liegen. `?` in seinem `path` wird durch den Path des übergeordneten Plugins ersetzt, `?1` in seinem Markup zeigt ein Plugin nach oben, und `exports.parent` gibt die übergeordnete Instanz zurück.\n\n```html\n<ui-plugin path=\"order\">\n  <ui-plugin path=\"?.customer\">\n    <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n    /\n    <ui-bind path=\"?1.number\" config=\"text\"></ui-bind>\n  </ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('order', function(exports) {\n  exports.set('number', 'A-100');\n});\n\nPLUGIN('order.customer', function(exports) {\n  exports.make = function() {\n    exports.set('name', 'Ann');\n    console.log(exports.name, exports.parent.name); // order.customer order\n  };\n});\n</script>\n```\n\nDas innere Plugin rendert `Ann / A-100`, und die Daten sind `{\"number\":\"A-100\",\"customer\":{\"name\":\"Ann\"}}`.\n\n## Daten von einem Server laden\n\n`exports.ajax(url, [data], [callback])` sendet eine Anfrage. Ist das letzte Argument ein String, wird die Antwort in diesen Path des Plugins geschrieben:\n\n```js\nPLUGIN('products', function(exports) {\n  exports.make = function() {\n\n    // Writes the response to \"products.items\"\n    exports.ajax('GET /api/products/', 'items');\n\n    exports.ajax('GET /api/products/', function(response) {\n      console.log(response.length);\n    });\n  };\n});\n```\n\n## Abhängigkeiten\n\nDas letzte Argument von `PLUGIN()` listet auf, was bereit sein muss, bevor das Plugin startet. Es ist ein String mit durch Kommas getrennten URLs oder ein Array aus URLs und Funktionen. Eine Funktion erhält einen Callback `next`.\n\n```js\nvar loadmaps = function(next) {\n  window.MAPS = { ready: true };\n  next();\n};\n\nPLUGIN('map', function(exports) {\n  console.log(window.MAPS.ready); // true\n}, ['/js/geo.js', loadmaps]);\n```\n\nURLs werden mit `IMPORT()` geladen. Wie du ein ganzes Plugin aus einer Datei lädst, steht unter [Inhalte importieren](../importing/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNe1yd61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/plugins/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Plugins","summary":"Cómo agrupar en un plugin los datos, la lógica y el marcado de una parte de una aplicación.","markdown":"---\ntitle: Plugins\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/plugins/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Plugins\n\n> Cómo agrupar en un plugin los datos, la lógica y el marcado de una parte de una aplicación.\n\nUn plugin contiene una parte de una aplicación: una página, un formulario, un diálogo. Es dueño de una porción del modelo de datos, guarda la lógica que trabaja con ella y ofrece paths relativos cortos al marcado que hay dentro de su elemento. Un plugin tiene dos partes: una declaración hecha con `PLUGIN()` y un elemento `<ui-plugin>` que crea una instancia de ella.\n\n## Declarar un plugin\n\n`PLUGIN(name, [config], callback, [dependencies])` registra una declaración. El atributo `path` de `<ui-plugin>` selecciona la declaración y establece dónde guarda el plugin sus datos.\n\n```html\n<ui-plugin path=\"counter\" config=\"step:2\">\n  <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n  <button class=\"exec\" data-exec=\"?/plus\">Add</button>\n</ui-plugin>\n\n<script>\nPLUGIN('counter', 'step:1;label:Clicks', function(exports, config) {\n\n  exports.make = function() {\n    exports.set('count', 0);\n    console.log(exports.name, config.step, config.label);\n  };\n\n  exports.plus = function() {\n    exports.inc('count', config.step);\n  };\n\n});\n</script>\n```\n\nLa consola imprime `counter 2 Clicks`, y dos clics en el botón dejan `4` en `counter.count`.\n\nEl callback recibe tres argumentos:\n\n| Argumento | Descripción |\n| --- | --- |\n| `exports` | La instancia del plugin. También es el valor de `this`. |\n| `config` | La configuración combinada. |\n| `cls` | El valor del atributo `path` del elemento. |\n\nLa instancia expone `name`, `path`, `element`, `dom` y `config`. Todos sus métodos aparecen en la referencia de [Plugin](../../reference/plugin/).\n\n## Trabajar con los datos del plugin\n\nDentro del marcado de un plugin, `?` representa el path del plugin. `?.count` en el plugin `counter` es el path global `counter.count`. Lee más sobre los paths en [Paths](../paths/).\n\nEn el código, los métodos de `exports` reciben un path relativo al plugin:\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.make = function() {\n    exports.set('title', 'My cart');\n    exports.push('items', 'Apple');\n    exports.push('items', ['Pear', 'Plum']);\n    exports.inc('count', 3);\n    exports.toggle('open');\n    exports.nul('title');\n    console.log(JSON.stringify(exports.model));\n    console.log(exports.get('items.length'));\n  };\n});\n```\n\n```text\n{\"title\":null,\"items\":[\"Apple\",\"Pear\",\"Plum\"],\"count\":3,\"open\":true}\n3\n```\n\n`exports.model` lee o sustituye todos los datos del plugin, y `exports.data` es el mismo valor. Cada escritura avisa a los componentes, enlaces y observadores de ese path. `exports.upd(path)` envía el aviso sin cambiar el valor.\n\n## Métodos\n\nCada función asignada a `exports` es un método al que puede llamar otro código:\n\n| Dónde | Cómo llamarlo |\n| --- | --- |\n| Cualquier script | `EXEC('inbox/clear')` |\n| Marcado dentro del plugin | `<button class=\"exec\" data-exec=\"?/clear\">` |\n| El propio plugin | `exports.exec('clear')` |\n\nUn clic en un elemento con la clase `exec` llama al método con el elemento y el evento como argumentos. Además, cada instancia está disponible como `PLUGINS.name`.\n\n## Observar datos y escuchar eventos\n\n`exports.watch(path, callback, [autoinit])` reacciona a los cambios bajo el path del plugin. `exports.on(name, callback)` escucha un evento global enviado con `EMIT()`.\n\n```js\nPLUGIN('inbox', function(exports) {\n\n  exports.watch('unread', function(value, flags, path) {\n    console.log('watch', path, value);\n  });\n\n  exports.on('message', function(text) {\n    exports.inc('unread');\n    console.log('event', text);\n  });\n\n  exports.clear = function() {\n    exports.set('unread', 0);\n  };\n});\n\nEMIT('message', 'Hello');\nEXEC('inbox/clear');\nSET('inbox.unread', 5);\n```\n\n```text\nwatch inbox.unread 1\nevent Hello\nwatch inbox.unread 0\nwatch inbox.unread 5\n```\n\nLlama a `EMIT()` y `EXEC()` cuando el plugin ya exista, por ejemplo en `ON('ready', callback)`.\n\n## Configuración\n\nLa configuración del elemento sobrescribe la de la declaración. Tres claves tienen un significado especial:\n\n| Clave | Descripción |\n| --- | --- |\n| `init` | El nombre de una función a la que se llama con el elemento del plugin cuando este arranca. |\n| `class` | Clases CSS que se alternan en el elemento poco después de que arranque el plugin. |\n| `aclass` | Si es verdadero, añade el nombre del plugin al elemento como clase CSS. |\n\n```html\n<ui-plugin path=\"panel\" config=\"color:red;init:FUNC.panelready;class:loaded;aclass:1\"></ui-plugin>\n\n<script>\nFUNC.panelready = function(element) {\n  console.log('init', element.prop('tagName'));\n};\n\nPLUGIN('panel', 'color:blue;size:10', function(exports, config, cls) {\n  console.log(config.color, config.size, cls);\n});\n</script>\n```\n\n```text\nred 10 panel\ninit UI-PLUGIN\n```\n\nEl elemento termina con las clases `panel loaded`.\n\n## Ciclo de vida\n\n1. Se ejecuta el callback de `PLUGIN()`. Asigna aquí los métodos y registra los observadores.\n2. Se ejecuta `exports.make()`, si está definido, cuando la instancia está lista.\n3. Se ejecuta `exports.destroy()`, si está definido, cuando se elimina el plugin.\n\nLa biblioteca busca elementos eliminados una vez por minuto. `FREE()` ejecuta esa limpieza al momento:\n\n```js\nPLUGIN('chart', function(exports) {\n  exports.destroy = function() {\n    console.log('destroy');\n  };\n});\n\n$('#area').empty();\nconsole.log(typeof PLUGINS.chart); // object\nFREE();                            // destroy\nconsole.log(typeof PLUGINS.chart); // undefined\n```\n\n## Una declaración, varias instancias\n\nCuando el atributo `path` tiene dos palabras, la primera es el path de la instancia y la segunda es el nombre de la declaración. Usa `?` como primera palabra para obtener un path generado.\n\n```html\n<ui-plugin path=\"left timer\"></ui-plugin>\n<ui-plugin path=\"right timer\"></ui-plugin>\n<ui-plugin path=\"? timer\"></ui-plugin>\n\n<script>\nPLUGIN('timer', function(exports) {\n  exports.make = function() {\n    exports.set('value', exports.name.length);\n  };\n});\n</script>\n```\n\n`left.value` es `4` y `right.value` es `5`. Cada instancia guarda sus propios datos. La tercera instancia tiene un path único que empieza por `jComponent.data.`.\n\n## El plugin common\n\nEl nombre `*` es un atajo del plugin `common`, un lugar práctico para lo que comparte toda la aplicación:\n\n```html\n<ui-plugin path=\"*\"></ui-plugin>\n\n<script>\nPLUGIN('*', function(exports) {\n  exports.hello = function() {\n    console.log('hello from', exports.name);\n  };\n});\n\nEXEC('common/hello'); // hello from common\n</script>\n```\n\n## Plugins anidados\n\nUn plugin puede estar dentro de otro plugin. `?` en su `path` se sustituye por el path del padre, `?1` en su marcado apunta un plugin más arriba y `exports.parent` devuelve la instancia del padre.\n\n```html\n<ui-plugin path=\"order\">\n  <ui-plugin path=\"?.customer\">\n    <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n    /\n    <ui-bind path=\"?1.number\" config=\"text\"></ui-bind>\n  </ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('order', function(exports) {\n  exports.set('number', 'A-100');\n});\n\nPLUGIN('order.customer', function(exports) {\n  exports.make = function() {\n    exports.set('name', 'Ann');\n    console.log(exports.name, exports.parent.name); // order.customer order\n  };\n});\n</script>\n```\n\nEl plugin interno renderiza `Ann / A-100`, y los datos son `{\"number\":\"A-100\",\"customer\":{\"name\":\"Ann\"}}`.\n\n## Cargar datos desde un servidor\n\n`exports.ajax(url, [data], [callback])` envía una petición. Cuando el último argumento es una cadena, la respuesta se escribe en ese path del plugin:\n\n```js\nPLUGIN('products', function(exports) {\n  exports.make = function() {\n\n    // Writes the response to \"products.items\"\n    exports.ajax('GET /api/products/', 'items');\n\n    exports.ajax('GET /api/products/', function(response) {\n      console.log(response.length);\n    });\n  };\n});\n```\n\n## Dependencias\n\nEl último argumento de `PLUGIN()` enumera lo que debe estar listo antes de que arranque el plugin. Es una cadena de URL separadas por comas o un array de URL y funciones. Una función recibe un callback `next`.\n\n```js\nvar loadmaps = function(next) {\n  window.MAPS = { ready: true };\n  next();\n};\n\nPLUGIN('map', function(exports) {\n  console.log(window.MAPS.ready); // true\n}, ['/js/geo.js', loadmaps]);\n```\n\nLas URL se cargan con `IMPORT()`. Para cargar un plugin completo desde un archivo, consulta [Importar contenido](../importing/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNe1yd61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/plugins/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Plugins","summary":"Comment regrouper dans un plugin les données, la logique et le balisage d'une partie d'une application.","markdown":"---\ntitle: Plugins\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/plugins/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Plugins\n\n> Comment regrouper dans un plugin les données, la logique et le balisage d'une partie d'une application.\n\nUn plugin contient une partie d'une application : une page, un formulaire, une boîte de dialogue. Il possède un morceau du modèle de données, conserve la logique qui s'y rapporte et donne au balisage placé dans son élément de courts paths relatifs. Un plugin comporte deux parties : une déclaration faite avec `PLUGIN()` et un élément `<ui-plugin>` qui en crée une instance.\n\n## Déclarer un plugin\n\n`PLUGIN(name, [config], callback, [dependencies])` enregistre une déclaration. L'attribut `path` de `<ui-plugin>` sélectionne la déclaration et définit l'endroit où le plugin garde ses données.\n\n```html\n<ui-plugin path=\"counter\" config=\"step:2\">\n  <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n  <button class=\"exec\" data-exec=\"?/plus\">Add</button>\n</ui-plugin>\n\n<script>\nPLUGIN('counter', 'step:1;label:Clicks', function(exports, config) {\n\n  exports.make = function() {\n    exports.set('count', 0);\n    console.log(exports.name, config.step, config.label);\n  };\n\n  exports.plus = function() {\n    exports.inc('count', config.step);\n  };\n\n});\n</script>\n```\n\nLa console affiche `counter 2 Clicks`, et deux clics sur le bouton laissent `4` dans `counter.count`.\n\nLe callback reçoit trois arguments :\n\n| Argument | Description |\n| --- | --- |\n| `exports` | L'instance du plugin. C'est aussi la valeur de `this`. |\n| `config` | La configuration fusionnée. |\n| `cls` | La valeur de l'attribut `path` de l'élément. |\n\nL'instance expose `name`, `path`, `element`, `dom` et `config`. Toutes ses méthodes sont répertoriées dans la référence [Plugin](../../reference/plugin/).\n\n## Travailler avec les données du plugin\n\nDans le balisage d'un plugin, `?` représente le path du plugin. `?.count` dans le plugin `counter` correspond au path global `counter.count`. Pour en savoir plus sur les paths, lis [Paths](../paths/).\n\nDans le code, les méthodes de `exports` prennent un path relatif au plugin :\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.make = function() {\n    exports.set('title', 'My cart');\n    exports.push('items', 'Apple');\n    exports.push('items', ['Pear', 'Plum']);\n    exports.inc('count', 3);\n    exports.toggle('open');\n    exports.nul('title');\n    console.log(JSON.stringify(exports.model));\n    console.log(exports.get('items.length'));\n  };\n});\n```\n\n```text\n{\"title\":null,\"items\":[\"Apple\",\"Pear\",\"Plum\"],\"count\":3,\"open\":true}\n3\n```\n\n`exports.model` lit ou remplace toutes les données du plugin, et `exports.data` est la même valeur. Chaque écriture prévient les composants, les liaisons et les observateurs de ce path. `exports.upd(path)` envoie la notification sans modifier la valeur.\n\n## Méthodes\n\nChaque fonction assignée à `exports` est une méthode que d'autres parties du code peuvent appeler :\n\n| Où | Comment l'appeler |\n| --- | --- |\n| N'importe quel script | `EXEC('inbox/clear')` |\n| Balisage à l'intérieur du plugin | `<button class=\"exec\" data-exec=\"?/clear\">` |\n| Le plugin lui-même | `exports.exec('clear')` |\n\nUn clic sur un élément doté de la classe `exec` appelle la méthode avec l'élément et l'événement comme arguments. Chaque instance est aussi disponible sous le nom `PLUGINS.name`.\n\n## Observer les données et écouter les événements\n\n`exports.watch(path, callback, [autoinit])` réagit aux changements sous le path du plugin. `exports.on(name, callback)` écoute un événement global envoyé avec `EMIT()`.\n\n```js\nPLUGIN('inbox', function(exports) {\n\n  exports.watch('unread', function(value, flags, path) {\n    console.log('watch', path, value);\n  });\n\n  exports.on('message', function(text) {\n    exports.inc('unread');\n    console.log('event', text);\n  });\n\n  exports.clear = function() {\n    exports.set('unread', 0);\n  };\n});\n\nEMIT('message', 'Hello');\nEXEC('inbox/clear');\nSET('inbox.unread', 5);\n```\n\n```text\nwatch inbox.unread 1\nevent Hello\nwatch inbox.unread 0\nwatch inbox.unread 5\n```\n\nAppelle `EMIT()` et `EXEC()` une fois que le plugin existe, par exemple dans `ON('ready', callback)`.\n\n## Configuration\n\nLa configuration de l'élément remplace celle de la déclaration. Trois clés ont une signification particulière :\n\n| Clé | Description |\n| --- | --- |\n| `init` | Le nom d'une fonction à appeler avec l'élément du plugin au démarrage du plugin. |\n| `class` | Les classes CSS à basculer sur l'élément peu après le démarrage du plugin. |\n| `aclass` | Si la valeur est truthy, ajoute le nom du plugin à l'élément comme classe CSS. |\n\n```html\n<ui-plugin path=\"panel\" config=\"color:red;init:FUNC.panelready;class:loaded;aclass:1\"></ui-plugin>\n\n<script>\nFUNC.panelready = function(element) {\n  console.log('init', element.prop('tagName'));\n};\n\nPLUGIN('panel', 'color:blue;size:10', function(exports, config, cls) {\n  console.log(config.color, config.size, cls);\n});\n</script>\n```\n\n```text\nred 10 panel\ninit UI-PLUGIN\n```\n\nL'élément finit avec les classes `panel loaded`.\n\n## Cycle de vie\n\n1. Le callback de `PLUGIN()` s'exécute. Assigne ici les méthodes et enregistre les observateurs.\n2. `exports.make()` s'exécute, s'il est défini, quand l'instance est prête.\n3. `exports.destroy()` s'exécute, s'il est défini, quand le plugin est supprimé.\n\nLa bibliothèque recherche les éléments supprimés une fois par minute. `FREE()` lance ce nettoyage immédiatement :\n\n```js\nPLUGIN('chart', function(exports) {\n  exports.destroy = function() {\n    console.log('destroy');\n  };\n});\n\n$('#area').empty();\nconsole.log(typeof PLUGINS.chart); // object\nFREE();                            // destroy\nconsole.log(typeof PLUGINS.chart); // undefined\n```\n\n## Une déclaration, plusieurs instances\n\nQuand l'attribut `path` contient deux mots, le premier est le path de l'instance et le second le nom de la déclaration. Utilise `?` comme premier mot pour obtenir un path généré.\n\n```html\n<ui-plugin path=\"left timer\"></ui-plugin>\n<ui-plugin path=\"right timer\"></ui-plugin>\n<ui-plugin path=\"? timer\"></ui-plugin>\n\n<script>\nPLUGIN('timer', function(exports) {\n  exports.make = function() {\n    exports.set('value', exports.name.length);\n  };\n});\n</script>\n```\n\n`left.value` vaut `4` et `right.value` vaut `5`. Chaque instance garde ses propres données. La troisième instance a un path unique qui commence par `jComponent.data.`.\n\n## Le plugin common\n\nLe nom `*` est un raccourci pour le plugin `common`, un endroit pratique pour ce que toute l'application partage :\n\n```html\n<ui-plugin path=\"*\"></ui-plugin>\n\n<script>\nPLUGIN('*', function(exports) {\n  exports.hello = function() {\n    console.log('hello from', exports.name);\n  };\n});\n\nEXEC('common/hello'); // hello from common\n</script>\n```\n\n## Plugins imbriqués\n\nUn plugin peut se trouver dans un autre plugin. `?` dans son `path` est remplacé par le path du parent, `?1` dans son balisage remonte d'un plugin, et `exports.parent` renvoie l'instance parente.\n\n```html\n<ui-plugin path=\"order\">\n  <ui-plugin path=\"?.customer\">\n    <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n    /\n    <ui-bind path=\"?1.number\" config=\"text\"></ui-bind>\n  </ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('order', function(exports) {\n  exports.set('number', 'A-100');\n});\n\nPLUGIN('order.customer', function(exports) {\n  exports.make = function() {\n    exports.set('name', 'Ann');\n    console.log(exports.name, exports.parent.name); // order.customer order\n  };\n});\n</script>\n```\n\nLe plugin interne affiche `Ann / A-100`, et les données sont `{\"number\":\"A-100\",\"customer\":{\"name\":\"Ann\"}}`.\n\n## Charger des données depuis un serveur\n\n`exports.ajax(url, [data], [callback])` envoie une requête. Quand le dernier argument est une chaîne, la réponse est écrite dans ce path du plugin :\n\n```js\nPLUGIN('products', function(exports) {\n  exports.make = function() {\n\n    // Writes the response to \"products.items\"\n    exports.ajax('GET /api/products/', 'items');\n\n    exports.ajax('GET /api/products/', function(response) {\n      console.log(response.length);\n    });\n  };\n});\n```\n\n## Dépendances\n\nLe dernier argument de `PLUGIN()` liste ce qui doit être prêt avant le démarrage du plugin. C'est une chaîne d'URL séparées par des virgules ou un tableau d'URL et de fonctions. Une fonction reçoit un callback `next`.\n\n```js\nvar loadmaps = function(next) {\n  window.MAPS = { ready: true };\n  next();\n};\n\nPLUGIN('map', function(exports) {\n  console.log(window.MAPS.ready); // true\n}, ['/js/geo.js', loadmaps]);\n```\n\nLes URL sont chargées avec `IMPORT()`. Pour charger un plugin entier depuis un fichier, consulte [Importer du contenu](../importing/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNe1yd61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/plugins/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Plugin","summary":"Come raggruppare in un plugin i dati, la logica e il markup di una parte di un'applicazione.","markdown":"---\ntitle: Plugin\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/plugins/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Plugin\n\n> Come raggruppare in un plugin i dati, la logica e il markup di una parte di un'applicazione.\n\nUn plugin contiene una parte di un'applicazione: una pagina, un modulo, una finestra di dialogo. Possiede una porzione del modello dei dati, conserva la logica che lavora su di essa e fornisce al markup al suo interno path relativi brevi. Un plugin è composto da due parti: una dichiarazione fatta con `PLUGIN()` e un elemento `<ui-plugin>` che ne crea un'istanza.\n\n## Dichiarare un plugin\n\n`PLUGIN(name, [config], callback, [dependencies])` registra una dichiarazione. L'attributo `path` di `<ui-plugin>` seleziona la dichiarazione e stabilisce dove il plugin conserva i propri dati.\n\n```html\n<ui-plugin path=\"counter\" config=\"step:2\">\n  <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n  <button class=\"exec\" data-exec=\"?/plus\">Add</button>\n</ui-plugin>\n\n<script>\nPLUGIN('counter', 'step:1;label:Clicks', function(exports, config) {\n\n  exports.make = function() {\n    exports.set('count', 0);\n    console.log(exports.name, config.step, config.label);\n  };\n\n  exports.plus = function() {\n    exports.inc('count', config.step);\n  };\n\n});\n</script>\n```\n\nLa console stampa `counter 2 Clicks` e due clic sul pulsante lasciano `4` in `counter.count`.\n\nLa callback riceve tre argomenti:\n\n| Argomento | Descrizione |\n| --- | --- |\n| `exports` | L'istanza del plugin. È anche il valore di `this`. |\n| `config` | La configurazione unificata. |\n| `cls` | Il valore dell'attributo `path` dell'elemento. |\n\nL'istanza espone `name`, `path`, `element`, `dom` e `config`. Tutti i suoi metodi sono elencati nel riferimento di [Plugin](../../reference/plugin/).\n\n## Lavorare con i dati del plugin\n\nNel markup di un plugin, `?` rappresenta il path del plugin. `?.count` nel plugin `counter` è il path globale `counter.count`. Approfondisci i path in [Path](../paths/).\n\nNel codice, i metodi di `exports` accettano un path relativo al plugin:\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.make = function() {\n    exports.set('title', 'My cart');\n    exports.push('items', 'Apple');\n    exports.push('items', ['Pear', 'Plum']);\n    exports.inc('count', 3);\n    exports.toggle('open');\n    exports.nul('title');\n    console.log(JSON.stringify(exports.model));\n    console.log(exports.get('items.length'));\n  };\n});\n```\n\n```text\n{\"title\":null,\"items\":[\"Apple\",\"Pear\",\"Plum\"],\"count\":3,\"open\":true}\n3\n```\n\n`exports.model` legge o sostituisce tutti i dati del plugin ed `exports.data` è lo stesso valore. Ogni scrittura avvisa i componenti, le associazioni e gli osservatori su quel path. `exports.upd(path)` invia la notifica senza modificare il valore.\n\n## Metodi\n\nOgni funzione assegnata a `exports` è un metodo che altro codice può chiamare:\n\n| Dove | Come chiamarlo |\n| --- | --- |\n| Qualsiasi script | `EXEC('inbox/clear')` |\n| Markup dentro il plugin | `<button class=\"exec\" data-exec=\"?/clear\">` |\n| Il plugin stesso | `exports.exec('clear')` |\n\nUn clic su un elemento con la classe `exec` chiama il metodo passando come argomenti l'elemento e l'evento. Ogni istanza è disponibile anche come `PLUGINS.name`.\n\n## Osservare i dati e ascoltare gli eventi\n\n`exports.watch(path, callback, [autoinit])` reagisce alle modifiche sotto il path del plugin. `exports.on(name, callback)` ascolta un evento globale inviato con `EMIT()`.\n\n```js\nPLUGIN('inbox', function(exports) {\n\n  exports.watch('unread', function(value, flags, path) {\n    console.log('watch', path, value);\n  });\n\n  exports.on('message', function(text) {\n    exports.inc('unread');\n    console.log('event', text);\n  });\n\n  exports.clear = function() {\n    exports.set('unread', 0);\n  };\n});\n\nEMIT('message', 'Hello');\nEXEC('inbox/clear');\nSET('inbox.unread', 5);\n```\n\n```text\nwatch inbox.unread 1\nevent Hello\nwatch inbox.unread 0\nwatch inbox.unread 5\n```\n\nChiama `EMIT()` ed `EXEC()` quando il plugin esiste già, ad esempio in `ON('ready', callback)`.\n\n## Configurazione\n\nLa configurazione dell'elemento sovrascrive quella della dichiarazione. Tre chiavi hanno un significato speciale:\n\n| Chiave | Descrizione |\n| --- | --- |\n| `init` | Il nome di una funzione da chiamare con l'elemento del plugin all'avvio del plugin. |\n| `class` | Le classi CSS da alternare sull'elemento poco dopo l'avvio del plugin. |\n| `aclass` | Se truthy, aggiunge all'elemento il nome del plugin come classe CSS. |\n\n```html\n<ui-plugin path=\"panel\" config=\"color:red;init:FUNC.panelready;class:loaded;aclass:1\"></ui-plugin>\n\n<script>\nFUNC.panelready = function(element) {\n  console.log('init', element.prop('tagName'));\n};\n\nPLUGIN('panel', 'color:blue;size:10', function(exports, config, cls) {\n  console.log(config.color, config.size, cls);\n});\n</script>\n```\n\n```text\nred 10 panel\ninit UI-PLUGIN\n```\n\nAlla fine l'elemento ha le classi `panel loaded`.\n\n## Ciclo di vita\n\n1. Viene eseguita la callback di `PLUGIN()`. Qui assegna i metodi e registra gli osservatori.\n2. `exports.make()` viene eseguito, se definito, quando l'istanza è pronta.\n3. `exports.destroy()` viene eseguito, se definito, quando il plugin viene rimosso.\n\nLa libreria cerca gli elementi rimossi una volta al minuto. `FREE()` esegue subito questa pulizia:\n\n```js\nPLUGIN('chart', function(exports) {\n  exports.destroy = function() {\n    console.log('destroy');\n  };\n});\n\n$('#area').empty();\nconsole.log(typeof PLUGINS.chart); // object\nFREE();                            // destroy\nconsole.log(typeof PLUGINS.chart); // undefined\n```\n\n## Una dichiarazione, più istanze\n\nQuando l'attributo `path` contiene due parole, la prima è il path dell'istanza e la seconda il nome della dichiarazione. Usa `?` come prima parola per ottenere un path generato.\n\n```html\n<ui-plugin path=\"left timer\"></ui-plugin>\n<ui-plugin path=\"right timer\"></ui-plugin>\n<ui-plugin path=\"? timer\"></ui-plugin>\n\n<script>\nPLUGIN('timer', function(exports) {\n  exports.make = function() {\n    exports.set('value', exports.name.length);\n  };\n});\n</script>\n```\n\n`left.value` vale `4` e `right.value` vale `5`. Ogni istanza conserva i propri dati. La terza istanza ha un path univoco che inizia con `jComponent.data.`.\n\n## Il plugin common\n\nIl nome `*` è una scorciatoia per il plugin `common`, un posto comodo per ciò che l'intera applicazione condivide:\n\n```html\n<ui-plugin path=\"*\"></ui-plugin>\n\n<script>\nPLUGIN('*', function(exports) {\n  exports.hello = function() {\n    console.log('hello from', exports.name);\n  };\n});\n\nEXEC('common/hello'); // hello from common\n</script>\n```\n\n## Plugin annidati\n\nUn plugin può trovarsi dentro un altro plugin. `?` nel suo `path` viene sostituito dal path del genitore, `?1` nel suo markup punta al plugin di un livello superiore ed `exports.parent` restituisce l'istanza del genitore.\n\n```html\n<ui-plugin path=\"order\">\n  <ui-plugin path=\"?.customer\">\n    <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n    /\n    <ui-bind path=\"?1.number\" config=\"text\"></ui-bind>\n  </ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('order', function(exports) {\n  exports.set('number', 'A-100');\n});\n\nPLUGIN('order.customer', function(exports) {\n  exports.make = function() {\n    exports.set('name', 'Ann');\n    console.log(exports.name, exports.parent.name); // order.customer order\n  };\n});\n</script>\n```\n\nIl plugin interno visualizza `Ann / A-100` e i dati sono `{\"number\":\"A-100\",\"customer\":{\"name\":\"Ann\"}}`.\n\n## Caricare dati da un server\n\n`exports.ajax(url, [data], [callback])` invia una richiesta. Quando l'ultimo argomento è una stringa, la risposta viene scritta in quel path del plugin:\n\n```js\nPLUGIN('products', function(exports) {\n  exports.make = function() {\n\n    // Writes the response to \"products.items\"\n    exports.ajax('GET /api/products/', 'items');\n\n    exports.ajax('GET /api/products/', function(response) {\n      console.log(response.length);\n    });\n  };\n});\n```\n\n## Dipendenze\n\nL'ultimo argomento di `PLUGIN()` elenca ciò che deve essere pronto prima dell'avvio del plugin. È una stringa di URL separati da virgole oppure un array di URL e funzioni. Una funzione riceve una callback `next`.\n\n```js\nvar loadmaps = function(next) {\n  window.MAPS = { ready: true };\n  next();\n};\n\nPLUGIN('map', function(exports) {\n  console.log(window.MAPS.ready); // true\n}, ['/js/geo.js', loadmaps]);\n```\n\nGli URL vengono caricati con `IMPORT()`. Per caricare un intero plugin da un file, consulta [Importare contenuti](../importing/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNe1yd61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/plugins/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Pluginy","summary":"Ako zoskupiť dáta, logiku a značkovanie jednej časti aplikácie do pluginu.","markdown":"---\ntitle: Pluginy\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/plugins/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Pluginy\n\n> Ako zoskupiť dáta, logiku a značkovanie jednej časti aplikácie do pluginu.\n\nPlugin obsahuje jednu časť aplikácie: stránku, formulár, dialóg. Vlastní kúsok dátového modelu, drží logiku, ktorá s ním pracuje, a značkovaniu vo svojom elemente poskytuje krátke relatívne path. Plugin má dve časti: deklaráciu vytvorenú cez `PLUGIN()` a element `<ui-plugin>`, ktorý vytvorí jeho inštanciu.\n\n## Deklarácia pluginu\n\n`PLUGIN(name, [config], callback, [dependencies])` zaregistruje deklaráciu. Atribút `path` elementu `<ui-plugin>` vyberie deklaráciu a určí, kde si plugin drží dáta.\n\n```html\n<ui-plugin path=\"counter\" config=\"step:2\">\n  <b><ui-bind path=\"?.count\" config=\"text\"></ui-bind></b>\n  <button class=\"exec\" data-exec=\"?/plus\">Add</button>\n</ui-plugin>\n\n<script>\nPLUGIN('counter', 'step:1;label:Clicks', function(exports, config) {\n\n  exports.make = function() {\n    exports.set('count', 0);\n    console.log(exports.name, config.step, config.label);\n  };\n\n  exports.plus = function() {\n    exports.inc('count', config.step);\n  };\n\n});\n</script>\n```\n\nKonzola vypíše `counter 2 Clicks` a po dvoch kliknutiach na tlačidlo zostane v `counter.count` hodnota `4`.\n\nCallback dostane tri argumenty:\n\n| Argument | Popis |\n| --- | --- |\n| `exports` | Inštancia pluginu. Je to aj hodnota `this`. |\n| `config` | Zlúčená konfigurácia. |\n| `cls` | Hodnota atribútu `path` elementu. |\n\nInštancia sprístupňuje `name`, `path`, `element`, `dom` a `config`. Všetky jej metódy uvádza referencia [Plugin](../../reference/plugin/).\n\n## Práca s dátami pluginu\n\nV značkovaní pluginu zastupuje `?` path pluginu. `?.count` v plugine `counter` je globálna path `counter.count`. Viac o path sa dočítaš v časti [Paths](../paths/).\n\nV kóde prijímajú metódy `exports` path relatívnu k pluginu:\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.make = function() {\n    exports.set('title', 'My cart');\n    exports.push('items', 'Apple');\n    exports.push('items', ['Pear', 'Plum']);\n    exports.inc('count', 3);\n    exports.toggle('open');\n    exports.nul('title');\n    console.log(JSON.stringify(exports.model));\n    console.log(exports.get('items.length'));\n  };\n});\n```\n\n```text\n{\"title\":null,\"items\":[\"Apple\",\"Pear\",\"Plum\"],\"count\":3,\"open\":true}\n3\n```\n\n`exports.model` prečíta alebo nahradí všetky dáta pluginu a `exports.data` je tá istá hodnota. Každý zápis upozorní komponenty, väzby a sledovače na danej path. `exports.upd(path)` odošle upozornenie bez zmeny hodnoty.\n\n## Metódy\n\nKaždá funkcia priradená do `exports` je metóda, ktorú môže volať iný kód:\n\n| Kde | Ako ju zavolať |\n| --- | --- |\n| Ľubovoľný skript | `EXEC('inbox/clear')` |\n| Značkovanie vo vnútri pluginu | `<button class=\"exec\" data-exec=\"?/clear\">` |\n| Samotný plugin | `exports.exec('clear')` |\n\nKliknutie na element s triedou `exec` zavolá metódu a ako argumenty jej odovzdá element a udalosť. Každá inštancia je dostupná aj ako `PLUGINS.name`.\n\n## Sledovanie dát a počúvanie udalostí\n\n`exports.watch(path, callback, [autoinit])` reaguje na zmeny pod path pluginu. `exports.on(name, callback)` počúva globálnu udalosť odoslanú cez `EMIT()`.\n\n```js\nPLUGIN('inbox', function(exports) {\n\n  exports.watch('unread', function(value, flags, path) {\n    console.log('watch', path, value);\n  });\n\n  exports.on('message', function(text) {\n    exports.inc('unread');\n    console.log('event', text);\n  });\n\n  exports.clear = function() {\n    exports.set('unread', 0);\n  };\n});\n\nEMIT('message', 'Hello');\nEXEC('inbox/clear');\nSET('inbox.unread', 5);\n```\n\n```text\nwatch inbox.unread 1\nevent Hello\nwatch inbox.unread 0\nwatch inbox.unread 5\n```\n\n`EMIT()` a `EXEC()` volaj až vtedy, keď plugin existuje, napríklad v `ON('ready', callback)`.\n\n## Konfigurácia\n\nKonfigurácia elementu prepíše konfiguráciu deklarácie. Tri kľúče majú špeciálny význam:\n\n| Kľúč | Popis |\n| --- | --- |\n| `init` | Názov funkcie, ktorá sa pri štarte pluginu zavolá s elementom pluginu. |\n| `class` | CSS triedy, ktoré sa na elemente prepnú krátko po štarte pluginu. |\n| `aclass` | Keď je pravdivý, pridá elementu názov pluginu ako CSS triedu. |\n\n```html\n<ui-plugin path=\"panel\" config=\"color:red;init:FUNC.panelready;class:loaded;aclass:1\"></ui-plugin>\n\n<script>\nFUNC.panelready = function(element) {\n  console.log('init', element.prop('tagName'));\n};\n\nPLUGIN('panel', 'color:blue;size:10', function(exports, config, cls) {\n  console.log(config.color, config.size, cls);\n});\n</script>\n```\n\n```text\nred 10 panel\ninit UI-PLUGIN\n```\n\nElement nakoniec dostane triedy `panel loaded`.\n\n## Životný cyklus\n\n1. Spustí sa callback `PLUGIN()`. Tu priraď metódy a zaregistruj sledovače.\n2. Keď je inštancia pripravená, spustí sa `exports.make()`, ak je definovaná.\n3. Keď sa plugin odstráni, spustí sa `exports.destroy()`, ak je definovaná.\n\nKnižnica hľadá odstránené elementy raz za minútu. `FREE()` spustí toto upratovanie okamžite:\n\n```js\nPLUGIN('chart', function(exports) {\n  exports.destroy = function() {\n    console.log('destroy');\n  };\n});\n\n$('#area').empty();\nconsole.log(typeof PLUGINS.chart); // object\nFREE();                            // destroy\nconsole.log(typeof PLUGINS.chart); // undefined\n```\n\n## Jedna deklarácia, viac inštancií\n\nKeď má atribút `path` dve slová, prvé je path inštancie a druhé názov deklarácie. Ak chceš vygenerovanú path, použi ako prvé slovo `?`.\n\n```html\n<ui-plugin path=\"left timer\"></ui-plugin>\n<ui-plugin path=\"right timer\"></ui-plugin>\n<ui-plugin path=\"? timer\"></ui-plugin>\n\n<script>\nPLUGIN('timer', function(exports) {\n  exports.make = function() {\n    exports.set('value', exports.name.length);\n  };\n});\n</script>\n```\n\n`left.value` je `4` a `right.value` je `5`. Každá inštancia má vlastné dáta. Tretia inštancia má jedinečnú path, ktorá začína na `jComponent.data.`.\n\n## Plugin common\n\nNázov `*` je skratka pluginu `common`, ktorý je praktickým miestom pre to, čo zdieľa celá aplikácia:\n\n```html\n<ui-plugin path=\"*\"></ui-plugin>\n\n<script>\nPLUGIN('*', function(exports) {\n  exports.hello = function() {\n    console.log('hello from', exports.name);\n  };\n});\n\nEXEC('common/hello'); // hello from common\n</script>\n```\n\n## Vnorené pluginy\n\nPlugin môže byť vo vnútri iného pluginu. `?` v jeho `path` sa nahradí path nadradeného pluginu, `?1` v jeho značkovaní ukazuje o jeden plugin vyššie a `exports.parent` vráti nadradenú inštanciu.\n\n```html\n<ui-plugin path=\"order\">\n  <ui-plugin path=\"?.customer\">\n    <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n    /\n    <ui-bind path=\"?1.number\" config=\"text\"></ui-bind>\n  </ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('order', function(exports) {\n  exports.set('number', 'A-100');\n});\n\nPLUGIN('order.customer', function(exports) {\n  exports.make = function() {\n    exports.set('name', 'Ann');\n    console.log(exports.name, exports.parent.name); // order.customer order\n  };\n});\n</script>\n```\n\nVnútorný plugin vykreslí `Ann / A-100` a dáta sú `{\"number\":\"A-100\",\"customer\":{\"name\":\"Ann\"}}`.\n\n## Načítanie dát zo servera\n\n`exports.ajax(url, [data], [callback])` odošle požiadavku. Keď je posledný argument reťazec, odpoveď sa zapíše na túto path pluginu:\n\n```js\nPLUGIN('products', function(exports) {\n  exports.make = function() {\n\n    // Writes the response to \"products.items\"\n    exports.ajax('GET /api/products/', 'items');\n\n    exports.ajax('GET /api/products/', function(response) {\n      console.log(response.length);\n    });\n  };\n});\n```\n\n## Závislosti\n\nPosledný argument `PLUGIN()` uvádza, čo musí byť pripravené pred štartom pluginu. Je to reťazec URL oddelených čiarkami alebo pole URL a funkcií. Funkcia dostane callback `next`.\n\n```js\nvar loadmaps = function(next) {\n  window.MAPS = { ready: true };\n  next();\n};\n\nPLUGIN('map', function(exports) {\n  console.log(window.MAPS.ready); // true\n}, ['/js/geo.js', loadmaps]);\n```\n\nURL sa načítavajú cez `IMPORT()`. Ako načítať celý plugin zo súboru, opisuje časť [Import obsahu](../importing/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNR1qd61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/importing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Importing content","summary":"How to load scripts, stylesheets and HTML parts into a running page with IMPORT() and the ui-import element.","markdown":"---\ntitle: Importing content\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/importing/\nupdated: 2026-11-22T18:41:57.302Z\n---\n\n# Importing content\n\n> How to load scripts, stylesheets and HTML parts into a running page with IMPORT() and the ui-import element.\n\nAn application does not have to load everything at start. `IMPORT()` loads a script, a stylesheet or a part of a page when it is needed, and the `<ui-import>` element does the same from the markup.\n\n## IMPORT()\n\n`IMPORT(url, [target], [callback], [prepare])` decides what to do from the extension of the URL:\n\n| Extension | Result |\n| --- | --- |\n| `.js` | Adds a `<script>` to the `<head>`. |\n| `.css` | Adds a `<link>` to the `<head>`. |\n| Anything else | Downloads the content as HTML and inserts it into `target`. |\n\n| Argument | Description |\n| --- | --- |\n| `url` | The address, with optional flags. |\n| `target` | A selector or an element for HTML content. The default is `body`. |\n| `callback` | A function called when the content is loaded. |\n| `prepare` | A function that receives the downloaded HTML and returns the HTML to insert. |\n\n## Scripts and stylesheets\n\n```js\nIMPORT('/js/charts.js', function() {\n  console.log('script', window.CHARTS);\n});\n\nIMPORT('/css/charts.css', function() {\n  console.log('style loaded');\n});\n```\n\nThe callback runs after the file has loaded. If a script or a stylesheet cannot be loaded, the library writes a warning to the console and the callback still runs.\n\nWhen the URL has no extension, name the type after a space:\n\n```js\nIMPORT('/assets/charts?v=2 .js', function() {\n  console.log('script loaded');\n});\n```\n\n## Loading a file once\n\nEach call to `IMPORT()` loads the file again. There are two ways to avoid that.\n\nThe `@singleton` flag loads a script or a stylesheet only once, however many times it is requested:\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nA global variable in angle brackets skips the download when that variable already exists:\n\n```js\nIMPORT('<CHARTS> /js/charts.js', function() {\n  console.log('CHARTS is available');\n});\n```\n\nFor HTML, `@singleton` downloads the content once, and each call inserts the kept copy into its target.\n\n## HTML parts\n\nDownloaded HTML is appended to the target. The `@prepend` flag inserts it at the beginning. `<style>` blocks move to the `<head>`, and `<script src>` tags are added to the `<head>` once.\n\n```js\n// /parts/note.html contains:\n// <style>.note { color: green; }</style><p class=\"note\">Imported</p>\n\nIMPORT('/parts/note.html', '#content', function() {\n  console.log($('#content').html());\n});\n\nIMPORT('/parts/note.html @prepend', '#side', function() {\n  console.log($('#side').html());\n});\n```\n\n```text\n<p>Existing</p><p class=\"note\">Imported</p>\n<p class=\"note\">Imported</p><p>Existing</p>\n```\n\nThe `prepare` function changes the content before it is inserted:\n\n```js\n// /parts/hello.html contains: <p>Hello NAME</p>\n\nIMPORT('/parts/hello.html', '#third', function() {\n  console.log($('#third').html()); // <p>Hello Ann</p>\n}, function(html) {\n  return html.replace('NAME', 'Ann');\n});\n```\n\n## Placeholders in imported HTML\n\nImported HTML can use these placeholders:\n\n| Placeholder | Replaced with |\n| --- | --- |\n| `@(text)` | The translation of the text. See [Localization](../localization/). |\n| `--name=value--` | Nothing. It defines a variable for the file. |\n| `--name--` | The value of the variable defined in the file. |\n| `~CDN~` | The value of `DEF.cdn`. |\n\n```js\nDEF.cdn = 'https://cdn.example.com';\nLOCALIZE(HASH('Welcome').toString(36) + ' : Vitajte');\n\n// /parts/welcome.html contains:\n// --color=red--<p style=\"color:--color--\"><img src=\"~CDN~/logo.png\" />@(Welcome)</p>\n\nIMPORT('/parts/welcome.html', '#target', function() {\n  console.log($('#target').html());\n});\n```\n\n```text\n<p style=\"color:red\"><img src=\"https://cdn.example.com/logo.png\">Vitajte</p>\n```\n\n## The ui-import element\n\n`<ui-import>` imports content into itself as soon as it appears in the page. The URL goes to the `path` attribute or to the `url` configuration key.\n\n| Configuration | Description |\n| --- | --- |\n| `url` | The address, when the `path` attribute is not used. |\n| `target` | A selector of the element that receives the content. The default is the element itself. |\n| `path` | The value for `~PATH~` and `CLASS` in the content. |\n| `id` | The value for `~ID~` in the content. |\n| `init` | The name of a function to call when the content is loaded. |\n| `class` | CSS classes to toggle on the target when the content is loaded. |\n\nThe library writes a warning with the URL to the console the first time it downloads the content of a `<ui-import>`.\n\n## Importing a plugin\n\nWith the `path` key, one file can be used for any plugin. `<ui-plugin>` receives the path and `PLUGIN(function...)` is registered under it:\n\n```html\n<!-- /parts/invoice.html -->\n<ui-plugin><b id=\"~ID~\">~PATH~</b></ui-plugin>\n<script>\nPLUGIN(function(exports) {\n  exports.make = function() {\n    console.log('plugin', exports.name);\n  };\n});\n</script>\n```\n\n```html\n<ui-import path=\"/parts/invoice.html\" config=\"path:invoice;id:title;init:FUNC.imported;class:ready\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n  console.log('init');\n};\n</script>\n```\n\n```text\nplugin invoice\ninit\n```\n\nThe element `#title` contains the text `invoice`, `<ui-import>` has the class `ready`, and the instance is available as `PLUGINS.invoice`. Read more about plugins in [Plugins](../plugins/).\n\n## Knowing when content is imported\n\nThe global event `import` is emitted after each import with the URL and the target. For a script or a stylesheet, the second argument is the new element:\n\n```js\nON('import', function(url, target) {\n  console.log(url);\n});\n```\n\n## Requests made for HTML\n\nHTML is downloaded with `AJAX()`, so the request carries the language set in `DEF.language`, and a URL ending with `.html` also carries `DEF.version`. See [Localization](../localization/).\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:57.302Z"}
{"id":"JamcNR1qd61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/importing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Inhalte importieren","summary":"Wie du mit IMPORT() und dem Element ui-import Skripte, Stylesheets und HTML-Teile in eine laufende Seite lädst.","markdown":"---\ntitle: Inhalte importieren\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/importing/\nupdated: 2026-11-22T18:41:57.302Z\n---\n\n# Inhalte importieren\n\n> Wie du mit IMPORT() und dem Element ui-import Skripte, Stylesheets und HTML-Teile in eine laufende Seite lädst.\n\nEine Anwendung muss nicht alles beim Start laden. `IMPORT()` lädt ein Skript, ein Stylesheet oder einen Teil einer Seite, sobald er gebraucht wird, und das Element `<ui-import>` macht das Gleiche direkt aus dem Markup.\n\n## IMPORT()\n\n`IMPORT(url, [target], [callback], [prepare])` entscheidet anhand der Endung der URL, was zu tun ist:\n\n| Endung | Ergebnis |\n| --- | --- |\n| `.js` | Fügt dem `<head>` ein `<script>` hinzu. |\n| `.css` | Fügt dem `<head>` ein `<link>` hinzu. |\n| Alles andere | Lädt den Inhalt als HTML herunter und fügt ihn in `target` ein. |\n\n| Argument | Beschreibung |\n| --- | --- |\n| `url` | Die Adresse, optional mit Flags. |\n| `target` | Ein Selektor oder ein Element für HTML-Inhalt. Standard ist `body`. |\n| `callback` | Eine Funktion, die aufgerufen wird, wenn der Inhalt geladen ist. |\n| `prepare` | Eine Funktion, die das heruntergeladene HTML erhält und das einzufügende HTML zurückgibt. |\n\n## Skripte und Stylesheets\n\n```js\nIMPORT('/js/charts.js', function() {\n  console.log('script', window.CHARTS);\n});\n\nIMPORT('/css/charts.css', function() {\n  console.log('style loaded');\n});\n```\n\nDer Callback läuft, nachdem die Datei geladen wurde. Kann ein Skript oder Stylesheet nicht geladen werden, schreibt die Bibliothek eine Warnung in die Konsole, und der Callback läuft trotzdem.\n\nHat die URL keine Endung, gibst du den Typ nach einem Leerzeichen an:\n\n```js\nIMPORT('/assets/charts?v=2 .js', function() {\n  console.log('script loaded');\n});\n```\n\n## Eine Datei nur einmal laden\n\nJeder Aufruf von `IMPORT()` lädt die Datei erneut. Das lässt sich auf zwei Arten vermeiden.\n\nDas Flag `@singleton` lädt ein Skript oder Stylesheet nur einmal, egal wie oft es angefordert wird:\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nEine globale Variable in spitzen Klammern überspringt den Download, wenn diese Variable bereits existiert:\n\n```js\nIMPORT('<CHARTS> /js/charts.js', function() {\n  console.log('CHARTS is available');\n});\n```\n\nBei HTML lädt `@singleton` den Inhalt einmal herunter, und jeder Aufruf fügt die aufbewahrte Kopie in sein Ziel ein.\n\n## HTML-Teile\n\nHeruntergeladenes HTML wird an das Ziel angehängt. Das Flag `@prepend` fügt es am Anfang ein. `<style>`-Blöcke wandern in den `<head>`, und `<script src>`-Tags werden dem `<head>` einmal hinzugefügt.\n\n```js\n// /parts/note.html contains:\n// <style>.note { color: green; }</style><p class=\"note\">Imported</p>\n\nIMPORT('/parts/note.html', '#content', function() {\n  console.log($('#content').html());\n});\n\nIMPORT('/parts/note.html @prepend', '#side', function() {\n  console.log($('#side').html());\n});\n```\n\n```text\n<p>Existing</p><p class=\"note\">Imported</p>\n<p class=\"note\">Imported</p><p>Existing</p>\n```\n\nDie Funktion `prepare` ändert den Inhalt vor dem Einfügen:\n\n```js\n// /parts/hello.html contains: <p>Hello NAME</p>\n\nIMPORT('/parts/hello.html', '#third', function() {\n  console.log($('#third').html()); // <p>Hello Ann</p>\n}, function(html) {\n  return html.replace('NAME', 'Ann');\n});\n```\n\n## Platzhalter in importiertem HTML\n\nImportiertes HTML kann diese Platzhalter verwenden:\n\n| Platzhalter | Wird ersetzt durch |\n| --- | --- |\n| `@(text)` | Die Übersetzung des Textes. Siehe [Lokalisierung](../localization/). |\n| `--name=value--` | Nichts. Es definiert eine Variable für die Datei. |\n| `--name--` | Den Wert der in der Datei definierten Variable. |\n| `~CDN~` | Den Wert von `DEF.cdn`. |\n\n```js\nDEF.cdn = 'https://cdn.example.com';\nLOCALIZE(HASH('Welcome').toString(36) + ' : Vitajte');\n\n// /parts/welcome.html contains:\n// --color=red--<p style=\"color:--color--\"><img src=\"~CDN~/logo.png\" />@(Welcome)</p>\n\nIMPORT('/parts/welcome.html', '#target', function() {\n  console.log($('#target').html());\n});\n```\n\n```text\n<p style=\"color:red\"><img src=\"https://cdn.example.com/logo.png\">Vitajte</p>\n```\n\n## Das Element ui-import\n\n`<ui-import>` importiert Inhalte in sich selbst, sobald es auf der Seite erscheint. Die URL steht im Attribut `path` oder im Konfigurationsschlüssel `url`.\n\n| Konfiguration | Beschreibung |\n| --- | --- |\n| `url` | Die Adresse, wenn das Attribut `path` nicht verwendet wird. |\n| `target` | Ein Selektor des Elements, das den Inhalt erhält. Standard ist das Element selbst. |\n| `path` | Der Wert für `~PATH~` und `CLASS` im Inhalt. |\n| `id` | Der Wert für `~ID~` im Inhalt. |\n| `init` | Der Name einer Funktion, die aufgerufen wird, wenn der Inhalt geladen ist. |\n| `class` | CSS-Klassen, die am Ziel umgeschaltet werden, wenn der Inhalt geladen ist. |\n\nDie Bibliothek schreibt eine Warnung mit der URL in die Konsole, wenn sie den Inhalt eines `<ui-import>` zum ersten Mal herunterlädt.\n\n## Ein Plugin importieren\n\nMit dem Schlüssel `path` lässt sich eine Datei für jedes beliebige Plugin verwenden. `<ui-plugin>` erhält den Path, und `PLUGIN(function...)` wird darunter registriert:\n\n```html\n<!-- /parts/invoice.html -->\n<ui-plugin><b id=\"~ID~\">~PATH~</b></ui-plugin>\n<script>\nPLUGIN(function(exports) {\n  exports.make = function() {\n    console.log('plugin', exports.name);\n  };\n});\n</script>\n```\n\n```html\n<ui-import path=\"/parts/invoice.html\" config=\"path:invoice;id:title;init:FUNC.imported;class:ready\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n  console.log('init');\n};\n</script>\n```\n\n```text\nplugin invoice\ninit\n```\n\nDas Element `#title` enthält den Text `invoice`, `<ui-import>` hat die Klasse `ready`, und die Instanz ist als `PLUGINS.invoice` verfügbar. Mehr über Plugins erfährst du unter [Plugins](../plugins/).\n\n## Erfahren, wann Inhalt importiert wurde\n\nDas globale Event `import` wird nach jedem Import mit der URL und dem Ziel ausgelöst. Bei einem Skript oder Stylesheet ist das zweite Argument das neue Element:\n\n```js\nON('import', function(url, target) {\n  console.log(url);\n});\n```\n\n## Anfragen für HTML\n\nHTML wird mit `AJAX()` heruntergeladen, die Anfrage enthält also die in `DEF.language` gesetzte Sprache, und eine URL, die auf `.html` endet, enthält zusätzlich `DEF.version`. Siehe [Lokalisierung](../localization/).\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:57.302Z"}
{"id":"JamcNR1qd61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/importing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Importar contenido","summary":"Cómo cargar scripts, hojas de estilos y fragmentos HTML en una página en ejecución con IMPORT() y el elemento ui-import.","markdown":"---\ntitle: Importar contenido\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/importing/\nupdated: 2026-11-22T18:41:57.302Z\n---\n\n# Importar contenido\n\n> Cómo cargar scripts, hojas de estilos y fragmentos HTML en una página en ejecución con IMPORT() y el elemento ui-import.\n\nUna aplicación no tiene que cargarlo todo al arrancar. `IMPORT()` carga un script, una hoja de estilos o una parte de una página cuando hace falta, y el elemento `<ui-import>` hace lo mismo desde el marcado.\n\n## IMPORT()\n\n`IMPORT(url, [target], [callback], [prepare])` decide qué hacer según la extensión de la URL:\n\n| Extensión | Resultado |\n| --- | --- |\n| `.js` | Añade un `<script>` al `<head>`. |\n| `.css` | Añade un `<link>` al `<head>`. |\n| Cualquier otra | Descarga el contenido como HTML y lo inserta en `target`. |\n\n| Argumento | Descripción |\n| --- | --- |\n| `url` | La dirección, con flags opcionales. |\n| `target` | Un selector o un elemento para el contenido HTML. El valor predeterminado es `body`. |\n| `callback` | Una función a la que se llama cuando se ha cargado el contenido. |\n| `prepare` | Una función que recibe el HTML descargado y devuelve el HTML que se va a insertar. |\n\n## Scripts y hojas de estilos\n\n```js\nIMPORT('/js/charts.js', function() {\n  console.log('script', window.CHARTS);\n});\n\nIMPORT('/css/charts.css', function() {\n  console.log('style loaded');\n});\n```\n\nEl callback se ejecuta cuando se ha cargado el archivo. Si un script o una hoja de estilos no se pueden cargar, la biblioteca escribe un aviso en la consola y el callback se ejecuta igualmente.\n\nCuando la URL no tiene extensión, indica el tipo tras un espacio:\n\n```js\nIMPORT('/assets/charts?v=2 .js', function() {\n  console.log('script loaded');\n});\n```\n\n## Cargar un archivo una sola vez\n\nCada llamada a `IMPORT()` vuelve a cargar el archivo. Hay dos formas de evitarlo.\n\nEl flag `@singleton` carga un script o una hoja de estilos una sola vez, por muchas veces que se solicite:\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nUna variable global entre corchetes angulares omite la descarga cuando esa variable ya existe:\n\n```js\nIMPORT('<CHARTS> /js/charts.js', function() {\n  console.log('CHARTS is available');\n});\n```\n\nEn el caso del HTML, `@singleton` descarga el contenido una vez, y cada llamada inserta la copia guardada en su destino.\n\n## Fragmentos HTML\n\nEl HTML descargado se añade al final del destino. El flag `@prepend` lo inserta al principio. Los bloques `<style>` se mueven al `<head>`, y las etiquetas `<script src>` se añaden al `<head>` una sola vez.\n\n```js\n// /parts/note.html contains:\n// <style>.note { color: green; }</style><p class=\"note\">Imported</p>\n\nIMPORT('/parts/note.html', '#content', function() {\n  console.log($('#content').html());\n});\n\nIMPORT('/parts/note.html @prepend', '#side', function() {\n  console.log($('#side').html());\n});\n```\n\n```text\n<p>Existing</p><p class=\"note\">Imported</p>\n<p class=\"note\">Imported</p><p>Existing</p>\n```\n\nLa función `prepare` cambia el contenido antes de insertarlo:\n\n```js\n// /parts/hello.html contains: <p>Hello NAME</p>\n\nIMPORT('/parts/hello.html', '#third', function() {\n  console.log($('#third').html()); // <p>Hello Ann</p>\n}, function(html) {\n  return html.replace('NAME', 'Ann');\n});\n```\n\n## Marcadores en el HTML importado\n\nEl HTML importado puede usar estos marcadores:\n\n| Marcador | Se sustituye por |\n| --- | --- |\n| `@(text)` | La traducción del texto. Consulta [Localización](../localization/). |\n| `--name=value--` | Nada. Define una variable para el archivo. |\n| `--name--` | El valor de la variable definida en el archivo. |\n| `~CDN~` | El valor de `DEF.cdn`. |\n\n```js\nDEF.cdn = 'https://cdn.example.com';\nLOCALIZE(HASH('Welcome').toString(36) + ' : Vitajte');\n\n// /parts/welcome.html contains:\n// --color=red--<p style=\"color:--color--\"><img src=\"~CDN~/logo.png\" />@(Welcome)</p>\n\nIMPORT('/parts/welcome.html', '#target', function() {\n  console.log($('#target').html());\n});\n```\n\n```text\n<p style=\"color:red\"><img src=\"https://cdn.example.com/logo.png\">Vitajte</p>\n```\n\n## El elemento ui-import\n\n`<ui-import>` importa contenido en sí mismo en cuanto aparece en la página. La URL va en el atributo `path` o en la clave de configuración `url`.\n\n| Configuración | Descripción |\n| --- | --- |\n| `url` | La dirección, cuando no se usa el atributo `path`. |\n| `target` | Un selector del elemento que recibe el contenido. El valor predeterminado es el propio elemento. |\n| `path` | El valor de `~PATH~` y `CLASS` en el contenido. |\n| `id` | El valor de `~ID~` en el contenido. |\n| `init` | El nombre de una función a la que se llama cuando se ha cargado el contenido. |\n| `class` | Clases CSS que se alternan en el destino cuando se ha cargado el contenido. |\n\nLa biblioteca escribe en la consola una advertencia con la URL la primera vez que descarga el contenido de un `<ui-import>`.\n\n## Importar un plugin\n\nCon la clave `path`, un mismo archivo sirve para cualquier plugin. `<ui-plugin>` recibe el path y `PLUGIN(function...)` se registra bajo él:\n\n```html\n<!-- /parts/invoice.html -->\n<ui-plugin><b id=\"~ID~\">~PATH~</b></ui-plugin>\n<script>\nPLUGIN(function(exports) {\n  exports.make = function() {\n    console.log('plugin', exports.name);\n  };\n});\n</script>\n```\n\n```html\n<ui-import path=\"/parts/invoice.html\" config=\"path:invoice;id:title;init:FUNC.imported;class:ready\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n  console.log('init');\n};\n</script>\n```\n\n```text\nplugin invoice\ninit\n```\n\nEl elemento `#title` contiene el texto `invoice`, `<ui-import>` tiene la clase `ready` y la instancia está disponible como `PLUGINS.invoice`. Lee más sobre los plugins en [Plugins](../plugins/).\n\n## Saber cuándo se ha importado el contenido\n\nEl evento global `import` se emite después de cada importación con la URL y el destino. En el caso de un script o una hoja de estilos, el segundo argumento es el nuevo elemento:\n\n```js\nON('import', function(url, target) {\n  console.log(url);\n});\n```\n\n## Peticiones de HTML\n\nEl HTML se descarga con `AJAX()`, así que la petición lleva el idioma establecido en `DEF.language`, y una URL que termina en `.html` lleva además `DEF.version`. Consulta [Localización](../localization/).\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:57.302Z"}
{"id":"JamcNR1qd61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/importing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Importer du contenu","summary":"Comment charger des scripts, des feuilles de style et des fragments HTML dans une page en cours d'exécution avec IMPORT() et l'élément ui-import.","markdown":"---\ntitle: Importer du contenu\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/importing/\nupdated: 2026-11-22T18:41:57.302Z\n---\n\n# Importer du contenu\n\n> Comment charger des scripts, des feuilles de style et des fragments HTML dans une page en cours d'exécution avec IMPORT() et l'élément ui-import.\n\nUne application n'a pas besoin de tout charger au démarrage. `IMPORT()` charge un script, une feuille de style ou une partie de page au moment où tu en as besoin, et l'élément `<ui-import>` fait la même chose depuis le balisage.\n\n## IMPORT()\n\n`IMPORT(url, [target], [callback], [prepare])` décide quoi faire selon l'extension de l'URL :\n\n| Extension | Résultat |\n| --- | --- |\n| `.js` | Ajoute un `<script>` dans le `<head>`. |\n| `.css` | Ajoute un `<link>` dans le `<head>`. |\n| Tout le reste | Télécharge le contenu au format HTML et l'insère dans `target`. |\n\n| Argument | Description |\n| --- | --- |\n| `url` | L'adresse, avec des flags facultatifs. |\n| `target` | Un sélecteur ou un élément pour le contenu HTML. La valeur par défaut est `body`. |\n| `callback` | Une fonction appelée quand le contenu est chargé. |\n| `prepare` | Une fonction qui reçoit le HTML téléchargé et renvoie le HTML à insérer. |\n\n## Scripts et feuilles de style\n\n```js\nIMPORT('/js/charts.js', function() {\n  console.log('script', window.CHARTS);\n});\n\nIMPORT('/css/charts.css', function() {\n  console.log('style loaded');\n});\n```\n\nLe callback s'exécute une fois le fichier chargé. Si un script ou une feuille de style ne peut pas être chargé, la bibliothèque écrit un avertissement dans la console et le callback s'exécute quand même.\n\nQuand l'URL n'a pas d'extension, indique le type après une espace :\n\n```js\nIMPORT('/assets/charts?v=2 .js', function() {\n  console.log('script loaded');\n});\n```\n\n## Charger un fichier une seule fois\n\nChaque appel à `IMPORT()` charge de nouveau le fichier. Il existe deux façons de l'éviter.\n\nLe flag `@singleton` ne charge un script ou une feuille de style qu'une seule fois, quel que soit le nombre de demandes :\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nUne variable globale entre chevrons évite le téléchargement quand cette variable existe déjà :\n\n```js\nIMPORT('<CHARTS> /js/charts.js', function() {\n  console.log('CHARTS is available');\n});\n```\n\nPour le HTML, `@singleton` télécharge le contenu une seule fois, et chaque appel insère la copie conservée dans sa cible.\n\n## Fragments HTML\n\nLe HTML téléchargé est ajouté à la fin de la cible. Le flag `@prepend` l'insère au début. Les blocs `<style>` sont déplacés dans le `<head>`, et les balises `<script src>` sont ajoutées une seule fois au `<head>`.\n\n```js\n// /parts/note.html contains:\n// <style>.note { color: green; }</style><p class=\"note\">Imported</p>\n\nIMPORT('/parts/note.html', '#content', function() {\n  console.log($('#content').html());\n});\n\nIMPORT('/parts/note.html @prepend', '#side', function() {\n  console.log($('#side').html());\n});\n```\n\n```text\n<p>Existing</p><p class=\"note\">Imported</p>\n<p class=\"note\">Imported</p><p>Existing</p>\n```\n\nLa fonction `prepare` modifie le contenu avant son insertion :\n\n```js\n// /parts/hello.html contains: <p>Hello NAME</p>\n\nIMPORT('/parts/hello.html', '#third', function() {\n  console.log($('#third').html()); // <p>Hello Ann</p>\n}, function(html) {\n  return html.replace('NAME', 'Ann');\n});\n```\n\n## Espaces réservés dans le HTML importé\n\nLe HTML importé peut utiliser ces espaces réservés :\n\n| Espace réservé | Remplacé par |\n| --- | --- |\n| `@(text)` | La traduction du texte. Consulte [Localisation](../localization/). |\n| `--name=value--` | Rien. Il définit une variable pour le fichier. |\n| `--name--` | La valeur de la variable définie dans le fichier. |\n| `~CDN~` | La valeur de `DEF.cdn`. |\n\n```js\nDEF.cdn = 'https://cdn.example.com';\nLOCALIZE(HASH('Welcome').toString(36) + ' : Vitajte');\n\n// /parts/welcome.html contains:\n// --color=red--<p style=\"color:--color--\"><img src=\"~CDN~/logo.png\" />@(Welcome)</p>\n\nIMPORT('/parts/welcome.html', '#target', function() {\n  console.log($('#target').html());\n});\n```\n\n```text\n<p style=\"color:red\"><img src=\"https://cdn.example.com/logo.png\">Vitajte</p>\n```\n\n## L'élément ui-import\n\n`<ui-import>` importe du contenu en lui-même dès qu'il apparaît dans la page. L'URL se place dans l'attribut `path` ou dans la clé de configuration `url`.\n\n| Configuration | Description |\n| --- | --- |\n| `url` | L'adresse, quand l'attribut `path` n'est pas utilisé. |\n| `target` | Un sélecteur de l'élément qui reçoit le contenu. Par défaut, c'est l'élément lui-même. |\n| `path` | La valeur de `~PATH~` et de `CLASS` dans le contenu. |\n| `id` | La valeur de `~ID~` dans le contenu. |\n| `init` | Le nom d'une fonction à appeler quand le contenu est chargé. |\n| `class` | Les classes CSS à basculer sur la cible quand le contenu est chargé. |\n\nLa bibliothèque écrit un avertissement contenant l'URL dans la console la première fois qu'elle télécharge le contenu d'un `<ui-import>`.\n\n## Importer un plugin\n\nAvec la clé `path`, un même fichier peut servir pour n'importe quel plugin. `<ui-plugin>` reçoit le path et `PLUGIN(function...)` est enregistré sous celui-ci :\n\n```html\n<!-- /parts/invoice.html -->\n<ui-plugin><b id=\"~ID~\">~PATH~</b></ui-plugin>\n<script>\nPLUGIN(function(exports) {\n  exports.make = function() {\n    console.log('plugin', exports.name);\n  };\n});\n</script>\n```\n\n```html\n<ui-import path=\"/parts/invoice.html\" config=\"path:invoice;id:title;init:FUNC.imported;class:ready\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n  console.log('init');\n};\n</script>\n```\n\n```text\nplugin invoice\ninit\n```\n\nL'élément `#title` contient le texte `invoice`, `<ui-import>` a la classe `ready` et l'instance est disponible sous le nom `PLUGINS.invoice`. Pour en savoir plus sur les plugins, lis [Plugins](../plugins/).\n\n## Savoir quand le contenu est importé\n\nL'événement global `import` est émis après chaque importation avec l'URL et la cible. Pour un script ou une feuille de style, le second argument est le nouvel élément :\n\n```js\nON('import', function(url, target) {\n  console.log(url);\n});\n```\n\n## Requêtes effectuées pour le HTML\n\nLe HTML est téléchargé avec `AJAX()` : la requête transporte donc la langue définie dans `DEF.language`, et une URL se terminant par `.html` transporte aussi `DEF.version`. Consulte [Localisation](../localization/).\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:57.302Z"}
{"id":"JamcNR1qd61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/importing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Importare contenuti","summary":"Come caricare script, fogli di stile e parti HTML in una pagina in esecuzione con IMPORT() e l'elemento ui-import.","markdown":"---\ntitle: Importare contenuti\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/importing/\nupdated: 2026-11-22T18:41:57.302Z\n---\n\n# Importare contenuti\n\n> Come caricare script, fogli di stile e parti HTML in una pagina in esecuzione con IMPORT() e l'elemento ui-import.\n\nUn'applicazione non deve caricare tutto all'avvio. `IMPORT()` carica uno script, un foglio di stile o una parte di pagina quando serve, e l'elemento `<ui-import>` fa lo stesso dal markup.\n\n## IMPORT()\n\n`IMPORT(url, [target], [callback], [prepare])` decide che cosa fare in base all'estensione dell'URL:\n\n| Estensione | Risultato |\n| --- | --- |\n| `.js` | Aggiunge uno `<script>` a `<head>`. |\n| `.css` | Aggiunge un `<link>` a `<head>`. |\n| Qualsiasi altra | Scarica il contenuto come HTML e lo inserisce in `target`. |\n\n| Argomento | Descrizione |\n| --- | --- |\n| `url` | L'indirizzo, con flag facoltativi. |\n| `target` | Un selettore o un elemento per il contenuto HTML. Il valore predefinito è `body`. |\n| `callback` | Una funzione chiamata quando il contenuto è stato caricato. |\n| `prepare` | Una funzione che riceve l'HTML scaricato e restituisce l'HTML da inserire. |\n\n## Script e fogli di stile\n\n```js\nIMPORT('/js/charts.js', function() {\n  console.log('script', window.CHARTS);\n});\n\nIMPORT('/css/charts.css', function() {\n  console.log('style loaded');\n});\n```\n\nLa callback viene eseguita dopo il caricamento del file. Se uno script o un foglio di stile non può essere caricato, la libreria scrive un avviso nella console e la callback viene eseguita comunque.\n\nQuando l'URL non ha un'estensione, indica il tipo dopo uno spazio:\n\n```js\nIMPORT('/assets/charts?v=2 .js', function() {\n  console.log('script loaded');\n});\n```\n\n## Caricare un file una sola volta\n\nOgni chiamata a `IMPORT()` carica di nuovo il file. Puoi evitarlo in due modi.\n\nIl flag `@singleton` carica uno script o un foglio di stile una sola volta, indipendentemente da quante volte viene richiesto:\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nUna variabile globale tra parentesi angolari salta il download quando quella variabile esiste già:\n\n```js\nIMPORT('<CHARTS> /js/charts.js', function() {\n  console.log('CHARTS is available');\n});\n```\n\nPer l'HTML, `@singleton` scarica il contenuto una sola volta e ogni chiamata inserisce la copia conservata nella propria destinazione.\n\n## Parti HTML\n\nL'HTML scaricato viene aggiunto in fondo alla destinazione. Il flag `@prepend` lo inserisce all'inizio. I blocchi `<style>` vengono spostati in `<head>` e i tag `<script src>` vengono aggiunti a `<head>` una sola volta.\n\n```js\n// /parts/note.html contains:\n// <style>.note { color: green; }</style><p class=\"note\">Imported</p>\n\nIMPORT('/parts/note.html', '#content', function() {\n  console.log($('#content').html());\n});\n\nIMPORT('/parts/note.html @prepend', '#side', function() {\n  console.log($('#side').html());\n});\n```\n\n```text\n<p>Existing</p><p class=\"note\">Imported</p>\n<p class=\"note\">Imported</p><p>Existing</p>\n```\n\nLa funzione `prepare` modifica il contenuto prima che venga inserito:\n\n```js\n// /parts/hello.html contains: <p>Hello NAME</p>\n\nIMPORT('/parts/hello.html', '#third', function() {\n  console.log($('#third').html()); // <p>Hello Ann</p>\n}, function(html) {\n  return html.replace('NAME', 'Ann');\n});\n```\n\n## Segnaposto nell'HTML importato\n\nL'HTML importato può usare questi segnaposto:\n\n| Segnaposto | Sostituito con |\n| --- | --- |\n| `@(text)` | La traduzione del testo. Consulta [Localizzazione](../localization/). |\n| `--name=value--` | Niente. Definisce una variabile per il file. |\n| `--name--` | Il valore della variabile definita nel file. |\n| `~CDN~` | Il valore di `DEF.cdn`. |\n\n```js\nDEF.cdn = 'https://cdn.example.com';\nLOCALIZE(HASH('Welcome').toString(36) + ' : Vitajte');\n\n// /parts/welcome.html contains:\n// --color=red--<p style=\"color:--color--\"><img src=\"~CDN~/logo.png\" />@(Welcome)</p>\n\nIMPORT('/parts/welcome.html', '#target', function() {\n  console.log($('#target').html());\n});\n```\n\n```text\n<p style=\"color:red\"><img src=\"https://cdn.example.com/logo.png\">Vitajte</p>\n```\n\n## L'elemento ui-import\n\n`<ui-import>` importa il contenuto al proprio interno non appena compare nella pagina. L'URL va nell'attributo `path` o nella chiave di configurazione `url`.\n\n| Configurazione | Descrizione |\n| --- | --- |\n| `url` | L'indirizzo, quando non usi l'attributo `path`. |\n| `target` | Il selettore dell'elemento che riceve il contenuto. Il valore predefinito è l'elemento stesso. |\n| `path` | Il valore per `~PATH~` e `CLASS` nel contenuto. |\n| `id` | Il valore per `~ID~` nel contenuto. |\n| `init` | Il nome di una funzione da chiamare quando il contenuto è stato caricato. |\n| `class` | Le classi CSS da alternare sulla destinazione quando il contenuto è stato caricato. |\n\nLa prima volta che scarica il contenuto di un `<ui-import>`, la libreria scrive nella console un avviso con l'URL.\n\n## Importare un plugin\n\nCon la chiave `path`, un solo file può servire per qualsiasi plugin. `<ui-plugin>` riceve il path e `PLUGIN(function...)` viene registrato con quel path:\n\n```html\n<!-- /parts/invoice.html -->\n<ui-plugin><b id=\"~ID~\">~PATH~</b></ui-plugin>\n<script>\nPLUGIN(function(exports) {\n  exports.make = function() {\n    console.log('plugin', exports.name);\n  };\n});\n</script>\n```\n\n```html\n<ui-import path=\"/parts/invoice.html\" config=\"path:invoice;id:title;init:FUNC.imported;class:ready\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n  console.log('init');\n};\n</script>\n```\n\n```text\nplugin invoice\ninit\n```\n\nL'elemento `#title` contiene il testo `invoice`, `<ui-import>` ha la classe `ready` e l'istanza è disponibile come `PLUGINS.invoice`. Approfondisci i plugin in [Plugin](../plugins/).\n\n## Sapere quando il contenuto è stato importato\n\nL'evento globale `import` viene emesso dopo ogni importazione con l'URL e la destinazione. Per uno script o un foglio di stile, il secondo argomento è il nuovo elemento:\n\n```js\nON('import', function(url, target) {\n  console.log(url);\n});\n```\n\n## Richieste per l'HTML\n\nL'HTML viene scaricato con `AJAX()`, quindi la richiesta contiene la lingua impostata in `DEF.language` e un URL che termina con `.html` contiene anche `DEF.version`. Consulta [Localizzazione](../localization/).\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:57.302Z"}
{"id":"JamcNR1qd61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/importing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Import obsahu","summary":"Ako do bežiacej stránky načítať skripty, štýly a časti HTML pomocou IMPORT() a elementu ui-import.","markdown":"---\ntitle: Import obsahu\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/importing/\nupdated: 2026-11-22T18:41:57.302Z\n---\n\n# Import obsahu\n\n> Ako do bežiacej stránky načítať skripty, štýly a časti HTML pomocou IMPORT() a elementu ui-import.\n\nAplikácia nemusí načítať všetko hneď pri štarte. `IMPORT()` načíta skript, štýl alebo časť stránky až vtedy, keď sú potrebné, a element `<ui-import>` robí to isté priamo zo značkovania.\n\n## IMPORT()\n\n`IMPORT(url, [target], [callback], [prepare])` sa podľa prípony URL rozhodne, čo urobí:\n\n| Prípona | Výsledok |\n| --- | --- |\n| `.js` | Pridá `<script>` do `<head>`. |\n| `.css` | Pridá `<link>` do `<head>`. |\n| Čokoľvek iné | Stiahne obsah ako HTML a vloží ho do `target`. |\n\n| Argument | Popis |\n| --- | --- |\n| `url` | Adresa, voliteľne s flagmi. |\n| `target` | Selektor alebo element pre HTML obsah. Predvolene `body`. |\n| `callback` | Funkcia zavolaná po načítaní obsahu. |\n| `prepare` | Funkcia, ktorá dostane stiahnuté HTML a vráti HTML na vloženie. |\n\n## Skripty a štýly\n\n```js\nIMPORT('/js/charts.js', function() {\n  console.log('script', window.CHARTS);\n});\n\nIMPORT('/css/charts.css', function() {\n  console.log('style loaded');\n});\n```\n\nCallback sa spustí po načítaní súboru. Ak sa skript alebo štýl nepodarí načítať, knižnica zapíše do konzoly varovanie a callback sa aj tak spustí.\n\nKeď URL nemá príponu, uveď typ za medzerou:\n\n```js\nIMPORT('/assets/charts?v=2 .js', function() {\n  console.log('script loaded');\n});\n```\n\n## Jednorazové načítanie súboru\n\nKaždé volanie `IMPORT()` načíta súbor znova. Dá sa tomu vyhnúť dvoma spôsobmi.\n\nFlag `@singleton` načíta skript alebo štýl iba raz, bez ohľadu na to, koľkokrát si ho vyžiadaš:\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nGlobálna premenná v lomených zátvorkách preskočí sťahovanie, keď už daná premenná existuje:\n\n```js\nIMPORT('<CHARTS> /js/charts.js', function() {\n  console.log('CHARTS is available');\n});\n```\n\nPri HTML stiahne `@singleton` obsah raz a každé volanie vloží uloženú kópiu do svojho cieľa.\n\n## Časti HTML\n\nStiahnuté HTML sa pridá na koniec cieľa. Flag `@prepend` ho vloží na začiatok. Bloky `<style>` sa presunú do `<head>` a značky `<script src>` sa do `<head>` pridajú raz.\n\n```js\n// /parts/note.html contains:\n// <style>.note { color: green; }</style><p class=\"note\">Imported</p>\n\nIMPORT('/parts/note.html', '#content', function() {\n  console.log($('#content').html());\n});\n\nIMPORT('/parts/note.html @prepend', '#side', function() {\n  console.log($('#side').html());\n});\n```\n\n```text\n<p>Existing</p><p class=\"note\">Imported</p>\n<p class=\"note\">Imported</p><p>Existing</p>\n```\n\nFunkcia `prepare` upraví obsah pred vložením:\n\n```js\n// /parts/hello.html contains: <p>Hello NAME</p>\n\nIMPORT('/parts/hello.html', '#third', function() {\n  console.log($('#third').html()); // <p>Hello Ann</p>\n}, function(html) {\n  return html.replace('NAME', 'Ann');\n});\n```\n\n## Zástupné symboly v importovanom HTML\n\nImportované HTML môže používať tieto zástupné symboly:\n\n| Zástupný symbol | Nahradí sa |\n| --- | --- |\n| `@(text)` | Prekladom textu. Pozri [Lokalizácia](../localization/). |\n| `--name=value--` | Ničím. Definuje premennú pre súbor. |\n| `--name--` | Hodnotou premennej definovanej v súbore. |\n| `~CDN~` | Hodnotou `DEF.cdn`. |\n\n```js\nDEF.cdn = 'https://cdn.example.com';\nLOCALIZE(HASH('Welcome').toString(36) + ' : Vitajte');\n\n// /parts/welcome.html contains:\n// --color=red--<p style=\"color:--color--\"><img src=\"~CDN~/logo.png\" />@(Welcome)</p>\n\nIMPORT('/parts/welcome.html', '#target', function() {\n  console.log($('#target').html());\n});\n```\n\n```text\n<p style=\"color:red\"><img src=\"https://cdn.example.com/logo.png\">Vitajte</p>\n```\n\n## Element ui-import\n\n`<ui-import>` importuje obsah do seba hneď, ako sa objaví na stránke. URL patrí do atribútu `path` alebo do konfiguračného kľúča `url`.\n\n| Konfigurácia | Popis |\n| --- | --- |\n| `url` | Adresa, keď sa nepoužije atribút `path`. |\n| `target` | Selektor elementu, ktorý dostane obsah. Predvolene je to samotný element. |\n| `path` | Hodnota pre `~PATH~` a `CLASS` v obsahu. |\n| `id` | Hodnota pre `~ID~` v obsahu. |\n| `init` | Názov funkcie, ktorá sa zavolá po načítaní obsahu. |\n| `class` | CSS triedy, ktoré sa na cieli prepnú po načítaní obsahu. |\n\nPri prvom stiahnutí obsahu elementu `<ui-import>` zapíše knižnica do konzoly varovanie s URL.\n\n## Import pluginu\n\nVďaka kľúču `path` môžeš jeden súbor použiť pre ľubovoľný plugin. `<ui-plugin>` dostane path a `PLUGIN(function...)` sa pod ňou zaregistruje:\n\n```html\n<!-- /parts/invoice.html -->\n<ui-plugin><b id=\"~ID~\">~PATH~</b></ui-plugin>\n<script>\nPLUGIN(function(exports) {\n  exports.make = function() {\n    console.log('plugin', exports.name);\n  };\n});\n</script>\n```\n\n```html\n<ui-import path=\"/parts/invoice.html\" config=\"path:invoice;id:title;init:FUNC.imported;class:ready\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n  console.log('init');\n};\n</script>\n```\n\n```text\nplugin invoice\ninit\n```\n\nElement `#title` obsahuje text `invoice`, `<ui-import>` má triedu `ready` a inštancia je dostupná ako `PLUGINS.invoice`. Viac o pluginoch sa dočítaš v časti [Pluginy](../plugins/).\n\n## Ako zistiť, že sa obsah naimportoval\n\nPo každom importe sa vyšle globálna udalosť `import` s URL a cieľom. Pri skripte alebo štýle je druhým argumentom nový element:\n\n```js\nON('import', function(url, target) {\n  console.log(url);\n});\n```\n\n## Požiadavky na HTML\n\nHTML sa sťahuje cez `AJAX()`, takže požiadavka nesie jazyk nastavený v `DEF.language` a URL končiaca na `.html` nesie aj `DEF.version`. Pozri [Lokalizácia](../localization/).\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:57.302Z"}
{"id":"JamcNk22d61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/tangular/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Templates with Tangular","summary":"How to write templates with Tangular: values, conditions, loops and helpers.","markdown":"---\ntitle: Templates with Tangular\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/tangular/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Templates with Tangular\n\n> How to write templates with Tangular: values, conditions, loops and helpers.\n\nTangular is the template engine included in the library. It turns a template and a data object into an HTML string. Templates are compiled to JavaScript functions, so one template can render many times.\n\n## Rendering a template\n\n`Tangular.render(template, [model], [repository], [helpers])` compiles and renders in one step. `Tangular.compile(template)` returns a function to use repeatedly.\n\n```js\nvar html = Tangular.render('<h1>{{ title }}</h1><p>{{ user.name }}</p>', { title: 'Team', user: { name: 'Ann' } });\nconsole.log(html);\n\nvar template = Tangular.compile('Hello {{ name }}!');\nconsole.log(template({ name: 'Ann' }));\nconsole.log(template({ name: 'Bob' }));\n```\n\n```text\n<h1>Team</h1><p>Ann</p>\nHello Ann!\nHello Bob!\n```\n\nA compiled template is called as `template(model, [repository], [helpers])`. `Ta` is a short alias of `Tangular`.\n\n## Values\n\n`{{ name }}` prints a value of the model. The output is HTML-encoded. The `raw` helper prints the value as it is, so use it only for HTML you trust.\n\n```js\nvar model = { name: '<b>Ann</b>', age: 30, user: { address: null }, score: 0, note: null };\n\nTangular.render('{{ name }}', model);                       // &lt;b&gt;Ann&lt;/b&gt;\nTangular.render('{{ name | raw }}', model);                 // <b>Ann</b>\nTangular.render('[{{ user.address.city }}]', model);        // []\nTangular.render('{{ score }}|{{ note }}|{{ age + 1 }}|{{ name.length }}', model); // 0||31|10\nTangular.render('{{ age > 18 ? \"adult\" : \"minor\" }}', model); // adult\n```\n\nA missing value prints nothing, and so does `null`. The number `0` is printed. A tag can hold a JavaScript expression over the values of the model.\n\n## Conditions\n\nA condition starts with `{{ if }}` and ends with `{{ fi }}`. `{{ else if }}` and `{{ else }}` are optional.\n\n```js\nvar template = Tangular.compile('{{ if age >= 65 }}senior{{ else if age >= 18 }}adult{{ else }}child{{ fi }}');\n\ntemplate({ age: 70 }); // senior\ntemplate({ age: 30 }); // adult\ntemplate({ age: 12 }); // child\n```\n\nA condition is plain JavaScript. Reading a property of a missing object is an error there, which is written to the console and leaves the result `undefined`. Check the object first:\n\n```js\nTangular.render('{{ if user && user.active }}on{{ else }}off{{ fi }}', {}); // off\n```\n\n## Loops\n\n`{{ foreach item in list }}` repeats its content until `{{ end }}`. `$index` holds the position of the current item.\n\n```js\nvar model = {\n  tags: ['red', 'green', 'blue'],\n  sizes: { s: 10, m: 20 },\n  groups: [{ name: 'A', items: [1, 2] }, { name: 'B', items: [3] }]\n};\n\nTangular.render('{{ foreach tag in tags }}{{ $index }}:{{ tag }} {{ end }}', model);\n// 0:red 1:green 2:blue\n\nTangular.render('{{ foreach m in sizes }}{{ m.key }}={{ m.value }} {{ end }}', model);\n// s=10 m=20\n\nTangular.render('{{ foreach g in groups }}{{ g.name }}({{ foreach n in g.items }}{{ n }}{{ end }}) {{ end }}', model);\n// A(12) B(3)\n```\n\nAn object is looped as a list of items with `key` and `value`. A missing or empty list renders nothing.\n\n`{{ continue }}` skips to the next item and `{{ break }}` ends the loop:\n\n```js\nTangular.render('{{ foreach tag in tags }}{{ if $index === 1 }}{{ continue }}{{ fi }}{{ tag }} {{ end }}', model);\n// red blue\n\nTangular.render('{{ foreach tag in tags }}{{ if $index === 2 }}{{ break }}{{ fi }}{{ tag }} {{ end }}', model);\n// red green\n```\n\nNested loops share one `$index`. After an inner loop finishes, `$index` keeps the last position of that inner loop until the outer loop moves on, so read the outer position ahead of the inner loop:\n\n```js\nvar model = { groups: [{ items: ['a', 'b', 'c'] }, { items: ['d'] }] };\n\nTangular.render('{{ foreach g in groups }}{{ $index }}:{{ foreach n in g.items }}{{ n }}{{ end }}:{{ $index }} {{ end }}', model);\n// 0:abc:2 1:d:0\n```\n\n## Helpers\n\nA helper transforms a value. It follows the value after a `|`, and helpers can be chained.\n\n| Helper | Description |\n| --- | --- |\n| `raw` | Prints the value without encoding. |\n| `encode([type])` | Encodes for HTML. The types `url`, `json`, `json2` and `querify` select another output. |\n| `format(...)` | Formats a number or a date. |\n| `pluralize(zero, one, few, other)` | Selects a text by a number. |\n| `empty([text])`, `def([text])` | Prints `text` or `DEF.empty` for an empty value. |\n| `currency([name])` | Formats a number with a currency from `DEF.currencies`. |\n| `cl(name, [key])` | Finds a label in the code list `DEF.cl[name]` by `id`. |\n\nThe arguments of each helper are described in [Tangular helpers](../../reference/tangular-helpers/).\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' EUR';\n};\nDEF.cl.status = [{ id: 1, name: 'Open' }, { id: 2, name: 'Closed' }];\n\nvar model = {\n  price: 1234.5,\n  created: new Date(2026, 0, 15, 10, 5),\n  count: 3,\n  note: '',\n  status: 2,\n  query: 'a b&c',\n  data: { a: 1 }\n};\n```\n\n| Template | Output |\n| --- | --- |\n| `{{ price \\| format(2) }}` | `1 234.50` |\n| `{{ created \\| format(\"yyyy-MM-dd HH:mm\") }}` | `2026-01-15 10:05` |\n| `{{ count \\| pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}` | `3 items` |\n| `{{ note \\| empty }}` | `---` |\n| `{{ note \\| empty(\"n/a\") }}` | `n/a` |\n| `{{ price \\| currency(\"eur\") }}` | `1 234.50 EUR` |\n| `{{ status \\| cl(\"status\") }}` | `Closed` |\n| `{{ query \\| encode(\"url\") }}` | `a%20b%26c` |\n| `{{ data \\| encode(\"json\") }}` | `{\"a\":1}` |\n\n## Custom helpers\n\n`Tangular.register(name, callback)` adds a helper for all templates. The first argument of the callback is the value, the next ones come from the template, and `this` is the model.\n\n```js\nTangular.register('initials', function(value) {\n  return value.split(' ').map(function(word) {\n    return word.charAt(0);\n  }).join('');\n});\n\nTangular.register('wrap', function(value, before, after) {\n  return before + value + after;\n});\n\nTangular.register('fullname', function(value) {\n  return this.first + ' ' + value;\n});\n\nvar model = { name: 'Ann Lee', first: 'Ann', last: 'Lee', html: '<i>' };\n\nTangular.render('{{ name | initials }}', model);             // AL\nTangular.render('{{ name | initials | wrap(\"[\", \"]\") }}', model); // [AL]\nTangular.render('{{ last | fullname }}', model);             // Ann Lee\n```\n\nThe output of a helper is not encoded. Add `encode` at the end of the chain when the value comes from a user:\n\n```js\nTangular.render('{{ html | wrap(\"\", \"\") }}', model);          // <i>\nTangular.render('{{ html | wrap(\"\", \"\") | encode }}', model); // &lt;i&gt;\n```\n\nHelpers for one call only go to the last argument of `render()`:\n\n```js\nvar helpers = { shout: function(value) { return value + '!'; } };\nTangular.render('{{ first | shout }}', model, null, helpers); // Ann!\n```\n\n## The repository\n\nThe repository is a second object for values that do not belong to the model. Templates read it through `$`:\n\n```js\nvar repository = { title: 'Users', limit: 2 };\n\nTangular.render('{{ $.title }}: {{ name }}', { name: 'Ann' }, repository);\n// Users: Ann\n\nvar template = Tangular.compile('{{ foreach n in items }}{{ if $index < $.limit }}{{ n }} {{ fi }}{{ end }}');\ntemplate({ items: ['a', 'b', 'c'] }, repository);\n// a b\n```\n\n## Custom delimiters\n\n`Tangular.compile(template, begin, end)` replaces `{{` and `}}`. Both values are parts of a regular expression, so special characters need escaping:\n\n```js\nvar template = Tangular.compile('[[ name ]] and {{ other }}', '\\\\[\\\\[', '\\\\]\\\\]');\ntemplate({ name: 'Ann' }); // Ann and {{ other }}\n```\n\n## Line breaks\n\nA line break directly in front of a tag and at the end of the template is removed:\n\n```js\nTangular.render('a\\n{{ name }}\\nb\\n', { name: 'X' }); // \"aX\\nb\"\n```\n\n## Templates in the page\n\nThe `template` command of `<ui-bind>` renders a Tangular template with the value of a path. Inside the template, the value is available as `value`, and the template renders again when the value changes.\n\n```html\n<ui-bind path=\"team\" config=\"template\">\n  <script type=\"text/html\">\n    <ul>{{ foreach m in value.people }}<li>{{ m.name }}</li>{{ end }}</ul>\n  </script>\n</ui-bind>\n\n<script>\nSET('team', { people: [{ name: 'Ann' }, { name: 'Bob' }] });\n</script>\n```\n\nThe element renders `<ul><li>Ann</li><li>Bob</li></ul>`. More about bindings is in [Data binding](../data-binding/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNk22d61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/tangular/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Templates mit Tangular","summary":"Wie du Templates mit Tangular schreibst: Werte, Bedingungen, Schleifen und Helper.","markdown":"---\ntitle: Templates mit Tangular\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/tangular/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Templates mit Tangular\n\n> Wie du Templates mit Tangular schreibst: Werte, Bedingungen, Schleifen und Helper.\n\nTangular ist die in der Bibliothek enthaltene Template-Engine. Damit wird aus einem Template und einem Datenobjekt ein HTML-String. Templates werden zu JavaScript-Funktionen kompiliert, ein Template kann also viele Male rendern.\n\n## Ein Template rendern\n\n`Tangular.render(template, [model], [repository], [helpers])` kompiliert und rendert in einem Schritt. `Tangular.compile(template)` gibt eine Funktion zur wiederholten Verwendung zurück.\n\n```js\nvar html = Tangular.render('<h1>{{ title }}</h1><p>{{ user.name }}</p>', { title: 'Team', user: { name: 'Ann' } });\nconsole.log(html);\n\nvar template = Tangular.compile('Hello {{ name }}!');\nconsole.log(template({ name: 'Ann' }));\nconsole.log(template({ name: 'Bob' }));\n```\n\n```text\n<h1>Team</h1><p>Ann</p>\nHello Ann!\nHello Bob!\n```\n\nEin kompiliertes Template wird als `template(model, [repository], [helpers])` aufgerufen. `Ta` ist ein kurzer Alias für `Tangular`.\n\n## Werte\n\n`{{ name }}` gibt einen Wert des Modells aus. Die Ausgabe ist HTML-kodiert. Der Helper `raw` gibt den Wert unverändert aus, verwende ihn also nur für HTML, dem du vertraust.\n\n```js\nvar model = { name: '<b>Ann</b>', age: 30, user: { address: null }, score: 0, note: null };\n\nTangular.render('{{ name }}', model);                       // &lt;b&gt;Ann&lt;/b&gt;\nTangular.render('{{ name | raw }}', model);                 // <b>Ann</b>\nTangular.render('[{{ user.address.city }}]', model);        // []\nTangular.render('{{ score }}|{{ note }}|{{ age + 1 }}|{{ name.length }}', model); // 0||31|10\nTangular.render('{{ age > 18 ? \"adult\" : \"minor\" }}', model); // adult\n```\n\nEin fehlender Wert gibt nichts aus, ebenso `null`. Die Zahl `0` wird ausgegeben. Ein Tag kann einen JavaScript-Ausdruck über die Werte des Modells enthalten.\n\n## Bedingungen\n\nEine Bedingung beginnt mit `{{ if }}` und endet mit `{{ fi }}`. `{{ else if }}` und `{{ else }}` sind optional.\n\n```js\nvar template = Tangular.compile('{{ if age >= 65 }}senior{{ else if age >= 18 }}adult{{ else }}child{{ fi }}');\n\ntemplate({ age: 70 }); // senior\ntemplate({ age: 30 }); // adult\ntemplate({ age: 12 }); // child\n```\n\nEine Bedingung ist normales JavaScript. Das Lesen einer Eigenschaft eines fehlenden Objekts ist dort ein Fehler, der in die Konsole geschrieben wird und das Ergebnis `undefined` hinterlässt. Prüfe zuerst das Objekt:\n\n```js\nTangular.render('{{ if user && user.active }}on{{ else }}off{{ fi }}', {}); // off\n```\n\n## Schleifen\n\n`{{ foreach item in list }}` wiederholt seinen Inhalt bis `{{ end }}`. `$index` enthält die Position des aktuellen Eintrags.\n\n```js\nvar model = {\n  tags: ['red', 'green', 'blue'],\n  sizes: { s: 10, m: 20 },\n  groups: [{ name: 'A', items: [1, 2] }, { name: 'B', items: [3] }]\n};\n\nTangular.render('{{ foreach tag in tags }}{{ $index }}:{{ tag }} {{ end }}', model);\n// 0:red 1:green 2:blue\n\nTangular.render('{{ foreach m in sizes }}{{ m.key }}={{ m.value }} {{ end }}', model);\n// s=10 m=20\n\nTangular.render('{{ foreach g in groups }}{{ g.name }}({{ foreach n in g.items }}{{ n }}{{ end }}) {{ end }}', model);\n// A(12) B(3)\n```\n\nEin Objekt wird als Liste von Einträgen mit `key` und `value` durchlaufen. Eine fehlende oder leere Liste rendert nichts.\n\n`{{ continue }}` springt zum nächsten Eintrag, und `{{ break }}` beendet die Schleife:\n\n```js\nTangular.render('{{ foreach tag in tags }}{{ if $index === 1 }}{{ continue }}{{ fi }}{{ tag }} {{ end }}', model);\n// red blue\n\nTangular.render('{{ foreach tag in tags }}{{ if $index === 2 }}{{ break }}{{ fi }}{{ tag }} {{ end }}', model);\n// red green\n```\n\nVerschachtelte Schleifen teilen sich ein `$index`. Nach dem Ende einer inneren Schleife behält `$index` deren letzte Position, bis die äußere Schleife weiterläuft. Lies die äußere Position also vor der inneren Schleife:\n\n```js\nvar model = { groups: [{ items: ['a', 'b', 'c'] }, { items: ['d'] }] };\n\nTangular.render('{{ foreach g in groups }}{{ $index }}:{{ foreach n in g.items }}{{ n }}{{ end }}:{{ $index }} {{ end }}', model);\n// 0:abc:2 1:d:0\n```\n\n## Helper\n\nEin Helper wandelt einen Wert um. Er folgt nach einem `|` auf den Wert, und Helper lassen sich verketten.\n\n| Helper | Beschreibung |\n| --- | --- |\n| `raw` | Gibt den Wert ohne Kodierung aus. |\n| `encode([type])` | Kodiert für HTML. Die Typen `url`, `json`, `json2` und `querify` wählen eine andere Ausgabe. |\n| `format(...)` | Formatiert eine Zahl oder ein Datum. |\n| `pluralize(zero, one, few, other)` | Wählt einen Text anhand einer Zahl. |\n| `empty([text])`, `def([text])` | Gibt bei einem leeren Wert `text` oder `DEF.empty` aus. |\n| `currency([name])` | Formatiert eine Zahl mit einer Währung aus `DEF.currencies`. |\n| `cl(name, [key])` | Sucht in der Codeliste `DEF.cl[name]` über `id` eine Bezeichnung. |\n\nDie Argumente jedes Helpers sind unter [Tangular-Helper](../../reference/tangular-helpers/) beschrieben.\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' EUR';\n};\nDEF.cl.status = [{ id: 1, name: 'Open' }, { id: 2, name: 'Closed' }];\n\nvar model = {\n  price: 1234.5,\n  created: new Date(2026, 0, 15, 10, 5),\n  count: 3,\n  note: '',\n  status: 2,\n  query: 'a b&c',\n  data: { a: 1 }\n};\n```\n\n| Template | Ausgabe |\n| --- | --- |\n| `{{ price \\| format(2) }}` | `1 234.50` |\n| `{{ created \\| format(\"yyyy-MM-dd HH:mm\") }}` | `2026-01-15 10:05` |\n| `{{ count \\| pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}` | `3 items` |\n| `{{ note \\| empty }}` | `---` |\n| `{{ note \\| empty(\"n/a\") }}` | `n/a` |\n| `{{ price \\| currency(\"eur\") }}` | `1 234.50 EUR` |\n| `{{ status \\| cl(\"status\") }}` | `Closed` |\n| `{{ query \\| encode(\"url\") }}` | `a%20b%26c` |\n| `{{ data \\| encode(\"json\") }}` | `{\"a\":1}` |\n\n## Eigene Helper\n\n`Tangular.register(name, callback)` fügt einen Helper für alle Templates hinzu. Das erste Argument des Callbacks ist der Wert, die weiteren kommen aus dem Template, und `this` ist das Modell.\n\n```js\nTangular.register('initials', function(value) {\n  return value.split(' ').map(function(word) {\n    return word.charAt(0);\n  }).join('');\n});\n\nTangular.register('wrap', function(value, before, after) {\n  return before + value + after;\n});\n\nTangular.register('fullname', function(value) {\n  return this.first + ' ' + value;\n});\n\nvar model = { name: 'Ann Lee', first: 'Ann', last: 'Lee', html: '<i>' };\n\nTangular.render('{{ name | initials }}', model);             // AL\nTangular.render('{{ name | initials | wrap(\"[\", \"]\") }}', model); // [AL]\nTangular.render('{{ last | fullname }}', model);             // Ann Lee\n```\n\nDie Ausgabe eines Helpers wird nicht kodiert. Füge `encode` am Ende der Kette hinzu, wenn der Wert von einem Benutzer stammt:\n\n```js\nTangular.render('{{ html | wrap(\"\", \"\") }}', model);          // <i>\nTangular.render('{{ html | wrap(\"\", \"\") | encode }}', model); // &lt;i&gt;\n```\n\nHelper für nur einen Aufruf übergibst du als letztes Argument von `render()`:\n\n```js\nvar helpers = { shout: function(value) { return value + '!'; } };\nTangular.render('{{ first | shout }}', model, null, helpers); // Ann!\n```\n\n## Das Repository\n\nDas Repository ist ein zweites Objekt für Werte, die nicht zum Modell gehören. Templates lesen es über `$`:\n\n```js\nvar repository = { title: 'Users', limit: 2 };\n\nTangular.render('{{ $.title }}: {{ name }}', { name: 'Ann' }, repository);\n// Users: Ann\n\nvar template = Tangular.compile('{{ foreach n in items }}{{ if $index < $.limit }}{{ n }} {{ fi }}{{ end }}');\ntemplate({ items: ['a', 'b', 'c'] }, repository);\n// a b\n```\n\n## Eigene Begrenzer\n\n`Tangular.compile(template, begin, end)` ersetzt `{{` und `}}`. Beide Werte sind Teile eines regulären Ausdrucks, Sonderzeichen müssen also maskiert werden:\n\n```js\nvar template = Tangular.compile('[[ name ]] and {{ other }}', '\\\\[\\\\[', '\\\\]\\\\]');\ntemplate({ name: 'Ann' }); // Ann and {{ other }}\n```\n\n## Zeilenumbrüche\n\nEin Zeilenumbruch direkt vor einem Tag und am Ende des Templates wird entfernt:\n\n```js\nTangular.render('a\\n{{ name }}\\nb\\n', { name: 'X' }); // \"aX\\nb\"\n```\n\n## Templates in der Seite\n\nDer Befehl `template` von `<ui-bind>` rendert ein Tangular-Template mit dem Wert eines Paths. Innerhalb des Templates steht der Wert als `value` zur Verfügung, und das Template rendert erneut, wenn sich der Wert ändert.\n\n```html\n<ui-bind path=\"team\" config=\"template\">\n  <script type=\"text/html\">\n    <ul>{{ foreach m in value.people }}<li>{{ m.name }}</li>{{ end }}</ul>\n  </script>\n</ui-bind>\n\n<script>\nSET('team', { people: [{ name: 'Ann' }, { name: 'Bob' }] });\n</script>\n```\n\nDas Element rendert `<ul><li>Ann</li><li>Bob</li></ul>`. Mehr über Bindungen erfährst du unter [Datenbindung](../data-binding/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNk22d61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/tangular/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Plantillas con Tangular","summary":"Cómo escribir plantillas con Tangular: valores, condiciones, bucles y helpers.","markdown":"---\ntitle: Plantillas con Tangular\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/tangular/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Plantillas con Tangular\n\n> Cómo escribir plantillas con Tangular: valores, condiciones, bucles y helpers.\n\nTangular es el motor de plantillas incluido en la biblioteca. Convierte una plantilla y un objeto de datos en una cadena HTML. Las plantillas se compilan a funciones JavaScript, así que una misma plantilla puede renderizarse muchas veces.\n\n## Renderizar una plantilla\n\n`Tangular.render(template, [model], [repository], [helpers])` compila y renderiza en un solo paso. `Tangular.compile(template)` devuelve una función para usarla repetidamente.\n\n```js\nvar html = Tangular.render('<h1>{{ title }}</h1><p>{{ user.name }}</p>', { title: 'Team', user: { name: 'Ann' } });\nconsole.log(html);\n\nvar template = Tangular.compile('Hello {{ name }}!');\nconsole.log(template({ name: 'Ann' }));\nconsole.log(template({ name: 'Bob' }));\n```\n\n```text\n<h1>Team</h1><p>Ann</p>\nHello Ann!\nHello Bob!\n```\n\nUna plantilla compilada se llama como `template(model, [repository], [helpers])`. `Ta` es un alias corto de `Tangular`.\n\n## Valores\n\n`{{ name }}` imprime un valor del modelo. La salida se codifica como HTML. El helper `raw` imprime el valor tal cual, así que úsalo solo con HTML de confianza.\n\n```js\nvar model = { name: '<b>Ann</b>', age: 30, user: { address: null }, score: 0, note: null };\n\nTangular.render('{{ name }}', model);                       // &lt;b&gt;Ann&lt;/b&gt;\nTangular.render('{{ name | raw }}', model);                 // <b>Ann</b>\nTangular.render('[{{ user.address.city }}]', model);        // []\nTangular.render('{{ score }}|{{ note }}|{{ age + 1 }}|{{ name.length }}', model); // 0||31|10\nTangular.render('{{ age > 18 ? \"adult\" : \"minor\" }}', model); // adult\n```\n\nUn valor que no existe no imprime nada, y lo mismo ocurre con `null`. El número `0` sí se imprime. Una etiqueta puede contener una expresión JavaScript sobre los valores del modelo.\n\n## Condiciones\n\nUna condición empieza por `{{ if }}` y termina con `{{ fi }}`. `{{ else if }}` y `{{ else }}` son opcionales.\n\n```js\nvar template = Tangular.compile('{{ if age >= 65 }}senior{{ else if age >= 18 }}adult{{ else }}child{{ fi }}');\n\ntemplate({ age: 70 }); // senior\ntemplate({ age: 30 }); // adult\ntemplate({ age: 12 }); // child\n```\n\nUna condición es JavaScript normal. Leer una propiedad de un objeto que no existe es un error, que se escribe en la consola y deja el resultado en `undefined`. Comprueba antes el objeto:\n\n```js\nTangular.render('{{ if user && user.active }}on{{ else }}off{{ fi }}', {}); // off\n```\n\n## Bucles\n\n`{{ foreach item in list }}` repite su contenido hasta `{{ end }}`. `$index` contiene la posición del elemento actual.\n\n```js\nvar model = {\n  tags: ['red', 'green', 'blue'],\n  sizes: { s: 10, m: 20 },\n  groups: [{ name: 'A', items: [1, 2] }, { name: 'B', items: [3] }]\n};\n\nTangular.render('{{ foreach tag in tags }}{{ $index }}:{{ tag }} {{ end }}', model);\n// 0:red 1:green 2:blue\n\nTangular.render('{{ foreach m in sizes }}{{ m.key }}={{ m.value }} {{ end }}', model);\n// s=10 m=20\n\nTangular.render('{{ foreach g in groups }}{{ g.name }}({{ foreach n in g.items }}{{ n }}{{ end }}) {{ end }}', model);\n// A(12) B(3)\n```\n\nUn objeto se recorre como una lista de elementos con `key` y `value`. Una lista vacía o inexistente no renderiza nada.\n\n`{{ continue }}` salta al siguiente elemento y `{{ break }}` termina el bucle:\n\n```js\nTangular.render('{{ foreach tag in tags }}{{ if $index === 1 }}{{ continue }}{{ fi }}{{ tag }} {{ end }}', model);\n// red blue\n\nTangular.render('{{ foreach tag in tags }}{{ if $index === 2 }}{{ break }}{{ fi }}{{ tag }} {{ end }}', model);\n// red green\n```\n\nLos bucles anidados comparten un único `$index`. Cuando termina un bucle interno, `$index` conserva la última posición de ese bucle hasta que avanza el externo, así que lee la posición externa antes del bucle interno:\n\n```js\nvar model = { groups: [{ items: ['a', 'b', 'c'] }, { items: ['d'] }] };\n\nTangular.render('{{ foreach g in groups }}{{ $index }}:{{ foreach n in g.items }}{{ n }}{{ end }}:{{ $index }} {{ end }}', model);\n// 0:abc:2 1:d:0\n```\n\n## Helpers\n\nUn helper transforma un valor. Se escribe detrás del valor después de un `|`, y los helpers se pueden encadenar.\n\n| Helper | Descripción |\n| --- | --- |\n| `raw` | Imprime el valor sin codificar. |\n| `encode([type])` | Codifica para HTML. Los tipos `url`, `json`, `json2` y `querify` seleccionan otra salida. |\n| `format(...)` | Da formato a un número o una fecha. |\n| `pluralize(zero, one, few, other)` | Selecciona un texto según un número. |\n| `empty([text])`, `def([text])` | Imprime `text` o `DEF.empty` para un valor vacío. |\n| `currency([name])` | Da formato a un número con una moneda de `DEF.currencies`. |\n| `cl(name, [key])` | Busca por `id` una etiqueta en la lista de códigos `DEF.cl[name]`. |\n\nLos argumentos de cada helper se describen en [Helpers de Tangular](../../reference/tangular-helpers/).\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' EUR';\n};\nDEF.cl.status = [{ id: 1, name: 'Open' }, { id: 2, name: 'Closed' }];\n\nvar model = {\n  price: 1234.5,\n  created: new Date(2026, 0, 15, 10, 5),\n  count: 3,\n  note: '',\n  status: 2,\n  query: 'a b&c',\n  data: { a: 1 }\n};\n```\n\n| Plantilla | Salida |\n| --- | --- |\n| `{{ price \\| format(2) }}` | `1 234.50` |\n| `{{ created \\| format(\"yyyy-MM-dd HH:mm\") }}` | `2026-01-15 10:05` |\n| `{{ count \\| pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}` | `3 items` |\n| `{{ note \\| empty }}` | `---` |\n| `{{ note \\| empty(\"n/a\") }}` | `n/a` |\n| `{{ price \\| currency(\"eur\") }}` | `1 234.50 EUR` |\n| `{{ status \\| cl(\"status\") }}` | `Closed` |\n| `{{ query \\| encode(\"url\") }}` | `a%20b%26c` |\n| `{{ data \\| encode(\"json\") }}` | `{\"a\":1}` |\n\n## Helpers personalizados\n\n`Tangular.register(name, callback)` añade un helper para todas las plantillas. El primer argumento del callback es el valor, los siguientes vienen de la plantilla y `this` es el modelo.\n\n```js\nTangular.register('initials', function(value) {\n  return value.split(' ').map(function(word) {\n    return word.charAt(0);\n  }).join('');\n});\n\nTangular.register('wrap', function(value, before, after) {\n  return before + value + after;\n});\n\nTangular.register('fullname', function(value) {\n  return this.first + ' ' + value;\n});\n\nvar model = { name: 'Ann Lee', first: 'Ann', last: 'Lee', html: '<i>' };\n\nTangular.render('{{ name | initials }}', model);             // AL\nTangular.render('{{ name | initials | wrap(\"[\", \"]\") }}', model); // [AL]\nTangular.render('{{ last | fullname }}', model);             // Ann Lee\n```\n\nLa salida de un helper no se codifica. Añade `encode` al final de la cadena cuando el valor venga de un usuario:\n\n```js\nTangular.render('{{ html | wrap(\"\", \"\") }}', model);          // <i>\nTangular.render('{{ html | wrap(\"\", \"\") | encode }}', model); // &lt;i&gt;\n```\n\nLos helpers para una sola llamada van en el último argumento de `render()`:\n\n```js\nvar helpers = { shout: function(value) { return value + '!'; } };\nTangular.render('{{ first | shout }}', model, null, helpers); // Ann!\n```\n\n## El repositorio\n\nEl repositorio es un segundo objeto para los valores que no pertenecen al modelo. Las plantillas lo leen a través de `$`:\n\n```js\nvar repository = { title: 'Users', limit: 2 };\n\nTangular.render('{{ $.title }}: {{ name }}', { name: 'Ann' }, repository);\n// Users: Ann\n\nvar template = Tangular.compile('{{ foreach n in items }}{{ if $index < $.limit }}{{ n }} {{ fi }}{{ end }}');\ntemplate({ items: ['a', 'b', 'c'] }, repository);\n// a b\n```\n\n## Delimitadores personalizados\n\n`Tangular.compile(template, begin, end)` sustituye `{{` y `}}`. Ambos valores forman parte de una expresión regular, así que los caracteres especiales deben escaparse:\n\n```js\nvar template = Tangular.compile('[[ name ]] and {{ other }}', '\\\\[\\\\[', '\\\\]\\\\]');\ntemplate({ name: 'Ann' }); // Ann and {{ other }}\n```\n\n## Saltos de línea\n\nSe elimina el salto de línea situado justo delante de una etiqueta y el del final de la plantilla:\n\n```js\nTangular.render('a\\n{{ name }}\\nb\\n', { name: 'X' }); // \"aX\\nb\"\n```\n\n## Plantillas en la página\n\nEl comando `template` de `<ui-bind>` renderiza una plantilla de Tangular con el valor de un path. Dentro de la plantilla, el valor está disponible como `value`, y la plantilla vuelve a renderizarse cuando cambia el valor.\n\n```html\n<ui-bind path=\"team\" config=\"template\">\n  <script type=\"text/html\">\n    <ul>{{ foreach m in value.people }}<li>{{ m.name }}</li>{{ end }}</ul>\n  </script>\n</ui-bind>\n\n<script>\nSET('team', { people: [{ name: 'Ann' }, { name: 'Bob' }] });\n</script>\n```\n\nEl elemento renderiza `<ul><li>Ann</li><li>Bob</li></ul>`. Encontrarás más sobre los enlaces en [Enlace de datos](../data-binding/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNk22d61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/tangular/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Modèles avec Tangular","summary":"Comment écrire des modèles avec Tangular : valeurs, conditions, boucles et helpers.","markdown":"---\ntitle: \"Modèles avec Tangular\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/tangular/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Modèles avec Tangular\n\n> Comment écrire des modèles avec Tangular : valeurs, conditions, boucles et helpers.\n\nTangular est le moteur de modèles inclus dans la bibliothèque. Il transforme un modèle et un objet de données en une chaîne HTML. Les modèles sont compilés en fonctions JavaScript : un même modèle peut donc être rendu de nombreuses fois.\n\n## Rendre un modèle\n\n`Tangular.render(template, [model], [repository], [helpers])` compile et rend en une seule étape. `Tangular.compile(template)` renvoie une fonction à réutiliser.\n\n```js\nvar html = Tangular.render('<h1>{{ title }}</h1><p>{{ user.name }}</p>', { title: 'Team', user: { name: 'Ann' } });\nconsole.log(html);\n\nvar template = Tangular.compile('Hello {{ name }}!');\nconsole.log(template({ name: 'Ann' }));\nconsole.log(template({ name: 'Bob' }));\n```\n\n```text\n<h1>Team</h1><p>Ann</p>\nHello Ann!\nHello Bob!\n```\n\nUn modèle compilé s'appelle sous la forme `template(model, [repository], [helpers])`. `Ta` est un alias court de `Tangular`.\n\n## Valeurs\n\n`{{ name }}` affiche une valeur des données. La sortie est encodée en HTML. Le helper `raw` affiche la valeur telle quelle : ne l'utilise donc que pour du HTML de confiance.\n\n```js\nvar model = { name: '<b>Ann</b>', age: 30, user: { address: null }, score: 0, note: null };\n\nTangular.render('{{ name }}', model);                       // &lt;b&gt;Ann&lt;/b&gt;\nTangular.render('{{ name | raw }}', model);                 // <b>Ann</b>\nTangular.render('[{{ user.address.city }}]', model);        // []\nTangular.render('{{ score }}|{{ note }}|{{ age + 1 }}|{{ name.length }}', model); // 0||31|10\nTangular.render('{{ age > 18 ? \"adult\" : \"minor\" }}', model); // adult\n```\n\nUne valeur manquante n'affiche rien, tout comme `null`. Le nombre `0` est affiché. Une balise peut contenir une expression JavaScript portant sur les valeurs des données.\n\n## Conditions\n\nUne condition commence par `{{ if }}` et se termine par `{{ fi }}`. `{{ else if }}` et `{{ else }}` sont facultatifs.\n\n```js\nvar template = Tangular.compile('{{ if age >= 65 }}senior{{ else if age >= 18 }}adult{{ else }}child{{ fi }}');\n\ntemplate({ age: 70 }); // senior\ntemplate({ age: 30 }); // adult\ntemplate({ age: 12 }); // child\n```\n\nUne condition est du JavaScript pur. Y lire une propriété d'un objet manquant provoque une erreur, qui est écrite dans la console et laisse le résultat à `undefined`. Vérifie d'abord l'objet :\n\n```js\nTangular.render('{{ if user && user.active }}on{{ else }}off{{ fi }}', {}); // off\n```\n\n## Boucles\n\n`{{ foreach item in list }}` répète son contenu jusqu'à `{{ end }}`. `$index` contient la position de l'élément courant.\n\n```js\nvar model = {\n  tags: ['red', 'green', 'blue'],\n  sizes: { s: 10, m: 20 },\n  groups: [{ name: 'A', items: [1, 2] }, { name: 'B', items: [3] }]\n};\n\nTangular.render('{{ foreach tag in tags }}{{ $index }}:{{ tag }} {{ end }}', model);\n// 0:red 1:green 2:blue\n\nTangular.render('{{ foreach m in sizes }}{{ m.key }}={{ m.value }} {{ end }}', model);\n// s=10 m=20\n\nTangular.render('{{ foreach g in groups }}{{ g.name }}({{ foreach n in g.items }}{{ n }}{{ end }}) {{ end }}', model);\n// A(12) B(3)\n```\n\nUn objet est parcouru comme une liste d'éléments dotés de `key` et `value`. Une liste manquante ou vide n'affiche rien.\n\n`{{ continue }}` passe à l'élément suivant et `{{ break }}` termine la boucle :\n\n```js\nTangular.render('{{ foreach tag in tags }}{{ if $index === 1 }}{{ continue }}{{ fi }}{{ tag }} {{ end }}', model);\n// red blue\n\nTangular.render('{{ foreach tag in tags }}{{ if $index === 2 }}{{ break }}{{ fi }}{{ tag }} {{ end }}', model);\n// red green\n```\n\nLes boucles imbriquées partagent un seul `$index`. Quand une boucle interne se termine, `$index` conserve la dernière position de cette boucle jusqu'à ce que la boucle externe avance : lis donc la position externe avant la boucle interne :\n\n```js\nvar model = { groups: [{ items: ['a', 'b', 'c'] }, { items: ['d'] }] };\n\nTangular.render('{{ foreach g in groups }}{{ $index }}:{{ foreach n in g.items }}{{ n }}{{ end }}:{{ $index }} {{ end }}', model);\n// 0:abc:2 1:d:0\n```\n\n## Helpers\n\nUn helper transforme une valeur. Il suit la valeur après un `|`, et les helpers peuvent s'enchaîner.\n\n| Helper | Description |\n| --- | --- |\n| `raw` | Affiche la valeur sans l'encoder. |\n| `encode([type])` | Encode pour le HTML. Les types `url`, `json`, `json2` et `querify` sélectionnent une autre sortie. |\n| `format(...)` | Formate un nombre ou une date. |\n| `pluralize(zero, one, few, other)` | Sélectionne un texte en fonction d'un nombre. |\n| `empty([text])`, `def([text])` | Affiche `text` ou `DEF.empty` pour une valeur vide. |\n| `currency([name])` | Formate un nombre avec une devise de `DEF.currencies`. |\n| `cl(name, [key])` | Recherche un libellé par `id` dans la liste de codes `DEF.cl[name]`. |\n\nLes arguments de chaque helper sont décrits dans [Helpers Tangular](../../reference/tangular-helpers/).\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' EUR';\n};\nDEF.cl.status = [{ id: 1, name: 'Open' }, { id: 2, name: 'Closed' }];\n\nvar model = {\n  price: 1234.5,\n  created: new Date(2026, 0, 15, 10, 5),\n  count: 3,\n  note: '',\n  status: 2,\n  query: 'a b&c',\n  data: { a: 1 }\n};\n```\n\n| Modèle | Sortie |\n| --- | --- |\n| `{{ price \\| format(2) }}` | `1 234.50` |\n| `{{ created \\| format(\"yyyy-MM-dd HH:mm\") }}` | `2026-01-15 10:05` |\n| `{{ count \\| pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}` | `3 items` |\n| `{{ note \\| empty }}` | `---` |\n| `{{ note \\| empty(\"n/a\") }}` | `n/a` |\n| `{{ price \\| currency(\"eur\") }}` | `1 234.50 EUR` |\n| `{{ status \\| cl(\"status\") }}` | `Closed` |\n| `{{ query \\| encode(\"url\") }}` | `a%20b%26c` |\n| `{{ data \\| encode(\"json\") }}` | `{\"a\":1}` |\n\n## Helpers personnalisés\n\n`Tangular.register(name, callback)` ajoute un helper pour tous les modèles. Le premier argument du callback est la valeur, les suivants viennent du modèle, et `this` représente les données.\n\n```js\nTangular.register('initials', function(value) {\n  return value.split(' ').map(function(word) {\n    return word.charAt(0);\n  }).join('');\n});\n\nTangular.register('wrap', function(value, before, after) {\n  return before + value + after;\n});\n\nTangular.register('fullname', function(value) {\n  return this.first + ' ' + value;\n});\n\nvar model = { name: 'Ann Lee', first: 'Ann', last: 'Lee', html: '<i>' };\n\nTangular.render('{{ name | initials }}', model);             // AL\nTangular.render('{{ name | initials | wrap(\"[\", \"]\") }}', model); // [AL]\nTangular.render('{{ last | fullname }}', model);             // Ann Lee\n```\n\nLa sortie d'un helper n'est pas encodée. Ajoute `encode` à la fin de la chaîne quand la valeur vient d'un utilisateur :\n\n```js\nTangular.render('{{ html | wrap(\"\", \"\") }}', model);          // <i>\nTangular.render('{{ html | wrap(\"\", \"\") | encode }}', model); // &lt;i&gt;\n```\n\nLes helpers valables pour un seul appel se passent dans le dernier argument de `render()` :\n\n```js\nvar helpers = { shout: function(value) { return value + '!'; } };\nTangular.render('{{ first | shout }}', model, null, helpers); // Ann!\n```\n\n## Le repository\n\nLe repository est un second objet destiné aux valeurs qui n'appartiennent pas au modèle de données. Les modèles le lisent par `$` :\n\n```js\nvar repository = { title: 'Users', limit: 2 };\n\nTangular.render('{{ $.title }}: {{ name }}', { name: 'Ann' }, repository);\n// Users: Ann\n\nvar template = Tangular.compile('{{ foreach n in items }}{{ if $index < $.limit }}{{ n }} {{ fi }}{{ end }}');\ntemplate({ items: ['a', 'b', 'c'] }, repository);\n// a b\n```\n\n## Délimiteurs personnalisés\n\n`Tangular.compile(template, begin, end)` remplace `{{` et `}}`. Les deux valeurs font partie d'une expression régulière : les caractères spéciaux doivent donc être échappés :\n\n```js\nvar template = Tangular.compile('[[ name ]] and {{ other }}', '\\\\[\\\\[', '\\\\]\\\\]');\ntemplate({ name: 'Ann' }); // Ann and {{ other }}\n```\n\n## Sauts de ligne\n\nUn saut de ligne placé juste devant une balise et à la fin du modèle est supprimé :\n\n```js\nTangular.render('a\\n{{ name }}\\nb\\n', { name: 'X' }); // \"aX\\nb\"\n```\n\n## Modèles dans la page\n\nLa commande `template` de `<ui-bind>` rend un modèle Tangular avec la valeur d'un path. Dans le modèle, la valeur est disponible sous le nom `value`, et le modèle est rendu de nouveau quand la valeur change.\n\n```html\n<ui-bind path=\"team\" config=\"template\">\n  <script type=\"text/html\">\n    <ul>{{ foreach m in value.people }}<li>{{ m.name }}</li>{{ end }}</ul>\n  </script>\n</ui-bind>\n\n<script>\nSET('team', { people: [{ name: 'Ann' }, { name: 'Bob' }] });\n</script>\n```\n\nL'élément affiche `<ul><li>Ann</li><li>Bob</li></ul>`. Pour en savoir plus sur les liaisons, lis [Liaison de données](../data-binding/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNk22d61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/tangular/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Template con Tangular","summary":"Come scrivere template con Tangular: valori, condizioni, cicli e helper.","markdown":"---\ntitle: Template con Tangular\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/tangular/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Template con Tangular\n\n> Come scrivere template con Tangular: valori, condizioni, cicli e helper.\n\nTangular è il motore di template incluso nella libreria. Trasforma un template e un oggetto di dati in una stringa HTML. I template vengono compilati in funzioni JavaScript, quindi un solo template può essere visualizzato molte volte.\n\n## Visualizzare un template\n\n`Tangular.render(template, [model], [repository], [helpers])` compila e visualizza in un solo passaggio. `Tangular.compile(template)` restituisce una funzione da usare più volte.\n\n```js\nvar html = Tangular.render('<h1>{{ title }}</h1><p>{{ user.name }}</p>', { title: 'Team', user: { name: 'Ann' } });\nconsole.log(html);\n\nvar template = Tangular.compile('Hello {{ name }}!');\nconsole.log(template({ name: 'Ann' }));\nconsole.log(template({ name: 'Bob' }));\n```\n\n```text\n<h1>Team</h1><p>Ann</p>\nHello Ann!\nHello Bob!\n```\n\nUn template compilato si chiama come `template(model, [repository], [helpers])`. `Ta` è un alias breve di `Tangular`.\n\n## Valori\n\n`{{ name }}` stampa un valore del modello. L'output viene codificato in HTML. L'helper `raw` stampa il valore così com'è, quindi usalo solo per HTML di cui ti fidi.\n\n```js\nvar model = { name: '<b>Ann</b>', age: 30, user: { address: null }, score: 0, note: null };\n\nTangular.render('{{ name }}', model);                       // &lt;b&gt;Ann&lt;/b&gt;\nTangular.render('{{ name | raw }}', model);                 // <b>Ann</b>\nTangular.render('[{{ user.address.city }}]', model);        // []\nTangular.render('{{ score }}|{{ note }}|{{ age + 1 }}|{{ name.length }}', model); // 0||31|10\nTangular.render('{{ age > 18 ? \"adult\" : \"minor\" }}', model); // adult\n```\n\nUn valore mancante non stampa nulla, così come `null`. Il numero `0` viene stampato. Un tag può contenere un'espressione JavaScript sui valori del modello.\n\n## Condizioni\n\nUna condizione inizia con `{{ if }}` e termina con `{{ fi }}`. `{{ else if }}` e `{{ else }}` sono facoltativi.\n\n```js\nvar template = Tangular.compile('{{ if age >= 65 }}senior{{ else if age >= 18 }}adult{{ else }}child{{ fi }}');\n\ntemplate({ age: 70 }); // senior\ntemplate({ age: 30 }); // adult\ntemplate({ age: 12 }); // child\n```\n\nUna condizione è semplice JavaScript. Leggere una proprietà di un oggetto mancante è quindi un errore, che viene scritto nella console e lascia il risultato `undefined`. Controlla prima l'oggetto:\n\n```js\nTangular.render('{{ if user && user.active }}on{{ else }}off{{ fi }}', {}); // off\n```\n\n## Cicli\n\n`{{ foreach item in list }}` ripete il proprio contenuto fino a `{{ end }}`. `$index` contiene la posizione dell'elemento corrente.\n\n```js\nvar model = {\n  tags: ['red', 'green', 'blue'],\n  sizes: { s: 10, m: 20 },\n  groups: [{ name: 'A', items: [1, 2] }, { name: 'B', items: [3] }]\n};\n\nTangular.render('{{ foreach tag in tags }}{{ $index }}:{{ tag }} {{ end }}', model);\n// 0:red 1:green 2:blue\n\nTangular.render('{{ foreach m in sizes }}{{ m.key }}={{ m.value }} {{ end }}', model);\n// s=10 m=20\n\nTangular.render('{{ foreach g in groups }}{{ g.name }}({{ foreach n in g.items }}{{ n }}{{ end }}) {{ end }}', model);\n// A(12) B(3)\n```\n\nUn oggetto viene percorso come un elenco di elementi con `key` e `value`. Un elenco mancante o vuoto non visualizza nulla.\n\n`{{ continue }}` passa all'elemento successivo e `{{ break }}` termina il ciclo:\n\n```js\nTangular.render('{{ foreach tag in tags }}{{ if $index === 1 }}{{ continue }}{{ fi }}{{ tag }} {{ end }}', model);\n// red blue\n\nTangular.render('{{ foreach tag in tags }}{{ if $index === 2 }}{{ break }}{{ fi }}{{ tag }} {{ end }}', model);\n// red green\n```\n\nI cicli annidati condividono un unico `$index`. Al termine di un ciclo interno, `$index` conserva l'ultima posizione di quel ciclo finché il ciclo esterno non avanza, quindi leggi la posizione esterna prima del ciclo interno:\n\n```js\nvar model = { groups: [{ items: ['a', 'b', 'c'] }, { items: ['d'] }] };\n\nTangular.render('{{ foreach g in groups }}{{ $index }}:{{ foreach n in g.items }}{{ n }}{{ end }}:{{ $index }} {{ end }}', model);\n// 0:abc:2 1:d:0\n```\n\n## Helper\n\nUn helper trasforma un valore. Segue il valore dopo un `|` e gli helper possono essere concatenati.\n\n| Helper | Descrizione |\n| --- | --- |\n| `raw` | Stampa il valore senza codificarlo. |\n| `encode([type])` | Codifica per l'HTML. I tipi `url`, `json`, `json2` e `querify` selezionano un altro output. |\n| `format(...)` | Formatta un numero o una data. |\n| `pluralize(zero, one, few, other)` | Seleziona un testo in base a un numero. |\n| `empty([text])`, `def([text])` | Stampa `text` o `DEF.empty` per un valore vuoto. |\n| `currency([name])` | Formatta un numero con una valuta di `DEF.currencies`. |\n| `cl(name, [key])` | Trova un'etichetta nell'elenco di codici `DEF.cl[name]` in base a `id`. |\n\nGli argomenti di ogni helper sono descritti in [Helper di Tangular](../../reference/tangular-helpers/).\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' EUR';\n};\nDEF.cl.status = [{ id: 1, name: 'Open' }, { id: 2, name: 'Closed' }];\n\nvar model = {\n  price: 1234.5,\n  created: new Date(2026, 0, 15, 10, 5),\n  count: 3,\n  note: '',\n  status: 2,\n  query: 'a b&c',\n  data: { a: 1 }\n};\n```\n\n| Template | Output |\n| --- | --- |\n| `{{ price \\| format(2) }}` | `1 234.50` |\n| `{{ created \\| format(\"yyyy-MM-dd HH:mm\") }}` | `2026-01-15 10:05` |\n| `{{ count \\| pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}` | `3 items` |\n| `{{ note \\| empty }}` | `---` |\n| `{{ note \\| empty(\"n/a\") }}` | `n/a` |\n| `{{ price \\| currency(\"eur\") }}` | `1 234.50 EUR` |\n| `{{ status \\| cl(\"status\") }}` | `Closed` |\n| `{{ query \\| encode(\"url\") }}` | `a%20b%26c` |\n| `{{ data \\| encode(\"json\") }}` | `{\"a\":1}` |\n\n## Helper personalizzati\n\n`Tangular.register(name, callback)` aggiunge un helper per tutti i template. Il primo argomento della callback è il valore, i successivi provengono dal template e `this` è il modello.\n\n```js\nTangular.register('initials', function(value) {\n  return value.split(' ').map(function(word) {\n    return word.charAt(0);\n  }).join('');\n});\n\nTangular.register('wrap', function(value, before, after) {\n  return before + value + after;\n});\n\nTangular.register('fullname', function(value) {\n  return this.first + ' ' + value;\n});\n\nvar model = { name: 'Ann Lee', first: 'Ann', last: 'Lee', html: '<i>' };\n\nTangular.render('{{ name | initials }}', model);             // AL\nTangular.render('{{ name | initials | wrap(\"[\", \"]\") }}', model); // [AL]\nTangular.render('{{ last | fullname }}', model);             // Ann Lee\n```\n\nL'output di un helper non viene codificato. Aggiungi `encode` alla fine della catena quando il valore proviene da un utente:\n\n```js\nTangular.render('{{ html | wrap(\"\", \"\") }}', model);          // <i>\nTangular.render('{{ html | wrap(\"\", \"\") | encode }}', model); // &lt;i&gt;\n```\n\nGli helper validi per una sola chiamata vanno nell'ultimo argomento di `render()`:\n\n```js\nvar helpers = { shout: function(value) { return value + '!'; } };\nTangular.render('{{ first | shout }}', model, null, helpers); // Ann!\n```\n\n## Il repository\n\nIl repository è un secondo oggetto per i valori che non appartengono al modello. I template lo leggono tramite `$`:\n\n```js\nvar repository = { title: 'Users', limit: 2 };\n\nTangular.render('{{ $.title }}: {{ name }}', { name: 'Ann' }, repository);\n// Users: Ann\n\nvar template = Tangular.compile('{{ foreach n in items }}{{ if $index < $.limit }}{{ n }} {{ fi }}{{ end }}');\ntemplate({ items: ['a', 'b', 'c'] }, repository);\n// a b\n```\n\n## Delimitatori personalizzati\n\n`Tangular.compile(template, begin, end)` sostituisce `{{` e `}}`. Entrambi i valori sono parti di un'espressione regolare, quindi i caratteri speciali vanno sottoposti a escape:\n\n```js\nvar template = Tangular.compile('[[ name ]] and {{ other }}', '\\\\[\\\\[', '\\\\]\\\\]');\ntemplate({ name: 'Ann' }); // Ann and {{ other }}\n```\n\n## Interruzioni di riga\n\nViene rimossa un'interruzione di riga subito prima di un tag e alla fine del template:\n\n```js\nTangular.render('a\\n{{ name }}\\nb\\n', { name: 'X' }); // \"aX\\nb\"\n```\n\n## Template nella pagina\n\nIl comando `template` di `<ui-bind>` visualizza un template Tangular con il valore di un path. Dentro il template, il valore è disponibile come `value` e il template viene visualizzato di nuovo quando il valore cambia.\n\n```html\n<ui-bind path=\"team\" config=\"template\">\n  <script type=\"text/html\">\n    <ul>{{ foreach m in value.people }}<li>{{ m.name }}</li>{{ end }}</ul>\n  </script>\n</ui-bind>\n\n<script>\nSET('team', { people: [{ name: 'Ann' }, { name: 'Bob' }] });\n</script>\n```\n\nL'elemento visualizza `<ul><li>Ann</li><li>Bob</li></ul>`. Trovi altre informazioni sulle associazioni in [Associazione dei dati](../data-binding/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNk22d61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/tangular/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Šablóny s Tangular","summary":"Ako písať šablóny s Tangular: hodnoty, podmienky, cykly a helpery.","markdown":"---\ntitle: \"Šablóny s Tangular\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/tangular/\nupdated: 2026-11-18T13:55:34.124Z\n---\n\n# Šablóny s Tangular\n\n> Ako písať šablóny s Tangular: hodnoty, podmienky, cykly a helpery.\n\nTangular je šablónovací nástroj zahrnutý v knižnici. Zo šablóny a dátového objektu vytvorí HTML reťazec. Šablóny sa kompilujú do JavaScriptových funkcií, takže jedna šablóna sa môže vykresliť mnohokrát.\n\n## Vykreslenie šablóny\n\n`Tangular.render(template, [model], [repository], [helpers])` skompiluje a vykreslí v jednom kroku. `Tangular.compile(template)` vráti funkciu na opakované použitie.\n\n```js\nvar html = Tangular.render('<h1>{{ title }}</h1><p>{{ user.name }}</p>', { title: 'Team', user: { name: 'Ann' } });\nconsole.log(html);\n\nvar template = Tangular.compile('Hello {{ name }}!');\nconsole.log(template({ name: 'Ann' }));\nconsole.log(template({ name: 'Bob' }));\n```\n\n```text\n<h1>Team</h1><p>Ann</p>\nHello Ann!\nHello Bob!\n```\n\nSkompilovaná šablóna sa volá ako `template(model, [repository], [helpers])`. `Ta` je krátky alias pre `Tangular`.\n\n## Hodnoty\n\n`{{ name }}` vypíše hodnotu z modelu. Výstup je zakódovaný pre HTML. Helper `raw` vypíše hodnotu tak, ako je, preto ho používaj iba pre HTML, ktorému dôveruješ.\n\n```js\nvar model = { name: '<b>Ann</b>', age: 30, user: { address: null }, score: 0, note: null };\n\nTangular.render('{{ name }}', model);                       // &lt;b&gt;Ann&lt;/b&gt;\nTangular.render('{{ name | raw }}', model);                 // <b>Ann</b>\nTangular.render('[{{ user.address.city }}]', model);        // []\nTangular.render('{{ score }}|{{ note }}|{{ age + 1 }}|{{ name.length }}', model); // 0||31|10\nTangular.render('{{ age > 18 ? \"adult\" : \"minor\" }}', model); // adult\n```\n\nChýbajúca hodnota nevypíše nič, rovnako ani `null`. Číslo `0` sa vypíše. Značka môže obsahovať JavaScriptový výraz nad hodnotami modelu.\n\n## Podmienky\n\nPodmienka začína `{{ if }}` a končí `{{ fi }}`. `{{ else if }}` a `{{ else }}` sú voliteľné.\n\n```js\nvar template = Tangular.compile('{{ if age >= 65 }}senior{{ else if age >= 18 }}adult{{ else }}child{{ fi }}');\n\ntemplate({ age: 70 }); // senior\ntemplate({ age: 30 }); // adult\ntemplate({ age: 12 }); // child\n```\n\nPodmienka je obyčajný JavaScript. Čítanie vlastnosti chýbajúceho objektu je v nej chyba, ktorá sa zapíše do konzoly a výsledok zostane `undefined`. Najprv preto skontroluj objekt:\n\n```js\nTangular.render('{{ if user && user.active }}on{{ else }}off{{ fi }}', {}); // off\n```\n\n## Cykly\n\n`{{ foreach item in list }}` opakuje svoj obsah až po `{{ end }}`. `$index` obsahuje pozíciu aktuálnej položky.\n\n```js\nvar model = {\n  tags: ['red', 'green', 'blue'],\n  sizes: { s: 10, m: 20 },\n  groups: [{ name: 'A', items: [1, 2] }, { name: 'B', items: [3] }]\n};\n\nTangular.render('{{ foreach tag in tags }}{{ $index }}:{{ tag }} {{ end }}', model);\n// 0:red 1:green 2:blue\n\nTangular.render('{{ foreach m in sizes }}{{ m.key }}={{ m.value }} {{ end }}', model);\n// s=10 m=20\n\nTangular.render('{{ foreach g in groups }}{{ g.name }}({{ foreach n in g.items }}{{ n }}{{ end }}) {{ end }}', model);\n// A(12) B(3)\n```\n\nObjekt sa prechádza ako zoznam položiek s `key` a `value`. Chýbajúci alebo prázdny zoznam nevykreslí nič.\n\n`{{ continue }}` preskočí na ďalšiu položku a `{{ break }}` ukončí cyklus:\n\n```js\nTangular.render('{{ foreach tag in tags }}{{ if $index === 1 }}{{ continue }}{{ fi }}{{ tag }} {{ end }}', model);\n// red blue\n\nTangular.render('{{ foreach tag in tags }}{{ if $index === 2 }}{{ break }}{{ fi }}{{ tag }} {{ end }}', model);\n// red green\n```\n\nVnorené cykly zdieľajú jeden `$index`. Po skončení vnútorného cyklu si `$index` ponechá poslednú pozíciu tohto cyklu, kým sa vonkajší cyklus neposunie ďalej, preto si vonkajšiu pozíciu prečítaj ešte pred vnútorným cyklom:\n\n```js\nvar model = { groups: [{ items: ['a', 'b', 'c'] }, { items: ['d'] }] };\n\nTangular.render('{{ foreach g in groups }}{{ $index }}:{{ foreach n in g.items }}{{ n }}{{ end }}:{{ $index }} {{ end }}', model);\n// 0:abc:2 1:d:0\n```\n\n## Helpery\n\nHelper transformuje hodnotu. Píše sa za hodnotu po znaku `|` a helpery možno reťaziť.\n\n| Helper | Popis |\n| --- | --- |\n| `raw` | Vypíše hodnotu bez kódovania. |\n| `encode([type])` | Zakóduje pre HTML. Typy `url`, `json`, `json2` a `querify` vyberú iný výstup. |\n| `format(...)` | Naformátuje číslo alebo dátum. |\n| `pluralize(zero, one, few, other)` | Vyberie text podľa čísla. |\n| `empty([text])`, `def([text])` | Pre prázdnu hodnotu vypíše `text` alebo `DEF.empty`. |\n| `currency([name])` | Naformátuje číslo s menou z `DEF.currencies`. |\n| `cl(name, [key])` | Nájde popis v zozname kódov `DEF.cl[name]` podľa `id`. |\n\nArgumenty jednotlivých helperov opisuje časť [Helpery Tangular](../../reference/tangular-helpers/).\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' EUR';\n};\nDEF.cl.status = [{ id: 1, name: 'Open' }, { id: 2, name: 'Closed' }];\n\nvar model = {\n  price: 1234.5,\n  created: new Date(2026, 0, 15, 10, 5),\n  count: 3,\n  note: '',\n  status: 2,\n  query: 'a b&c',\n  data: { a: 1 }\n};\n```\n\n| Šablóna | Výstup |\n| --- | --- |\n| `{{ price \\| format(2) }}` | `1 234.50` |\n| `{{ created \\| format(\"yyyy-MM-dd HH:mm\") }}` | `2026-01-15 10:05` |\n| `{{ count \\| pluralize(\"no items\", \"# item\", \"# items\", \"# items\") }}` | `3 items` |\n| `{{ note \\| empty }}` | `---` |\n| `{{ note \\| empty(\"n/a\") }}` | `n/a` |\n| `{{ price \\| currency(\"eur\") }}` | `1 234.50 EUR` |\n| `{{ status \\| cl(\"status\") }}` | `Closed` |\n| `{{ query \\| encode(\"url\") }}` | `a%20b%26c` |\n| `{{ data \\| encode(\"json\") }}` | `{\"a\":1}` |\n\n## Vlastné helpery\n\n`Tangular.register(name, callback)` pridá helper pre všetky šablóny. Prvým argumentom callbacku je hodnota, ďalšie pochádzajú zo šablóny a `this` je model.\n\n```js\nTangular.register('initials', function(value) {\n  return value.split(' ').map(function(word) {\n    return word.charAt(0);\n  }).join('');\n});\n\nTangular.register('wrap', function(value, before, after) {\n  return before + value + after;\n});\n\nTangular.register('fullname', function(value) {\n  return this.first + ' ' + value;\n});\n\nvar model = { name: 'Ann Lee', first: 'Ann', last: 'Lee', html: '<i>' };\n\nTangular.render('{{ name | initials }}', model);             // AL\nTangular.render('{{ name | initials | wrap(\"[\", \"]\") }}', model); // [AL]\nTangular.render('{{ last | fullname }}', model);             // Ann Lee\n```\n\nVýstup helpera sa nekóduje. Keď hodnota pochádza od používateľa, pridaj na koniec reťazca `encode`:\n\n```js\nTangular.render('{{ html | wrap(\"\", \"\") }}', model);          // <i>\nTangular.render('{{ html | wrap(\"\", \"\") | encode }}', model); // &lt;i&gt;\n```\n\nHelpery iba pre jedno volanie patria do posledného argumentu `render()`:\n\n```js\nvar helpers = { shout: function(value) { return value + '!'; } };\nTangular.render('{{ first | shout }}', model, null, helpers); // Ann!\n```\n\n## Repozitár\n\nRepozitár je druhý objekt pre hodnoty, ktoré nepatria do modelu. Šablóny ho čítajú cez `$`:\n\n```js\nvar repository = { title: 'Users', limit: 2 };\n\nTangular.render('{{ $.title }}: {{ name }}', { name: 'Ann' }, repository);\n// Users: Ann\n\nvar template = Tangular.compile('{{ foreach n in items }}{{ if $index < $.limit }}{{ n }} {{ fi }}{{ end }}');\ntemplate({ items: ['a', 'b', 'c'] }, repository);\n// a b\n```\n\n## Vlastné oddeľovače\n\n`Tangular.compile(template, begin, end)` nahradí `{{` a `}}`. Obe hodnoty sú časťami regulárneho výrazu, takže špeciálne znaky treba escapovať:\n\n```js\nvar template = Tangular.compile('[[ name ]] and {{ other }}', '\\\\[\\\\[', '\\\\]\\\\]');\ntemplate({ name: 'Ann' }); // Ann and {{ other }}\n```\n\n## Zalomenia riadkov\n\nZalomenie riadka tesne pred značkou a na konci šablóny sa odstráni:\n\n```js\nTangular.render('a\\n{{ name }}\\nb\\n', { name: 'X' }); // \"aX\\nb\"\n```\n\n## Šablóny na stránke\n\nPríkaz `template` elementu `<ui-bind>` vykreslí šablónu Tangular s hodnotou z path. V šablóne je hodnota dostupná ako `value` a pri jej zmene sa šablóna vykreslí znova.\n\n```html\n<ui-bind path=\"team\" config=\"template\">\n  <script type=\"text/html\">\n    <ul>{{ foreach m in value.people }}<li>{{ m.name }}</li>{{ end }}</ul>\n  </script>\n</ui-bind>\n\n<script>\nSET('team', { people: [{ name: 'Ann' }, { name: 'Bob' }] });\n</script>\n```\n\nElement vykreslí `<ul><li>Ann</li><li>Bob</li></ul>`. Viac o väzbách sa dočítaš v časti [Dátová väzba](../data-binding/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:34.124Z"}
{"id":"JamcNh20d61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/routing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Routing","summary":"How to map URLs to functions in a single-page application with ROUTE(), REDIRECT() and NAV.","markdown":"---\ntitle: Routing\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/routing/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Routing\n\n> How to map URLs to functions in a single-page application with ROUTE(), REDIRECT() and NAV.\n\nRouting lets one HTML page behave like many. The library watches the URL, runs the function registered for it, and changes the URL without reloading the page. The server must return the same application page for every URL the application uses, so that opening a link directly works too.\n\n## Declaring routes\n\n`ROUTE(url, callback, [middleware], [init])` registers a route. Parts in curly brackets are dynamic, and their values are passed to the callback in order. `REDIRECT(url)` navigates to a URL.\n\n```js\nROUTE('/', function() {\n  console.log('home');\n});\n\nROUTE('/products/', function() {\n  console.log('list');\n});\n\nROUTE('/products/new/', function() {\n  console.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n  console.log('detail', id);\n});\n\nROUTE('/products/{id}/{tab}/', function(id, tab) {\n  console.log('tab', id, tab, this.url);\n});\n\nON('ready', function() {\n  setTimeout(function() {\n    REDIRECT('/products/');\n    REDIRECT('/products/new/');\n    REDIRECT('/products/AB-15/');\n    REDIRECT('/products/15/photos');\n  }, 300);\n});\n```\n\n```text\nhome\nlist\nform\ndetail AB-15\ntab 15 photos /products/15/photos/\n```\n\nThe route for the current URL runs when the application starts. Inside the callback, `this` is `NAV`. A URL gets a trailing slash when it has none, and a static route such as `/products/new/` wins over a dynamic one such as `/products/{id}/`.\n\nThe URL is compared in lowercase, so write the routes in lowercase. A route with a capital letter never matches. The values of dynamic parts keep their case:\n\n```js\nROUTE('/team/{name}/', function(name) {\n  console.log(name);\n});\n\nREDIRECT('/TEAM/AnnLee/'); // AnnLee\n```\n\n## Reading the current location\n\n```js\nROUTE('/search/', function() {\n  console.log(JSON.stringify(NAV.query));\n  console.log(NAV.url, '|', NAV.href, '|', NAV.queryraw);\n});\n\nREDIRECT('/search/?q=lamp&page=2');\n```\n\n```text\n{\"q\":\"lamp\",\"page\":\"2\"}\n/search/ | /search/?q=lamp&page=2 | q=lamp&page=2\n```\n\n| Property | Description |\n| --- | --- |\n| `NAV.url` | The current path without the query string. |\n| `NAV.href` | The URL passed to the last navigation. |\n| `NAV.query` | The parsed query string. All values are strings. |\n| `NAV.queryraw` | The query string without the leading `?`. |\n| `NAV.params` | An array with the values of the dynamic parts. |\n| `NAV.is404` | `true` when no route matches the current URL. |\n| `NAV.history` | An array of the previous URLs. |\n| `NAV.isback` | The number of URLs to go back to. |\n| `NAV.isforward` | The number of URLs to go forward to. |\n\n`NAV` is a normal path, so the markup can bind to it:\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Links\n\nA plain link reloads the page. `NAV.clientside(selector)` turns matching links into client-side navigation. The URL is read from `href`, `data-href` or `data-url`. Any element with the class `exec` and a `data-href` attribute navigates too.\n\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<a class=\"link\" data-href=\"/contact/\">Contact</a>\n<span class=\"exec\" data-href=\"/help/\">Help</span>\n\n<script>\nNAV.clientside('.link');\n</script>\n```\n\n## Moving through the history\n\n| Method | Description |\n| --- | --- |\n| `NAV.back()` | Goes to the previous URL. |\n| `NAV.forward()` | Goes to the next URL after going back. |\n| `NAV.prev()` | Returns the previous URL. |\n| `NAV.next()` | Returns the next URL. |\n| `NAV.refresh()`, `NAV.reload()` | Runs the route of the current URL again. |\n\n```js\nREDIRECT('/a/');\nREDIRECT('/a/b/');\nconsole.log(NAV.url, NAV.prev()); // /a/b/ /a/\n\nNAV.back();\nconsole.log(NAV.url, NAV.next()); // /a/ /a/b/\n\nNAV.forward();\nconsole.log(NAV.url);             // /a/b/\n\nREDIRECT('../');\nconsole.log(NAV.url);             // /a/\n```\n\n`REDIRECT('../')` goes one level up. The buttons of the browser work as well.\n\n`NAV.autosave()` keeps the history in the browser storage at each navigation, `NAV.save()` stores it once, and `NAV.load()` restores it:\n\n```js\nNAV.autosave();\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history)); // [\"/\",\"/a/\"]\n```\n\n## Middleware\n\nA middleware runs ahead of the route callback and decides if the route continues. `MIDDLEWARE(name, callback)` registers one, and the third argument of `ROUTE()` selects them.\n\n```js\nMIDDLEWARE('auth', function(next, options, roles, route) {\n  console.log('auth', JSON.stringify(options), roles.join(), route.id);\n  if (window.user)\n    next();\n  else\n    next(false);\n});\n\nROUTE('/admin/', function() {\n  console.log('admin page');\n}, ['auth', '@admin', '@editor', { title: 'Admin' }]);\n```\n\nWith no user, the first navigation prints only the `auth` line. Once `window.user` is set, the next one reaches the page:\n\n```text\nauth {\"title\":\"Admin\"} admin,editor /admin/\nauth {\"title\":\"Admin\"} admin,editor /admin/\nadmin page\n```\n\nThe middleware argument of `ROUTE()` is an array or a comma-separated string:\n\n| Value | Meaning |\n| --- | --- |\n| `name` | The name of a middleware. |\n| `@name` | A role, passed to the middleware in `roles`. |\n| `#name` | A code list to load with `CL()`. |\n| An object | Options, passed to the middleware in `options`. Only in an array. |\n\n`next()` continues with the next middleware. `next(false)` and `next(new Error())` stop the route. The route callback does not run either when the user navigates elsewhere while a middleware is still working.\n\n```js\nMIDDLEWARE('first', function(next) { console.log('first'); next(); });\nMIDDLEWARE('second', function(next) { console.log('second'); next(); });\n\nCLINIT('countries', function(next) {\n  console.log('loading countries');\n  next([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n  console.log('orders', DEF.cl.countries.length);\n}, 'first,second,#countries');\n```\n\n```text\nfirst\nsecond\nloading countries\norders 1\n```\n\n`MIDDLEWARE(names, callback)` with an array of names runs those middleware outside of any route and then calls the callback:\n\n```js\nMIDDLEWARE(['first', 'second'], function() {\n  console.log('both done');\n});\n```\n\n## Preparing a route once\n\nThe `init` function runs once, on the first visit of a route, and receives a `next` callback. It suits work such as downloading the part of the application that the route needs.\n\n```js\nROUTE('/reports/', function() {\n  console.log('reports');\n}, function(next) {\n  console.log('prepare once');\n  next();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n```\n\n```text\nprepare once\nreports\nreports\n```\n\nWhen a route also has middleware, `init` is the fourth argument of `ROUTE()`.\n\n## Events\n\n| Event | Arguments | Description |\n| --- | --- | --- |\n| `location` | `url` | The URL changes. Emitted ahead of the route callback. |\n| `404` | | No route matches the URL. |\n| `route` | `url` | A new route is registered. |\n\n```js\nON('location', function(url) {\n  console.log('location', url);\n});\n\nON('404', function() {\n  console.log('not found', NAV.url, NAV.is404);\n});\n\nREDIRECT('/missing/');\n```\n\n```text\nlocation /missing/\nnot found /missing/ true\n```\n\n## Adding and removing routes at runtime\n\nA route registered while its URL is showing the 404 state runs immediately, so a route can arrive later from an imported file. `NAV.remove(url)` removes a route.\n\n```js\nREDIRECT('/missing/');\n\nROUTE('/missing/', function() {\n  console.log('added later');\n});\n\nconsole.log(NAV.is404); // false\n\nNAV.remove('/missing/');\n```\n\n## Keeping a query parameter\n\n`NAV.remember(name, value)` adds a parameter to every following `REDIRECT()`. Passing `null` as the value stops it.\n\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/?lang=de\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/\n```\n\n## Routing with hashes\n\nWith `NAV.hashtags = true`, routes are driven by the hash part of the URL. Set it at the start of the application, write the routes with a leading `#`, and navigate with links or `location.hash`.\n\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n  console.log('inbox', NAV.url);\n});\n\nROUTE('#sent', function() {\n  console.log('sent', NAV.url);\n});\n\nlocation.hash = '#inbox'; // inbox #inbox\n```\n\n## Routing without changing the address bar\n\n`NAV.custom()` keeps all navigation inside the application. Routes and `REDIRECT()` work as usual, and the address bar stays as it is. This is useful for an application embedded in another page. Call it at the start of the application.\n\n```js\nNAV.custom();\n\nROUTE('/', function() {\n  console.log('home');\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNh20d61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/routing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Routing","summary":"Wie du in einer Single-Page-Anwendung mit ROUTE(), REDIRECT() und NAV URLs auf Funktionen abbildest.","markdown":"---\ntitle: Routing\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/routing/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Routing\n\n> Wie du in einer Single-Page-Anwendung mit ROUTE(), REDIRECT() und NAV URLs auf Funktionen abbildest.\n\nMit Routing verhält sich eine HTML-Seite wie viele. Die Bibliothek beobachtet die URL, führt die dafür registrierte Funktion aus und ändert die URL, ohne die Seite neu zu laden. Der Server muss für jede URL, die die Anwendung verwendet, dieselbe Anwendungsseite zurückgeben, damit auch das direkte Öffnen eines Links funktioniert.\n\n## Routen deklarieren\n\n`ROUTE(url, callback, [middleware], [init])` registriert eine Route. Teile in geschweiften Klammern sind dynamisch, und ihre Werte werden der Reihe nach an den Callback übergeben. `REDIRECT(url)` navigiert zu einer URL.\n\n```js\nROUTE('/', function() {\n  console.log('home');\n});\n\nROUTE('/products/', function() {\n  console.log('list');\n});\n\nROUTE('/products/new/', function() {\n  console.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n  console.log('detail', id);\n});\n\nROUTE('/products/{id}/{tab}/', function(id, tab) {\n  console.log('tab', id, tab, this.url);\n});\n\nON('ready', function() {\n  setTimeout(function() {\n    REDIRECT('/products/');\n    REDIRECT('/products/new/');\n    REDIRECT('/products/AB-15/');\n    REDIRECT('/products/15/photos');\n  }, 300);\n});\n```\n\n```text\nhome\nlist\nform\ndetail AB-15\ntab 15 photos /products/15/photos/\n```\n\nDie Route der aktuellen URL läuft beim Start der Anwendung. Im Callback ist `this` gleich `NAV`. Eine URL ohne abschließenden Schrägstrich erhält einen, und eine statische Route wie `/products/new/` hat Vorrang vor einer dynamischen wie `/products/{id}/`.\n\nDie URL wird in Kleinbuchstaben verglichen, schreibe die Routen also kleingeschrieben. Eine Route mit einem Großbuchstaben passt nie. Die Werte dynamischer Teile behalten ihre Schreibweise:\n\n```js\nROUTE('/team/{name}/', function(name) {\n  console.log(name);\n});\n\nREDIRECT('/TEAM/AnnLee/'); // AnnLee\n```\n\n## Den aktuellen Ort lesen\n\n```js\nROUTE('/search/', function() {\n  console.log(JSON.stringify(NAV.query));\n  console.log(NAV.url, '|', NAV.href, '|', NAV.queryraw);\n});\n\nREDIRECT('/search/?q=lamp&page=2');\n```\n\n```text\n{\"q\":\"lamp\",\"page\":\"2\"}\n/search/ | /search/?q=lamp&page=2 | q=lamp&page=2\n```\n\n| Eigenschaft | Beschreibung |\n| --- | --- |\n| `NAV.url` | Der aktuelle Path ohne Query-String. |\n| `NAV.href` | Die an die letzte Navigation übergebene URL. |\n| `NAV.query` | Der geparste Query-String. Alle Werte sind Strings. |\n| `NAV.queryraw` | Der Query-String ohne das führende `?`. |\n| `NAV.params` | Ein Array mit den Werten der dynamischen Teile. |\n| `NAV.is404` | `true`, wenn keine Route zur aktuellen URL passt. |\n| `NAV.history` | Ein Array der vorherigen URLs. |\n| `NAV.isback` | Die Anzahl der URLs, zu denen du zurückgehen kannst. |\n| `NAV.isforward` | Die Anzahl der URLs, zu denen du vorwärtsgehen kannst. |\n\n`NAV` ist ein normaler Path, das Markup kann sich also daran binden:\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Links\n\nEin einfacher Link lädt die Seite neu. `NAV.clientside(selector)` macht aus passenden Links eine clientseitige Navigation. Die URL wird aus `href`, `data-href` oder `data-url` gelesen. Auch jedes Element mit der Klasse `exec` und einem Attribut `data-href` navigiert.\n\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<a class=\"link\" data-href=\"/contact/\">Contact</a>\n<span class=\"exec\" data-href=\"/help/\">Help</span>\n\n<script>\nNAV.clientside('.link');\n</script>\n```\n\n## Durch den Verlauf gehen\n\n| Methode | Beschreibung |\n| --- | --- |\n| `NAV.back()` | Geht zur vorherigen URL. |\n| `NAV.forward()` | Geht nach dem Zurückgehen zur nächsten URL. |\n| `NAV.prev()` | Gibt die vorherige URL zurück. |\n| `NAV.next()` | Gibt die nächste URL zurück. |\n| `NAV.refresh()`, `NAV.reload()` | Führt die Route der aktuellen URL erneut aus. |\n\n```js\nREDIRECT('/a/');\nREDIRECT('/a/b/');\nconsole.log(NAV.url, NAV.prev()); // /a/b/ /a/\n\nNAV.back();\nconsole.log(NAV.url, NAV.next()); // /a/ /a/b/\n\nNAV.forward();\nconsole.log(NAV.url);             // /a/b/\n\nREDIRECT('../');\nconsole.log(NAV.url);             // /a/\n```\n\n`REDIRECT('../')` geht eine Ebene nach oben. Auch die Schaltflächen des Browsers funktionieren.\n\n`NAV.autosave()` speichert den Verlauf bei jeder Navigation im Browserspeicher, `NAV.save()` speichert ihn einmalig, und `NAV.load()` stellt ihn wieder her:\n\n```js\nNAV.autosave();\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history)); // [\"/\",\"/a/\"]\n```\n\n## Middleware\n\nEine Middleware läuft vor dem Callback der Route und entscheidet, ob die Route fortgesetzt wird. `MIDDLEWARE(name, callback)` registriert eine Middleware, und das dritte Argument von `ROUTE()` wählt die zu verwendenden aus.\n\n```js\nMIDDLEWARE('auth', function(next, options, roles, route) {\n  console.log('auth', JSON.stringify(options), roles.join(), route.id);\n  if (window.user)\n    next();\n  else\n    next(false);\n});\n\nROUTE('/admin/', function() {\n  console.log('admin page');\n}, ['auth', '@admin', '@editor', { title: 'Admin' }]);\n```\n\nOhne Benutzer gibt die erste Navigation nur die Zeile `auth` aus. Sobald `window.user` gesetzt ist, erreicht die nächste die Seite:\n\n```text\nauth {\"title\":\"Admin\"} admin,editor /admin/\nauth {\"title\":\"Admin\"} admin,editor /admin/\nadmin page\n```\n\nDas Middleware-Argument von `ROUTE()` ist ein Array oder ein String mit durch Kommas getrennten Werten:\n\n| Wert | Bedeutung |\n| --- | --- |\n| `name` | Der Name einer Middleware. |\n| `@name` | Eine Rolle, die der Middleware in `roles` übergeben wird. |\n| `#name` | Eine Codeliste, die mit `CL()` geladen wird. |\n| Ein Objekt | Optionen, die der Middleware in `options` übergeben werden. Nur in einem Array. |\n\n`next()` fährt mit der nächsten Middleware fort. `next(false)` und `next(new Error())` stoppen die Route. Der Callback der Route läuft auch dann nicht, wenn der Benutzer woandershin navigiert, während eine Middleware noch arbeitet.\n\n```js\nMIDDLEWARE('first', function(next) { console.log('first'); next(); });\nMIDDLEWARE('second', function(next) { console.log('second'); next(); });\n\nCLINIT('countries', function(next) {\n  console.log('loading countries');\n  next([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n  console.log('orders', DEF.cl.countries.length);\n}, 'first,second,#countries');\n```\n\n```text\nfirst\nsecond\nloading countries\norders 1\n```\n\n`MIDDLEWARE(names, callback)` mit einem Array von Namen führt diese Middleware außerhalb jeder Route aus und ruft dann den Callback auf:\n\n```js\nMIDDLEWARE(['first', 'second'], function() {\n  console.log('both done');\n});\n```\n\n## Eine Route einmalig vorbereiten\n\nDie Funktion `init` läuft einmal, beim ersten Besuch einer Route, und erhält einen Callback `next`. Das eignet sich etwa, um den Teil der Anwendung herunterzuladen, den die Route braucht.\n\n```js\nROUTE('/reports/', function() {\n  console.log('reports');\n}, function(next) {\n  console.log('prepare once');\n  next();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n```\n\n```text\nprepare once\nreports\nreports\n```\n\nHat eine Route auch Middleware, ist `init` das vierte Argument von `ROUTE()`.\n\n## Events\n\n| Event | Argumente | Beschreibung |\n| --- | --- | --- |\n| `location` | `url` | Die URL ändert sich. Wird vor dem Callback der Route ausgelöst. |\n| `404` | | Keine Route passt zur URL. |\n| `route` | `url` | Eine neue Route wird registriert. |\n\n```js\nON('location', function(url) {\n  console.log('location', url);\n});\n\nON('404', function() {\n  console.log('not found', NAV.url, NAV.is404);\n});\n\nREDIRECT('/missing/');\n```\n\n```text\nlocation /missing/\nnot found /missing/ true\n```\n\n## Routen zur Laufzeit hinzufügen und entfernen\n\nEine Route, die registriert wird, während ihre URL den 404-Zustand zeigt, läuft sofort. Eine Route kann also später aus einer importierten Datei kommen. `NAV.remove(url)` entfernt eine Route.\n\n```js\nREDIRECT('/missing/');\n\nROUTE('/missing/', function() {\n  console.log('added later');\n});\n\nconsole.log(NAV.is404); // false\n\nNAV.remove('/missing/');\n```\n\n## Einen Query-Parameter beibehalten\n\n`NAV.remember(name, value)` fügt jedem folgenden `REDIRECT()` einen Parameter hinzu. Mit `null` als Wert endet das.\n\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/?lang=de\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/\n```\n\n## Routing mit Hashes\n\nMit `NAV.hashtags = true` werden Routen über den Hash-Teil der URL gesteuert. Setze das beim Start der Anwendung, schreibe die Routen mit führendem `#` und navigiere mit Links oder `location.hash`.\n\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n  console.log('inbox', NAV.url);\n});\n\nROUTE('#sent', function() {\n  console.log('sent', NAV.url);\n});\n\nlocation.hash = '#inbox'; // inbox #inbox\n```\n\n## Routing ohne Änderung der Adressleiste\n\n`NAV.custom()` hält die gesamte Navigation innerhalb der Anwendung. Routen und `REDIRECT()` funktionieren wie gewohnt, und die Adressleiste bleibt unverändert. Das ist nützlich für eine Anwendung, die in eine andere Seite eingebettet ist. Rufe es beim Start der Anwendung auf.\n\n```js\nNAV.custom();\n\nROUTE('/', function() {\n  console.log('home');\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNh20d61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/routing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Enrutamiento","summary":"Cómo asociar URL a funciones en una aplicación de una sola página con ROUTE(), REDIRECT() y NAV.","markdown":"---\ntitle: Enrutamiento\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/routing/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Enrutamiento\n\n> Cómo asociar URL a funciones en una aplicación de una sola página con ROUTE(), REDIRECT() y NAV.\n\nEl enrutamiento permite que una sola página HTML se comporte como muchas. La biblioteca vigila la URL, ejecuta la función registrada para ella y cambia la URL sin recargar la página. El servidor debe devolver la misma página de la aplicación para todas las URL que use la aplicación, de modo que abrir un enlace directamente también funcione.\n\n## Declarar rutas\n\n`ROUTE(url, callback, [middleware], [init])` registra una ruta. Las partes entre llaves son dinámicas, y sus valores se pasan al callback en orden. `REDIRECT(url)` navega a una URL.\n\n```js\nROUTE('/', function() {\n  console.log('home');\n});\n\nROUTE('/products/', function() {\n  console.log('list');\n});\n\nROUTE('/products/new/', function() {\n  console.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n  console.log('detail', id);\n});\n\nROUTE('/products/{id}/{tab}/', function(id, tab) {\n  console.log('tab', id, tab, this.url);\n});\n\nON('ready', function() {\n  setTimeout(function() {\n    REDIRECT('/products/');\n    REDIRECT('/products/new/');\n    REDIRECT('/products/AB-15/');\n    REDIRECT('/products/15/photos');\n  }, 300);\n});\n```\n\n```text\nhome\nlist\nform\ndetail AB-15\ntab 15 photos /products/15/photos/\n```\n\nLa ruta de la URL actual se ejecuta al arrancar la aplicación. Dentro del callback, `this` es `NAV`. Si una URL no termina en barra, se le añade una, y una ruta estática como `/products/new/` tiene prioridad sobre una dinámica como `/products/{id}/`.\n\nLa URL se compara en minúsculas, así que escribe las rutas en minúsculas. Una ruta con alguna mayúscula nunca coincide. Los valores de las partes dinámicas conservan sus mayúsculas y minúsculas:\n\n```js\nROUTE('/team/{name}/', function(name) {\n  console.log(name);\n});\n\nREDIRECT('/TEAM/AnnLee/'); // AnnLee\n```\n\n## Leer la ubicación actual\n\n```js\nROUTE('/search/', function() {\n  console.log(JSON.stringify(NAV.query));\n  console.log(NAV.url, '|', NAV.href, '|', NAV.queryraw);\n});\n\nREDIRECT('/search/?q=lamp&page=2');\n```\n\n```text\n{\"q\":\"lamp\",\"page\":\"2\"}\n/search/ | /search/?q=lamp&page=2 | q=lamp&page=2\n```\n\n| Propiedad | Descripción |\n| --- | --- |\n| `NAV.url` | La ruta actual sin la cadena de consulta. |\n| `NAV.href` | La URL pasada a la última navegación. |\n| `NAV.query` | La cadena de consulta analizada. Todos los valores son cadenas. |\n| `NAV.queryraw` | La cadena de consulta sin el `?` inicial. |\n| `NAV.params` | Un array con los valores de las partes dinámicas. |\n| `NAV.is404` | `true` cuando ninguna ruta coincide con la URL actual. |\n| `NAV.history` | Un array con las URL anteriores. |\n| `NAV.isback` | El número de URL a las que se puede retroceder. |\n| `NAV.isforward` | El número de URL a las que se puede avanzar. |\n\n`NAV` es un path normal, así que el marcado puede enlazarse a él:\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Enlaces\n\nUn enlace normal recarga la página. `NAV.clientside(selector)` convierte los enlaces que coinciden en navegación del lado del cliente. La URL se lee de `href`, `data-href` o `data-url`. Cualquier elemento con la clase `exec` y un atributo `data-href` también navega.\n\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<a class=\"link\" data-href=\"/contact/\">Contact</a>\n<span class=\"exec\" data-href=\"/help/\">Help</span>\n\n<script>\nNAV.clientside('.link');\n</script>\n```\n\n## Moverse por el historial\n\n| Método | Descripción |\n| --- | --- |\n| `NAV.back()` | Va a la URL anterior. |\n| `NAV.forward()` | Va a la URL siguiente después de haber retrocedido. |\n| `NAV.prev()` | Devuelve la URL anterior. |\n| `NAV.next()` | Devuelve la URL siguiente. |\n| `NAV.refresh()`, `NAV.reload()` | Vuelve a ejecutar la ruta de la URL actual. |\n\n```js\nREDIRECT('/a/');\nREDIRECT('/a/b/');\nconsole.log(NAV.url, NAV.prev()); // /a/b/ /a/\n\nNAV.back();\nconsole.log(NAV.url, NAV.next()); // /a/ /a/b/\n\nNAV.forward();\nconsole.log(NAV.url);             // /a/b/\n\nREDIRECT('../');\nconsole.log(NAV.url);             // /a/\n```\n\n`REDIRECT('../')` sube un nivel. Los botones del navegador también funcionan.\n\n`NAV.autosave()` guarda el historial en el almacenamiento del navegador en cada navegación, `NAV.save()` lo guarda una vez y `NAV.load()` lo restaura:\n\n```js\nNAV.autosave();\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history)); // [\"/\",\"/a/\"]\n```\n\n## Middleware\n\nUn middleware se ejecuta antes del callback de la ruta y decide si la ruta continúa. `MIDDLEWARE(name, callback)` registra uno, y el tercer argumento de `ROUTE()` los selecciona.\n\n```js\nMIDDLEWARE('auth', function(next, options, roles, route) {\n  console.log('auth', JSON.stringify(options), roles.join(), route.id);\n  if (window.user)\n    next();\n  else\n    next(false);\n});\n\nROUTE('/admin/', function() {\n  console.log('admin page');\n}, ['auth', '@admin', '@editor', { title: 'Admin' }]);\n```\n\nSin usuario, la primera navegación imprime solo la línea `auth`. Cuando se establece `window.user`, la siguiente llega a la página:\n\n```text\nauth {\"title\":\"Admin\"} admin,editor /admin/\nauth {\"title\":\"Admin\"} admin,editor /admin/\nadmin page\n```\n\nEl argumento middleware de `ROUTE()` es un array o una cadena separada por comas:\n\n| Valor | Significado |\n| --- | --- |\n| `name` | El nombre de un middleware. |\n| `@name` | Un rol, que se pasa al middleware en `roles`. |\n| `#name` | Una lista de códigos que se carga con `CL()`. |\n| Un objeto | Opciones, que se pasan al middleware en `options`. Solo en un array. |\n\n`next()` continúa con el siguiente middleware. `next(false)` y `next(new Error())` detienen la ruta. El callback de la ruta tampoco se ejecuta cuando el usuario navega a otro sitio mientras un middleware sigue trabajando.\n\n```js\nMIDDLEWARE('first', function(next) { console.log('first'); next(); });\nMIDDLEWARE('second', function(next) { console.log('second'); next(); });\n\nCLINIT('countries', function(next) {\n  console.log('loading countries');\n  next([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n  console.log('orders', DEF.cl.countries.length);\n}, 'first,second,#countries');\n```\n\n```text\nfirst\nsecond\nloading countries\norders 1\n```\n\n`MIDDLEWARE(names, callback)` con un array de nombres ejecuta esos middleware fuera de cualquier ruta y después llama al callback:\n\n```js\nMIDDLEWARE(['first', 'second'], function() {\n  console.log('both done');\n});\n```\n\n## Preparar una ruta una sola vez\n\nLa función `init` se ejecuta una vez, en la primera visita a una ruta, y recibe un callback `next`. Va bien para tareas como descargar la parte de la aplicación que necesita la ruta.\n\n```js\nROUTE('/reports/', function() {\n  console.log('reports');\n}, function(next) {\n  console.log('prepare once');\n  next();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n```\n\n```text\nprepare once\nreports\nreports\n```\n\nCuando una ruta también tiene middleware, `init` es el cuarto argumento de `ROUTE()`.\n\n## Eventos\n\n| Evento | Argumentos | Descripción |\n| --- | --- | --- |\n| `location` | `url` | La URL cambia. Se emite antes del callback de la ruta. |\n| `404` | | Ninguna ruta coincide con la URL. |\n| `route` | `url` | Se registra una ruta nueva. |\n\n```js\nON('location', function(url) {\n  console.log('location', url);\n});\n\nON('404', function() {\n  console.log('not found', NAV.url, NAV.is404);\n});\n\nREDIRECT('/missing/');\n```\n\n```text\nlocation /missing/\nnot found /missing/ true\n```\n\n## Añadir y eliminar rutas en tiempo de ejecución\n\nUna ruta registrada mientras su URL muestra el estado 404 se ejecuta de inmediato, así que una ruta puede llegar más tarde desde un archivo importado. `NAV.remove(url)` elimina una ruta.\n\n```js\nREDIRECT('/missing/');\n\nROUTE('/missing/', function() {\n  console.log('added later');\n});\n\nconsole.log(NAV.is404); // false\n\nNAV.remove('/missing/');\n```\n\n## Conservar un parámetro de consulta\n\n`NAV.remember(name, value)` añade un parámetro a cada `REDIRECT()` posterior. Si pasas `null` como valor, deja de añadirlo.\n\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/?lang=de\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/\n```\n\n## Enrutamiento con hashes\n\nCon `NAV.hashtags = true`, las rutas se rigen por la parte hash de la URL. Establécelo al arrancar la aplicación, escribe las rutas con un `#` inicial y navega con enlaces o con `location.hash`.\n\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n  console.log('inbox', NAV.url);\n});\n\nROUTE('#sent', function() {\n  console.log('sent', NAV.url);\n});\n\nlocation.hash = '#inbox'; // inbox #inbox\n```\n\n## Enrutamiento sin cambiar la barra de direcciones\n\n`NAV.custom()` mantiene toda la navegación dentro de la aplicación. Las rutas y `REDIRECT()` funcionan como siempre, y la barra de direcciones se queda como está. Es útil para una aplicación incrustada en otra página. Llámalo al arrancar la aplicación.\n\n```js\nNAV.custom();\n\nROUTE('/', function() {\n  console.log('home');\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNh20d61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/routing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Routage","summary":"Comment associer des URL à des fonctions dans une application monopage avec ROUTE(), REDIRECT() et NAV.","markdown":"---\ntitle: Routage\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/routing/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Routage\n\n> Comment associer des URL à des fonctions dans une application monopage avec ROUTE(), REDIRECT() et NAV.\n\nLe routage permet à une seule page HTML de se comporter comme plusieurs. La bibliothèque surveille l'URL, exécute la fonction enregistrée pour celle-ci et change l'URL sans recharger la page. Le serveur doit renvoyer la même page d'application pour chaque URL utilisée par l'application, afin que l'ouverture directe d'un lien fonctionne aussi.\n\n## Déclarer des routes\n\n`ROUTE(url, callback, [middleware], [init])` enregistre une route. Les parties entre accolades sont dynamiques, et leurs valeurs sont passées au callback dans l'ordre. `REDIRECT(url)` navigue vers une URL.\n\n```js\nROUTE('/', function() {\n  console.log('home');\n});\n\nROUTE('/products/', function() {\n  console.log('list');\n});\n\nROUTE('/products/new/', function() {\n  console.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n  console.log('detail', id);\n});\n\nROUTE('/products/{id}/{tab}/', function(id, tab) {\n  console.log('tab', id, tab, this.url);\n});\n\nON('ready', function() {\n  setTimeout(function() {\n    REDIRECT('/products/');\n    REDIRECT('/products/new/');\n    REDIRECT('/products/AB-15/');\n    REDIRECT('/products/15/photos');\n  }, 300);\n});\n```\n\n```text\nhome\nlist\nform\ndetail AB-15\ntab 15 photos /products/15/photos/\n```\n\nLa route de l'URL actuelle s'exécute au démarrage de l'application. Dans le callback, `this` vaut `NAV`. Une URL reçoit une barre oblique finale quand elle n'en a pas, et une route statique comme `/products/new/` l'emporte sur une route dynamique comme `/products/{id}/`.\n\nL'URL est comparée en minuscules : écris donc les routes en minuscules. Une route contenant une majuscule ne correspond jamais. Les valeurs des parties dynamiques conservent leur casse :\n\n```js\nROUTE('/team/{name}/', function(name) {\n  console.log(name);\n});\n\nREDIRECT('/TEAM/AnnLee/'); // AnnLee\n```\n\n## Lire l'emplacement actuel\n\n```js\nROUTE('/search/', function() {\n  console.log(JSON.stringify(NAV.query));\n  console.log(NAV.url, '|', NAV.href, '|', NAV.queryraw);\n});\n\nREDIRECT('/search/?q=lamp&page=2');\n```\n\n```text\n{\"q\":\"lamp\",\"page\":\"2\"}\n/search/ | /search/?q=lamp&page=2 | q=lamp&page=2\n```\n\n| Propriété | Description |\n| --- | --- |\n| `NAV.url` | Le chemin actuel sans la chaîne de requête. |\n| `NAV.href` | L'URL passée à la dernière navigation. |\n| `NAV.query` | La chaîne de requête analysée. Toutes les valeurs sont des chaînes. |\n| `NAV.queryraw` | La chaîne de requête sans le `?` initial. |\n| `NAV.params` | Un tableau contenant les valeurs des parties dynamiques. |\n| `NAV.is404` | `true` quand aucune route ne correspond à l'URL actuelle. |\n| `NAV.history` | Un tableau des URL précédentes. |\n| `NAV.isback` | Le nombre d'URL vers lesquelles revenir en arrière. |\n| `NAV.isforward` | Le nombre d'URL vers lesquelles avancer. |\n\n`NAV` est un path normal : le balisage peut donc s'y lier :\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Liens\n\nUn lien ordinaire recharge la page. `NAV.clientside(selector)` transforme les liens correspondants en navigation côté client. L'URL est lue dans `href`, `data-href` ou `data-url`. Tout élément doté de la classe `exec` et d'un attribut `data-href` navigue également.\n\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<a class=\"link\" data-href=\"/contact/\">Contact</a>\n<span class=\"exec\" data-href=\"/help/\">Help</span>\n\n<script>\nNAV.clientside('.link');\n</script>\n```\n\n## Se déplacer dans l'historique\n\n| Méthode | Description |\n| --- | --- |\n| `NAV.back()` | Va à l'URL précédente. |\n| `NAV.forward()` | Va à l'URL suivante après un retour en arrière. |\n| `NAV.prev()` | Renvoie l'URL précédente. |\n| `NAV.next()` | Renvoie l'URL suivante. |\n| `NAV.refresh()`, `NAV.reload()` | Exécute de nouveau la route de l'URL actuelle. |\n\n```js\nREDIRECT('/a/');\nREDIRECT('/a/b/');\nconsole.log(NAV.url, NAV.prev()); // /a/b/ /a/\n\nNAV.back();\nconsole.log(NAV.url, NAV.next()); // /a/ /a/b/\n\nNAV.forward();\nconsole.log(NAV.url);             // /a/b/\n\nREDIRECT('../');\nconsole.log(NAV.url);             // /a/\n```\n\n`REDIRECT('../')` remonte d'un niveau. Les boutons du navigateur fonctionnent aussi.\n\n`NAV.autosave()` conserve l'historique dans le stockage du navigateur à chaque navigation, `NAV.save()` l'enregistre une fois et `NAV.load()` le restaure :\n\n```js\nNAV.autosave();\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history)); // [\"/\",\"/a/\"]\n```\n\n## Middleware\n\nUn middleware s'exécute avant le callback de la route et décide si la route continue. `MIDDLEWARE(name, callback)` en enregistre un, et le troisième argument de `ROUTE()` les sélectionne.\n\n```js\nMIDDLEWARE('auth', function(next, options, roles, route) {\n  console.log('auth', JSON.stringify(options), roles.join(), route.id);\n  if (window.user)\n    next();\n  else\n    next(false);\n});\n\nROUTE('/admin/', function() {\n  console.log('admin page');\n}, ['auth', '@admin', '@editor', { title: 'Admin' }]);\n```\n\nSans utilisateur, la première navigation n'affiche que la ligne `auth`. Une fois `window.user` défini, la suivante atteint la page :\n\n```text\nauth {\"title\":\"Admin\"} admin,editor /admin/\nauth {\"title\":\"Admin\"} admin,editor /admin/\nadmin page\n```\n\nL'argument middleware de `ROUTE()` est un tableau ou une chaîne séparée par des virgules :\n\n| Valeur | Signification |\n| --- | --- |\n| `name` | Le nom d'un middleware. |\n| `@name` | Un rôle, passé au middleware dans `roles`. |\n| `#name` | Une liste de codes à charger avec `CL()`. |\n| Un objet | Des options, passées au middleware dans `options`. Uniquement dans un tableau. |\n\n`next()` continue avec le middleware suivant. `next(false)` et `next(new Error())` arrêtent la route. Le callback de la route ne s'exécute pas non plus quand l'utilisateur navigue ailleurs alors qu'un middleware est encore en cours.\n\n```js\nMIDDLEWARE('first', function(next) { console.log('first'); next(); });\nMIDDLEWARE('second', function(next) { console.log('second'); next(); });\n\nCLINIT('countries', function(next) {\n  console.log('loading countries');\n  next([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n  console.log('orders', DEF.cl.countries.length);\n}, 'first,second,#countries');\n```\n\n```text\nfirst\nsecond\nloading countries\norders 1\n```\n\n`MIDDLEWARE(names, callback)` avec un tableau de noms exécute ces middlewares en dehors de toute route, puis appelle le callback :\n\n```js\nMIDDLEWARE(['first', 'second'], function() {\n  console.log('both done');\n});\n```\n\n## Préparer une route une seule fois\n\nLa fonction `init` s'exécute une seule fois, à la première visite d'une route, et reçoit un callback `next`. Elle convient à des tâches comme le téléchargement de la partie de l'application dont la route a besoin.\n\n```js\nROUTE('/reports/', function() {\n  console.log('reports');\n}, function(next) {\n  console.log('prepare once');\n  next();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n```\n\n```text\nprepare once\nreports\nreports\n```\n\nQuand une route a aussi un middleware, `init` est le quatrième argument de `ROUTE()`.\n\n## Événements\n\n| Événement | Arguments | Description |\n| --- | --- | --- |\n| `location` | `url` | L'URL change. Émis avant le callback de la route. |\n| `404` | | Aucune route ne correspond à l'URL. |\n| `route` | `url` | Une nouvelle route est enregistrée. |\n\n```js\nON('location', function(url) {\n  console.log('location', url);\n});\n\nON('404', function() {\n  console.log('not found', NAV.url, NAV.is404);\n});\n\nREDIRECT('/missing/');\n```\n\n```text\nlocation /missing/\nnot found /missing/ true\n```\n\n## Ajouter et supprimer des routes à l'exécution\n\nUne route enregistrée alors que son URL affiche l'état 404 s'exécute immédiatement : une route peut donc arriver plus tard depuis un fichier importé. `NAV.remove(url)` supprime une route.\n\n```js\nREDIRECT('/missing/');\n\nROUTE('/missing/', function() {\n  console.log('added later');\n});\n\nconsole.log(NAV.is404); // false\n\nNAV.remove('/missing/');\n```\n\n## Conserver un paramètre de requête\n\n`NAV.remember(name, value)` ajoute un paramètre à chaque `REDIRECT()` suivant. Passer `null` comme valeur y met fin.\n\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/?lang=de\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/\n```\n\n## Routage avec des hachages\n\nAvec `NAV.hashtags = true`, les routes sont pilotées par la partie hachage de l'URL. Définis-le au démarrage de l'application, écris les routes avec un `#` initial et navigue avec des liens ou `location.hash`.\n\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n  console.log('inbox', NAV.url);\n});\n\nROUTE('#sent', function() {\n  console.log('sent', NAV.url);\n});\n\nlocation.hash = '#inbox'; // inbox #inbox\n```\n\n## Routage sans modifier la barre d'adresse\n\n`NAV.custom()` garde toute la navigation à l'intérieur de l'application. Les routes et `REDIRECT()` fonctionnent comme d'habitude, et la barre d'adresse reste telle quelle. C'est utile pour une application intégrée dans une autre page. Appelle-le au démarrage de l'application.\n\n```js\nNAV.custom();\n\nROUTE('/', function() {\n  console.log('home');\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNh20d61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/routing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Routing","summary":"Come associare gli URL a funzioni in un'applicazione a pagina singola con ROUTE(), REDIRECT() e NAV.","markdown":"---\ntitle: Routing\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/routing/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Routing\n\n> Come associare gli URL a funzioni in un'applicazione a pagina singola con ROUTE(), REDIRECT() e NAV.\n\nIl routing permette a una sola pagina HTML di comportarsi come tante pagine. La libreria osserva l'URL, esegue la funzione registrata per quell'URL e lo cambia senza ricaricare la pagina. Il server deve restituire la stessa pagina dell'applicazione per ogni URL usato dall'applicazione, così funziona anche l'apertura diretta di un link.\n\n## Dichiarare le rotte\n\n`ROUTE(url, callback, [middleware], [init])` registra una rotta. Le parti tra parentesi graffe sono dinamiche e i loro valori vengono passati in ordine alla callback. `REDIRECT(url)` naviga verso un URL.\n\n```js\nROUTE('/', function() {\n  console.log('home');\n});\n\nROUTE('/products/', function() {\n  console.log('list');\n});\n\nROUTE('/products/new/', function() {\n  console.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n  console.log('detail', id);\n});\n\nROUTE('/products/{id}/{tab}/', function(id, tab) {\n  console.log('tab', id, tab, this.url);\n});\n\nON('ready', function() {\n  setTimeout(function() {\n    REDIRECT('/products/');\n    REDIRECT('/products/new/');\n    REDIRECT('/products/AB-15/');\n    REDIRECT('/products/15/photos');\n  }, 300);\n});\n```\n\n```text\nhome\nlist\nform\ndetail AB-15\ntab 15 photos /products/15/photos/\n```\n\nLa rotta dell'URL corrente viene eseguita all'avvio dell'applicazione. Dentro la callback, `this` è `NAV`. Un URL senza barra finale la riceve automaticamente e una rotta statica come `/products/new/` ha la precedenza su una dinamica come `/products/{id}/`.\n\nL'URL viene confrontato in minuscolo, quindi scrivi le rotte in minuscolo. Una rotta con una lettera maiuscola non corrisponde mai. I valori delle parti dinamiche mantengono maiuscole e minuscole:\n\n```js\nROUTE('/team/{name}/', function(name) {\n  console.log(name);\n});\n\nREDIRECT('/TEAM/AnnLee/'); // AnnLee\n```\n\n## Leggere la posizione corrente\n\n```js\nROUTE('/search/', function() {\n  console.log(JSON.stringify(NAV.query));\n  console.log(NAV.url, '|', NAV.href, '|', NAV.queryraw);\n});\n\nREDIRECT('/search/?q=lamp&page=2');\n```\n\n```text\n{\"q\":\"lamp\",\"page\":\"2\"}\n/search/ | /search/?q=lamp&page=2 | q=lamp&page=2\n```\n\n| Proprietà | Descrizione |\n| --- | --- |\n| `NAV.url` | Il path corrente senza la stringa di query. |\n| `NAV.href` | L'URL passato all'ultima navigazione. |\n| `NAV.query` | La stringa di query analizzata. Tutti i valori sono stringhe. |\n| `NAV.queryraw` | La stringa di query senza il `?` iniziale. |\n| `NAV.params` | Un array con i valori delle parti dinamiche. |\n| `NAV.is404` | `true` quando nessuna rotta corrisponde all'URL corrente. |\n| `NAV.history` | Un array degli URL precedenti. |\n| `NAV.isback` | Il numero di URL a cui puoi tornare indietro. |\n| `NAV.isforward` | Il numero di URL verso cui puoi andare avanti. |\n\n`NAV` è un normale path, quindi il markup può associarsi a esso:\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Link\n\nUn link semplice ricarica la pagina. `NAV.clientside(selector)` trasforma i link corrispondenti in navigazione lato client. L'URL viene letto da `href`, `data-href` o `data-url`. Anche qualsiasi elemento con la classe `exec` e un attributo `data-href` esegue la navigazione.\n\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<a class=\"link\" data-href=\"/contact/\">Contact</a>\n<span class=\"exec\" data-href=\"/help/\">Help</span>\n\n<script>\nNAV.clientside('.link');\n</script>\n```\n\n## Muoversi nella cronologia\n\n| Metodo | Descrizione |\n| --- | --- |\n| `NAV.back()` | Va all'URL precedente. |\n| `NAV.forward()` | Va all'URL successivo dopo essere tornato indietro. |\n| `NAV.prev()` | Restituisce l'URL precedente. |\n| `NAV.next()` | Restituisce l'URL successivo. |\n| `NAV.refresh()`, `NAV.reload()` | Esegue di nuovo la rotta dell'URL corrente. |\n\n```js\nREDIRECT('/a/');\nREDIRECT('/a/b/');\nconsole.log(NAV.url, NAV.prev()); // /a/b/ /a/\n\nNAV.back();\nconsole.log(NAV.url, NAV.next()); // /a/ /a/b/\n\nNAV.forward();\nconsole.log(NAV.url);             // /a/b/\n\nREDIRECT('../');\nconsole.log(NAV.url);             // /a/\n```\n\n`REDIRECT('../')` sale di un livello. Funzionano anche i pulsanti del browser.\n\n`NAV.autosave()` conserva la cronologia nello storage del browser a ogni navigazione, `NAV.save()` la salva una volta e `NAV.load()` la ripristina:\n\n```js\nNAV.autosave();\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history)); // [\"/\",\"/a/\"]\n```\n\n## Middleware\n\nUn middleware viene eseguito prima della callback della rotta e decide se la rotta prosegue. `MIDDLEWARE(name, callback)` ne registra uno e il terzo argomento di `ROUTE()` seleziona quelli da usare.\n\n```js\nMIDDLEWARE('auth', function(next, options, roles, route) {\n  console.log('auth', JSON.stringify(options), roles.join(), route.id);\n  if (window.user)\n    next();\n  else\n    next(false);\n});\n\nROUTE('/admin/', function() {\n  console.log('admin page');\n}, ['auth', '@admin', '@editor', { title: 'Admin' }]);\n```\n\nSenza un utente, la prima navigazione stampa solo la riga `auth`. Una volta impostato `window.user`, la navigazione successiva raggiunge la pagina:\n\n```text\nauth {\"title\":\"Admin\"} admin,editor /admin/\nauth {\"title\":\"Admin\"} admin,editor /admin/\nadmin page\n```\n\nL'argomento middleware di `ROUTE()` è un array o una stringa separata da virgole:\n\n| Valore | Significato |\n| --- | --- |\n| `name` | Il nome di un middleware. |\n| `@name` | Un ruolo, passato al middleware in `roles`. |\n| `#name` | Un elenco di codici da caricare con `CL()`. |\n| Un oggetto | Le opzioni, passate al middleware in `options`. Solo in un array. |\n\n`next()` prosegue con il middleware successivo. `next(false)` e `next(new Error())` fermano la rotta. La callback della rotta non viene eseguita nemmeno quando l'utente naviga altrove mentre un middleware è ancora al lavoro.\n\n```js\nMIDDLEWARE('first', function(next) { console.log('first'); next(); });\nMIDDLEWARE('second', function(next) { console.log('second'); next(); });\n\nCLINIT('countries', function(next) {\n  console.log('loading countries');\n  next([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n  console.log('orders', DEF.cl.countries.length);\n}, 'first,second,#countries');\n```\n\n```text\nfirst\nsecond\nloading countries\norders 1\n```\n\n`MIDDLEWARE(names, callback)` con un array di nomi esegue quei middleware al di fuori di qualsiasi rotta e poi chiama la callback:\n\n```js\nMIDDLEWARE(['first', 'second'], function() {\n  console.log('both done');\n});\n```\n\n## Preparare una rotta una sola volta\n\nLa funzione `init` viene eseguita una sola volta, alla prima visita di una rotta, e riceve una callback `next`. È adatta a operazioni come scaricare la parte dell'applicazione che serve alla rotta.\n\n```js\nROUTE('/reports/', function() {\n  console.log('reports');\n}, function(next) {\n  console.log('prepare once');\n  next();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n```\n\n```text\nprepare once\nreports\nreports\n```\n\nQuando una rotta ha anche dei middleware, `init` è il quarto argomento di `ROUTE()`.\n\n## Eventi\n\n| Evento | Argomenti | Descrizione |\n| --- | --- | --- |\n| `location` | `url` | L'URL cambia. Viene emesso prima della callback della rotta. |\n| `404` | | Nessuna rotta corrisponde all'URL. |\n| `route` | `url` | Viene registrata una nuova rotta. |\n\n```js\nON('location', function(url) {\n  console.log('location', url);\n});\n\nON('404', function() {\n  console.log('not found', NAV.url, NAV.is404);\n});\n\nREDIRECT('/missing/');\n```\n\n```text\nlocation /missing/\nnot found /missing/ true\n```\n\n## Aggiungere e rimuovere rotte in fase di esecuzione\n\nUna rotta registrata mentre il suo URL mostra lo stato 404 viene eseguita subito, quindi una rotta può arrivare in seguito da un file importato. `NAV.remove(url)` rimuove una rotta.\n\n```js\nREDIRECT('/missing/');\n\nROUTE('/missing/', function() {\n  console.log('added later');\n});\n\nconsole.log(NAV.is404); // false\n\nNAV.remove('/missing/');\n```\n\n## Mantenere un parametro di query\n\n`NAV.remember(name, value)` aggiunge un parametro a ogni `REDIRECT()` successivo. Passando `null` come valore, smette di aggiungerlo.\n\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/?lang=de\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/\n```\n\n## Routing con gli hash\n\nCon `NAV.hashtags = true`, le rotte sono guidate dalla parte hash dell'URL. Impostalo all'avvio dell'applicazione, scrivi le rotte con un `#` iniziale e naviga con i link o con `location.hash`.\n\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n  console.log('inbox', NAV.url);\n});\n\nROUTE('#sent', function() {\n  console.log('sent', NAV.url);\n});\n\nlocation.hash = '#inbox'; // inbox #inbox\n```\n\n## Routing senza cambiare la barra degli indirizzi\n\n`NAV.custom()` mantiene tutta la navigazione dentro l'applicazione. Le rotte e `REDIRECT()` funzionano come al solito, mentre la barra degli indirizzi resta invariata. È utile per un'applicazione incorporata in un'altra pagina. Chiamalo all'avvio dell'applicazione.\n\n```js\nNAV.custom();\n\nROUTE('/', function() {\n  console.log('home');\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNh20d61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/routing/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Smerovanie","summary":"Ako v jednostránkovej aplikácii mapovať URL na funkcie pomocou ROUTE(), REDIRECT() a NAV.","markdown":"---\ntitle: Smerovanie\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/routing/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Smerovanie\n\n> Ako v jednostránkovej aplikácii mapovať URL na funkcie pomocou ROUTE(), REDIRECT() a NAV.\n\nSmerovanie umožňuje, aby sa jedna HTML stránka správala ako mnoho stránok. Knižnica sleduje URL, spustí funkciu zaregistrovanú pre danú URL a mení URL bez opätovného načítania stránky. Server musí pre každú URL, ktorú aplikácia používa, vrátiť tú istú stránku aplikácie, aby fungovalo aj priame otvorenie odkazu.\n\n## Deklarácia trás\n\n`ROUTE(url, callback, [middleware], [init])` zaregistruje trasu. Časti v zložených zátvorkách sú dynamické a ich hodnoty sa odovzdajú callbacku v poradí. `REDIRECT(url)` prejde na URL.\n\n```js\nROUTE('/', function() {\n  console.log('home');\n});\n\nROUTE('/products/', function() {\n  console.log('list');\n});\n\nROUTE('/products/new/', function() {\n  console.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n  console.log('detail', id);\n});\n\nROUTE('/products/{id}/{tab}/', function(id, tab) {\n  console.log('tab', id, tab, this.url);\n});\n\nON('ready', function() {\n  setTimeout(function() {\n    REDIRECT('/products/');\n    REDIRECT('/products/new/');\n    REDIRECT('/products/AB-15/');\n    REDIRECT('/products/15/photos');\n  }, 300);\n});\n```\n\n```text\nhome\nlist\nform\ndetail AB-15\ntab 15 photos /products/15/photos/\n```\n\nTrasa pre aktuálnu URL sa spustí pri štarte aplikácie. V callbacku je `this` objekt `NAV`. URL bez koncovej lomky ju dostane a statická trasa ako `/products/new/` má prednosť pred dynamickou trasou ako `/products/{id}/`.\n\nURL sa porovnáva malými písmenami, preto píš trasy malými písmenami. Trasa s veľkým písmenom sa nikdy nezhoduje. Hodnoty dynamických častí si zachovávajú veľkosť písmen:\n\n```js\nROUTE('/team/{name}/', function(name) {\n  console.log(name);\n});\n\nREDIRECT('/TEAM/AnnLee/'); // AnnLee\n```\n\n## Čítanie aktuálnej polohy\n\n```js\nROUTE('/search/', function() {\n  console.log(JSON.stringify(NAV.query));\n  console.log(NAV.url, '|', NAV.href, '|', NAV.queryraw);\n});\n\nREDIRECT('/search/?q=lamp&page=2');\n```\n\n```text\n{\"q\":\"lamp\",\"page\":\"2\"}\n/search/ | /search/?q=lamp&page=2 | q=lamp&page=2\n```\n\n| Vlastnosť | Popis |\n| --- | --- |\n| `NAV.url` | Aktuálna path bez reťazca dotazu. |\n| `NAV.href` | URL odovzdaná poslednej navigácii. |\n| `NAV.query` | Spracovaný reťazec dotazu. Všetky hodnoty sú reťazce. |\n| `NAV.queryraw` | Reťazec dotazu bez úvodného `?`. |\n| `NAV.params` | Pole s hodnotami dynamických častí. |\n| `NAV.is404` | `true`, keď aktuálnej URL nezodpovedá žiadna trasa. |\n| `NAV.history` | Pole predchádzajúcich URL. |\n| `NAV.isback` | Počet URL, na ktoré sa dá vrátiť späť. |\n| `NAV.isforward` | Počet URL, na ktoré sa dá prejsť dopredu. |\n\n`NAV` je bežná path, takže sa na ňu môže značkovanie naviazať:\n\n```html\n<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>\n```\n\n## Odkazy\n\nObyčajný odkaz stránku znova načíta. `NAV.clientside(selector)` zmení zodpovedajúce odkazy na navigáciu na strane klienta. URL sa číta z `href`, `data-href` alebo `data-url`. Naviguje aj každý element s triedou `exec` a atribútom `data-href`.\n\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<a class=\"link\" data-href=\"/contact/\">Contact</a>\n<span class=\"exec\" data-href=\"/help/\">Help</span>\n\n<script>\nNAV.clientside('.link');\n</script>\n```\n\n## Pohyb v histórii\n\n| Metóda | Popis |\n| --- | --- |\n| `NAV.back()` | Prejde na predchádzajúcu URL. |\n| `NAV.forward()` | Po návrate späť prejde na nasledujúcu URL. |\n| `NAV.prev()` | Vráti predchádzajúcu URL. |\n| `NAV.next()` | Vráti nasledujúcu URL. |\n| `NAV.refresh()`, `NAV.reload()` | Znova spustí trasu aktuálnej URL. |\n\n```js\nREDIRECT('/a/');\nREDIRECT('/a/b/');\nconsole.log(NAV.url, NAV.prev()); // /a/b/ /a/\n\nNAV.back();\nconsole.log(NAV.url, NAV.next()); // /a/ /a/b/\n\nNAV.forward();\nconsole.log(NAV.url);             // /a/b/\n\nREDIRECT('../');\nconsole.log(NAV.url);             // /a/\n```\n\n`REDIRECT('../')` prejde o úroveň vyššie. Fungujú aj tlačidlá prehliadača.\n\n`NAV.autosave()` ukladá históriu do úložiska prehliadača pri každej navigácii, `NAV.save()` ju uloží raz a `NAV.load()` ju obnoví:\n\n```js\nNAV.autosave();\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history)); // [\"/\",\"/a/\"]\n```\n\n## Middleware\n\nMiddleware sa spustí pred callbackom trasy a rozhodne, či trasa pokračuje. `MIDDLEWARE(name, callback)` ho zaregistruje a tretí argument `ROUTE()` určuje, ktoré sa použijú.\n\n```js\nMIDDLEWARE('auth', function(next, options, roles, route) {\n  console.log('auth', JSON.stringify(options), roles.join(), route.id);\n  if (window.user)\n    next();\n  else\n    next(false);\n});\n\nROUTE('/admin/', function() {\n  console.log('admin page');\n}, ['auth', '@admin', '@editor', { title: 'Admin' }]);\n```\n\nBez používateľa vypíše prvá navigácia iba riadok `auth`. Keď je nastavené `window.user`, ďalšia navigácia sa dostane na stránku:\n\n```text\nauth {\"title\":\"Admin\"} admin,editor /admin/\nauth {\"title\":\"Admin\"} admin,editor /admin/\nadmin page\n```\n\nArgument middleware funkcie `ROUTE()` je pole alebo reťazec oddelený čiarkami:\n\n| Hodnota | Význam |\n| --- | --- |\n| `name` | Názov middleware. |\n| `@name` | Rola odovzdaná middleware v `roles`. |\n| `#name` | Zoznam kódov, ktorý sa načíta cez `CL()`. |\n| Objekt | Možnosti odovzdané middleware v `options`. Iba v poli. |\n\n`next()` pokračuje ďalším middleware. `next(false)` a `next(new Error())` trasu zastavia. Callback trasy sa nespustí ani vtedy, keď používateľ prejde inam, kým middleware ešte pracuje.\n\n```js\nMIDDLEWARE('first', function(next) { console.log('first'); next(); });\nMIDDLEWARE('second', function(next) { console.log('second'); next(); });\n\nCLINIT('countries', function(next) {\n  console.log('loading countries');\n  next([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n  console.log('orders', DEF.cl.countries.length);\n}, 'first,second,#countries');\n```\n\n```text\nfirst\nsecond\nloading countries\norders 1\n```\n\n`MIDDLEWARE(names, callback)` s poľom názvov spustí tieto middleware mimo akejkoľvek trasy a potom zavolá callback:\n\n```js\nMIDDLEWARE(['first', 'second'], function() {\n  console.log('both done');\n});\n```\n\n## Jednorazová príprava trasy\n\nFunkcia `init` sa spustí raz, pri prvej návšteve trasy, a dostane callback `next`. Hodí sa napríklad na stiahnutie časti aplikácie, ktorú trasa potrebuje.\n\n```js\nROUTE('/reports/', function() {\n  console.log('reports');\n}, function(next) {\n  console.log('prepare once');\n  next();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n```\n\n```text\nprepare once\nreports\nreports\n```\n\nKeď má trasa aj middleware, `init` je štvrtým argumentom `ROUTE()`.\n\n## Udalosti\n\n| Udalosť | Argumenty | Popis |\n| --- | --- | --- |\n| `location` | `url` | URL sa zmení. Vyšle sa pred callbackom trasy. |\n| `404` | | URL nezodpovedá žiadna trasa. |\n| `route` | `url` | Zaregistruje sa nová trasa. |\n\n```js\nON('location', function(url) {\n  console.log('location', url);\n});\n\nON('404', function() {\n  console.log('not found', NAV.url, NAV.is404);\n});\n\nREDIRECT('/missing/');\n```\n\n```text\nlocation /missing/\nnot found /missing/ true\n```\n\n## Pridávanie a odstraňovanie trás za behu\n\nTrasa zaregistrovaná v čase, keď jej URL zobrazuje stav 404, sa spustí okamžite, takže trasa môže prísť neskôr z importovaného súboru. `NAV.remove(url)` trasu odstráni.\n\n```js\nREDIRECT('/missing/');\n\nROUTE('/missing/', function() {\n  console.log('added later');\n});\n\nconsole.log(NAV.is404); // false\n\nNAV.remove('/missing/');\n```\n\n## Zachovanie parametra dotazu\n\n`NAV.remember(name, value)` pridá parameter ku každému nasledujúcemu `REDIRECT()`. Odovzdaním `null` ako hodnoty to zastavíš.\n\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/?lang=de\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href); // /list/\n```\n\n## Smerovanie pomocou hashov\n\nS `NAV.hashtags = true` riadi trasy hashová časť URL. Nastav to pri štarte aplikácie, trasy píš s úvodným `#` a naviguj odkazmi alebo cez `location.hash`.\n\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n  console.log('inbox', NAV.url);\n});\n\nROUTE('#sent', function() {\n  console.log('sent', NAV.url);\n});\n\nlocation.hash = '#inbox'; // inbox #inbox\n```\n\n## Smerovanie bez zmeny adresného riadka\n\n`NAV.custom()` drží všetku navigáciu vo vnútri aplikácie. Trasy a `REDIRECT()` fungujú ako zvyčajne a adresný riadok zostáva nezmenený. Hodí sa to pre aplikáciu vloženú do inej stránky. Zavolaj to pri štarte aplikácie.\n\n```js\nNAV.custom();\n\nROUTE('/', function() {\n  console.log('home');\n});\n```\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNK1md61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/forms/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Forms and validation","summary":"How to build a form from components, validate it, show errors, submit it and reset it.","markdown":"---\ntitle: Forms and validation\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/forms/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Forms and validation\n\n> How to build a form from components, validate it, show errors, submit it and reset it.\n\nA form is a group of components bound to paths under one object, for example `form.name` and `form.email`. Each component keeps its own state: whether the user touched it, changed it, and whether its value is valid. This guide builds a form step by step. How to write components in general is explained in [Creating components](../creating-components/).\n\n## A field with validation\n\nA component takes part in validation when it defines `self.validate`. The function receives the value and runs each time the value changes.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n\n<script>\nCOMPONENT('input', 'label:Field', function(self, config) {\n\n  self.make = function() {\n    self.html('<label>' + config.label + '</label><input type=\"text\" /><em></em>');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    if (!config.required)\n      return true;\n    if (!value)\n      return 'This field is required';\n    if (config.email && !value.isEmail())\n      return 'Enter a valid email address';\n    return true;\n  };\n\n  self.state = function() {\n    self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n  };\n\n});\n</script>\n```\n\n`self.autobind20()` connects the `<input>` to the path. When the user writes `ann` into the email field and leaves it, the model is `{\"email\":\"ann\"}` and the message `Enter a valid email address` appears.\n\nThe result of `self.validate` sets `config.invalid`:\n\n| Result | Meaning | `config.invalid` |\n| --- | --- | --- |\n| `true` or an empty string | Valid | `false` |\n| A non-empty string | Invalid, with a message | The message |\n| Anything else | Invalid | `true` |\n\n## Field state\n\n| Value | CSS class | Set when |\n| --- | --- | --- |\n| `config.touched` | `ui-touched` | The user typed into the field or left it. |\n| `config.modified` | `ui-modified` | The user changed the value. |\n| `config.invalid` | `ui-invalid` | The value did not pass the validation. |\n| `config.disabled` | `ui-disabled` | The component is disabled. |\n\nThe library keeps the classes on the `<ui-component>` element up to date and calls `self.state()` after each change of the state.\n\nA required empty field is invalid from the moment the page loads. Testing `config.touched` as in the example above keeps the message hidden until the user has worked with the field.\n\n## Checking the form\n\n`ERRORS(path, callback)` returns the invalid components under a path. It also accepts a jQuery element and searches inside it. `COMPONENTS(path)` returns the components that match the flags in the path.\n\n```html\n<div id=\"contact\">\n  <ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.note\" config=\"label:Note\"></ui-component>\n</div>\n\n<script>\nON('ready', function() {\n  ERRORS('form', function(components) {\n    for (var component of components)\n      console.log(component.path.toString(), '-', component.config.invalid);\n  });\n\n  ERRORS($('#contact'), function(components) {\n    console.log(components.length);\n  });\n\n  console.log(COMPONENTS('form @invalid').length);\n  console.log(COMPONENTS('form @valid').length);\n  console.log(COMPONENTS('form @required').length);\n  console.log(COMPONENTS('form @modified').length);\n});\n</script>\n```\n\n```text\nform.name - This field is required\nform.email - This field is required\n2\n2\n1\n2\n0\n```\n\n`COMPONENTS()` understands the flags `@invalid`, `@valid`, `@touched`, `@modified`, `@required`, `@disabled`, `@enabled`, `@visible` and `@hidden`. `ERRORS('form @visible', callback)` skips the fields that are hidden.\n\n## Disabling the submit button\n\nWatch the form, keep the result in a path, and let `<ui-bind>` disable the button:\n\n```html\n<ui-bind path=\"formstate.invalid\" config=\"disabled\"><button>Save</button></ui-bind>\n\n<script>\nON('ready', function() {\n\n  var check = function() {\n    ERRORS('form', function(components) {\n      SET('formstate.invalid', components.length > 0);\n    });\n  };\n\n  WATCH('form', check);\n  check();\n\n});\n</script>\n```\n\nThe button is disabled while the name is empty and becomes enabled after `SET('form.name', 'Ann')`.\n\n## Submitting\n\nCheck the errors, send `GET('form')`, and reset the form after success. The `@change` flag marks the fields as touched and modified, which reveals their messages when the user submits too early.\n\n```js\nfunction submit() {\n  ERRORS('form', function(components) {\n\n    if (components.length) {\n      SET('form @change', GET('form'));\n      return;\n    }\n\n    AJAX('POST /api/contact/', GET('form'), function(response) {\n      if (response.success)\n        SET('form @reset', {});\n    });\n  });\n}\n```\n\n## Resetting and filling the form\n\n| Call | Effect |\n| --- | --- |\n| `SET('form.name @change', value)` | Sets the value and marks the field as touched and modified. |\n| `RESET('form')` | Clears the touched and modified state and keeps the values. |\n| `SET('form @reset', data)` | Replaces the data and clears the state. Use it to load a record into a form. |\n| `SET('form @default', {})` | Replaces the data, clears the state and applies the default values. |\n\nA default value is a JavaScript expression in the `default` attribute of the component. It is applied at start and by the `@default` flag whenever the value is empty.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name\"></ui-component>\n<ui-component name=\"input\" path=\"form.country\" config=\"label:Country\" default=\"'Slovakia'\"></ui-component>\n\n<script>\nvar show = function(label) {\n  var c = FIND('.form.name');\n  console.log(label, JSON.stringify(GET('form')), c.config.touched, c.config.modified);\n};\n\nON('ready', function() {\n  SET('form.name @change', 'Ann');\n  show('@change');\n  RESET('form');\n  show('RESET');\n  SET('form @reset', { name: 'Bob', country: 'Austria' });\n  show('@reset');\n  SET('form @default', {});\n  show('@default');\n});\n</script>\n```\n\n```text\n@change {\"country\":\"Slovakia\",\"name\":\"Ann\"} 1 1\nRESET {\"country\":\"Slovakia\",\"name\":\"Ann\"} 0 0\n@reset {\"name\":\"Bob\",\"country\":\"Austria\"} 0 0\n@default {\"country\":\"Slovakia\"} 0 0\n```\n\nMore flags are described in [Flags and path modifiers](../flags/).\n\n## Converting the value\n\nThe `type` key of the configuration converts the text from the `<input>` when `autobind20()` writes it to the model. With `type:number`, typing `42` stores the number `42`:\n\n```html\n<ui-component name=\"input\" path=\"form.age\" config=\"label:Age;type:number\"></ui-component>\n```\n\n## A field that is required on a condition\n\nThe `required` command of `<ui-bind>` sets `config.required` on the components inside it. Call `self.validate2()` from `self.configure` to validate again when the option changes:\n\n```html\n<ui-bind path=\"form.company\" config=\"required\">\n  <div><ui-component name=\"input\" path=\"form.vat\" config=\"label:VAT number\"></ui-component></div>\n</ui-bind>\n\n<script>\nCOMPONENT('input', function(self, config) {\n\n  self.make = function() {\n    self.html('<input type=\"text\" />');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    return !config.required || !!value;\n  };\n\n  self.configure = function(key) {\n    if (key === 'required')\n      self.validate2();\n  };\n\n});\n</script>\n```\n\nThe empty field is valid at first. After `SET('form.company', true)` it is required and invalid, and after `SET('form.company', false)` it is valid again.\n\n## Forms inside a plugin\n\nA [plugin](../plugins/) is a natural home for a form. The fields use `?` paths, `exports.set('@reset', data)` fills the form, and `exports.form` returns the data and clears the state of the fields.\n\n```html\n<ui-plugin path=\"contact\">\n  <ui-component name=\"input\" path=\"?.name\" config=\"label:Name;required:true\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('contact', function(exports) {\n\n  exports.load = function(data) {\n    exports.set('@reset', data);\n  };\n\n  exports.save = function() {\n    ERRORS(exports.name, function(components) {\n      console.log('errors', components.length);\n      if (!components.length)\n        console.log(JSON.stringify(exports.form));\n    });\n  };\n});\n</script>\n```\n\nCalling `EXEC('contact/save')` on the empty form prints `errors 1`. After `EXEC('contact/load', { name: 'Ann' })` and `SET('contact.name @change', 'Anna')`, it prints `errors 0` and `{\"name\":\"Anna\"}`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNK1md61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/forms/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Formulare und Validierung","summary":"Wie du ein Formular aus Komponenten baust, validierst, Fehler anzeigst, es absendest und zurücksetzt.","markdown":"---\ntitle: Formulare und Validierung\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/forms/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Formulare und Validierung\n\n> Wie du ein Formular aus Komponenten baust, validierst, Fehler anzeigst, es absendest und zurücksetzt.\n\nEin Formular ist eine Gruppe von Komponenten, die an Paths unter einem Objekt gebunden sind, zum Beispiel `form.name` und `form.email`. Jede Komponente verwaltet ihren eigenen Zustand: ob der Benutzer sie berührt oder geändert hat und ob ihr Wert gültig ist. Diese Anleitung baut ein Formular Schritt für Schritt auf. Wie du Komponenten allgemein schreibst, erklärt [Komponenten erstellen](../creating-components/).\n\n## Ein Feld mit Validierung\n\nEine Komponente nimmt an der Validierung teil, wenn sie `self.validate` definiert. Die Funktion erhält den Wert und läuft bei jeder Änderung des Werts.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n\n<script>\nCOMPONENT('input', 'label:Field', function(self, config) {\n\n  self.make = function() {\n    self.html('<label>' + config.label + '</label><input type=\"text\" /><em></em>');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    if (!config.required)\n      return true;\n    if (!value)\n      return 'This field is required';\n    if (config.email && !value.isEmail())\n      return 'Enter a valid email address';\n    return true;\n  };\n\n  self.state = function() {\n    self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n  };\n\n});\n</script>\n```\n\n`self.autobind20()` verbindet das `<input>` mit dem Path. Schreibt der Benutzer `ann` in das E-Mail-Feld und verlässt es, ist das Modell `{\"email\":\"ann\"}`, und die Meldung `Enter a valid email address` erscheint.\n\nDas Ergebnis von `self.validate` setzt `config.invalid`:\n\n| Ergebnis | Bedeutung | `config.invalid` |\n| --- | --- | --- |\n| `true` oder ein leerer String | Gültig | `false` |\n| Ein nicht leerer String | Ungültig, mit Meldung | Die Meldung |\n| Alles andere | Ungültig | `true` |\n\n## Zustand eines Felds\n\n| Wert | CSS-Klasse | Gesetzt, wenn |\n| --- | --- | --- |\n| `config.touched` | `ui-touched` | Der Benutzer in das Feld getippt oder es verlassen hat. |\n| `config.modified` | `ui-modified` | Der Benutzer den Wert geändert hat. |\n| `config.invalid` | `ui-invalid` | Der Wert die Validierung nicht bestanden hat. |\n| `config.disabled` | `ui-disabled` | Die Komponente deaktiviert ist. |\n\nDie Bibliothek hält die Klassen am Element `<ui-component>` aktuell und ruft nach jeder Zustandsänderung `self.state()` auf.\n\nEin leeres Pflichtfeld ist ab dem Laden der Seite ungültig. Prüfst du wie im Beispiel oben `config.touched`, bleibt die Meldung verborgen, bis der Benutzer mit dem Feld gearbeitet hat.\n\n## Das Formular prüfen\n\n`ERRORS(path, callback)` gibt die ungültigen Komponenten unter einem Path zurück. Es akzeptiert auch ein jQuery-Element und sucht darin. `COMPONENTS(path)` gibt die Komponenten zurück, die zu den Flags im Path passen.\n\n```html\n<div id=\"contact\">\n  <ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.note\" config=\"label:Note\"></ui-component>\n</div>\n\n<script>\nON('ready', function() {\n  ERRORS('form', function(components) {\n    for (var component of components)\n      console.log(component.path.toString(), '-', component.config.invalid);\n  });\n\n  ERRORS($('#contact'), function(components) {\n    console.log(components.length);\n  });\n\n  console.log(COMPONENTS('form @invalid').length);\n  console.log(COMPONENTS('form @valid').length);\n  console.log(COMPONENTS('form @required').length);\n  console.log(COMPONENTS('form @modified').length);\n});\n</script>\n```\n\n```text\nform.name - This field is required\nform.email - This field is required\n2\n2\n1\n2\n0\n```\n\n`COMPONENTS()` versteht die Flags `@invalid`, `@valid`, `@touched`, `@modified`, `@required`, `@disabled`, `@enabled`, `@visible` und `@hidden`. `ERRORS('form @visible', callback)` überspringt ausgeblendete Felder.\n\n## Den Absenden-Button deaktivieren\n\nBeobachte das Formular, halte das Ergebnis in einem Path fest und lass `<ui-bind>` den Button deaktivieren:\n\n```html\n<ui-bind path=\"formstate.invalid\" config=\"disabled\"><button>Save</button></ui-bind>\n\n<script>\nON('ready', function() {\n\n  var check = function() {\n    ERRORS('form', function(components) {\n      SET('formstate.invalid', components.length > 0);\n    });\n  };\n\n  WATCH('form', check);\n  check();\n\n});\n</script>\n```\n\nDer Button ist deaktiviert, solange der Name leer ist, und wird nach `SET('form.name', 'Ann')` aktiviert.\n\n## Absenden\n\nPrüfe die Fehler, sende `GET('form')` und setze das Formular nach dem Erfolg zurück. Das Flag `@change` markiert die Felder als berührt und geändert, wodurch ihre Meldungen sichtbar werden, wenn der Benutzer zu früh absendet.\n\n```js\nfunction submit() {\n  ERRORS('form', function(components) {\n\n    if (components.length) {\n      SET('form @change', GET('form'));\n      return;\n    }\n\n    AJAX('POST /api/contact/', GET('form'), function(response) {\n      if (response.success)\n        SET('form @reset', {});\n    });\n  });\n}\n```\n\n## Das Formular zurücksetzen und füllen\n\n| Aufruf | Wirkung |\n| --- | --- |\n| `SET('form.name @change', value)` | Setzt den Wert und markiert das Feld als berührt und geändert. |\n| `RESET('form')` | Löscht den Zustand „berührt“ und „geändert“ und behält die Werte. |\n| `SET('form @reset', data)` | Ersetzt die Daten und löscht den Zustand. Damit lädst du einen Datensatz in ein Formular. |\n| `SET('form @default', {})` | Ersetzt die Daten, löscht den Zustand und wendet die Standardwerte an. |\n\nEin Standardwert ist ein JavaScript-Ausdruck im Attribut `default` der Komponente. Er wird beim Start und durch das Flag `@default` angewendet, sobald der Wert leer ist.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name\"></ui-component>\n<ui-component name=\"input\" path=\"form.country\" config=\"label:Country\" default=\"'Slovakia'\"></ui-component>\n\n<script>\nvar show = function(label) {\n  var c = FIND('.form.name');\n  console.log(label, JSON.stringify(GET('form')), c.config.touched, c.config.modified);\n};\n\nON('ready', function() {\n  SET('form.name @change', 'Ann');\n  show('@change');\n  RESET('form');\n  show('RESET');\n  SET('form @reset', { name: 'Bob', country: 'Austria' });\n  show('@reset');\n  SET('form @default', {});\n  show('@default');\n});\n</script>\n```\n\n```text\n@change {\"country\":\"Slovakia\",\"name\":\"Ann\"} 1 1\nRESET {\"country\":\"Slovakia\",\"name\":\"Ann\"} 0 0\n@reset {\"name\":\"Bob\",\"country\":\"Austria\"} 0 0\n@default {\"country\":\"Slovakia\"} 0 0\n```\n\nWeitere Flags sind unter [Flags und Path-Modifikatoren](../flags/) beschrieben.\n\n## Den Wert umwandeln\n\nDer Konfigurationsschlüssel `type` wandelt den Text aus dem `<input>` um, wenn `autobind20()` ihn in das Modell schreibt. Mit `type:number` speichert die Eingabe `42` die Zahl `42`:\n\n```html\n<ui-component name=\"input\" path=\"form.age\" config=\"label:Age;type:number\"></ui-component>\n```\n\n## Ein Feld, das unter einer Bedingung Pflicht ist\n\nDer Befehl `required` von `<ui-bind>` setzt `config.required` an den Komponenten darin. Rufe `self.validate2()` aus `self.configure` auf, um erneut zu validieren, wenn sich die Option ändert:\n\n```html\n<ui-bind path=\"form.company\" config=\"required\">\n  <div><ui-component name=\"input\" path=\"form.vat\" config=\"label:VAT number\"></ui-component></div>\n</ui-bind>\n\n<script>\nCOMPONENT('input', function(self, config) {\n\n  self.make = function() {\n    self.html('<input type=\"text\" />');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    return !config.required || !!value;\n  };\n\n  self.configure = function(key) {\n    if (key === 'required')\n      self.validate2();\n  };\n\n});\n</script>\n```\n\nDas leere Feld ist zunächst gültig. Nach `SET('form.company', true)` ist es Pflicht und ungültig, und nach `SET('form.company', false)` ist es wieder gültig.\n\n## Formulare in einem Plugin\n\nEin [Plugin](../plugins/) ist ein naheliegender Ort für ein Formular. Die Felder verwenden `?`-Paths, `exports.set('@reset', data)` füllt das Formular, und `exports.form` gibt die Daten zurück und löscht den Zustand der Felder.\n\n```html\n<ui-plugin path=\"contact\">\n  <ui-component name=\"input\" path=\"?.name\" config=\"label:Name;required:true\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('contact', function(exports) {\n\n  exports.load = function(data) {\n    exports.set('@reset', data);\n  };\n\n  exports.save = function() {\n    ERRORS(exports.name, function(components) {\n      console.log('errors', components.length);\n      if (!components.length)\n        console.log(JSON.stringify(exports.form));\n    });\n  };\n});\n</script>\n```\n\nDer Aufruf von `EXEC('contact/save')` beim leeren Formular gibt `errors 1` aus. Nach `EXEC('contact/load', { name: 'Ann' })` und `SET('contact.name @change', 'Anna')` gibt er `errors 0` und `{\"name\":\"Anna\"}` aus.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNK1md61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/forms/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Formularios y validación","summary":"Cómo crear un formulario a partir de componentes, validarlo, mostrar errores, enviarlo y restablecerlo.","markdown":"---\ntitle: \"Formularios y validación\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/forms/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Formularios y validación\n\n> Cómo crear un formulario a partir de componentes, validarlo, mostrar errores, enviarlo y restablecerlo.\n\nUn formulario es un grupo de componentes enlazados a paths de un mismo objeto, por ejemplo `form.name` y `form.email`. Cada componente mantiene su propio estado: si el usuario lo ha tocado, si lo ha cambiado y si su valor es válido. Esta guía crea un formulario paso a paso. Cómo escribir componentes en general se explica en [Crear componentes](../creating-components/).\n\n## Un campo con validación\n\nUn componente participa en la validación cuando define `self.validate`. La función recibe el valor y se ejecuta cada vez que este cambia.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n\n<script>\nCOMPONENT('input', 'label:Field', function(self, config) {\n\n  self.make = function() {\n    self.html('<label>' + config.label + '</label><input type=\"text\" /><em></em>');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    if (!config.required)\n      return true;\n    if (!value)\n      return 'This field is required';\n    if (config.email && !value.isEmail())\n      return 'Enter a valid email address';\n    return true;\n  };\n\n  self.state = function() {\n    self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n  };\n\n});\n</script>\n```\n\n`self.autobind20()` conecta el `<input>` con el path. Cuando el usuario escribe `ann` en el campo de correo y sale de él, el modelo es `{\"email\":\"ann\"}` y aparece el mensaje `Enter a valid email address`.\n\nEl resultado de `self.validate` establece `config.invalid`:\n\n| Resultado | Significado | `config.invalid` |\n| --- | --- | --- |\n| `true` o una cadena vacía | Válido | `false` |\n| Una cadena no vacía | No válido, con un mensaje | El mensaje |\n| Cualquier otra cosa | No válido | `true` |\n\n## Estado del campo\n\n| Valor | Clase CSS | Se establece cuando |\n| --- | --- | --- |\n| `config.touched` | `ui-touched` | El usuario ha escrito en el campo o ha salido de él. |\n| `config.modified` | `ui-modified` | El usuario ha cambiado el valor. |\n| `config.invalid` | `ui-invalid` | El valor no ha superado la validación. |\n| `config.disabled` | `ui-disabled` | El componente está desactivado. |\n\nLa biblioteca mantiene actualizadas las clases del elemento `<ui-component>` y llama a `self.state()` después de cada cambio de estado.\n\nUn campo obligatorio vacío no es válido desde que se carga la página. Comprobar `config.touched`, como en el ejemplo anterior, mantiene oculto el mensaje hasta que el usuario ha trabajado con el campo.\n\n## Comprobar el formulario\n\n`ERRORS(path, callback)` devuelve los componentes no válidos de un path. También acepta un elemento jQuery y busca dentro de él. `COMPONENTS(path)` devuelve los componentes que coinciden con los flags del path.\n\n```html\n<div id=\"contact\">\n  <ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.note\" config=\"label:Note\"></ui-component>\n</div>\n\n<script>\nON('ready', function() {\n  ERRORS('form', function(components) {\n    for (var component of components)\n      console.log(component.path.toString(), '-', component.config.invalid);\n  });\n\n  ERRORS($('#contact'), function(components) {\n    console.log(components.length);\n  });\n\n  console.log(COMPONENTS('form @invalid').length);\n  console.log(COMPONENTS('form @valid').length);\n  console.log(COMPONENTS('form @required').length);\n  console.log(COMPONENTS('form @modified').length);\n});\n</script>\n```\n\n```text\nform.name - This field is required\nform.email - This field is required\n2\n2\n1\n2\n0\n```\n\n`COMPONENTS()` entiende los flags `@invalid`, `@valid`, `@touched`, `@modified`, `@required`, `@disabled`, `@enabled`, `@visible` y `@hidden`. `ERRORS('form @visible', callback)` omite los campos ocultos.\n\n## Desactivar el botón de envío\n\nObserva el formulario, guarda el resultado en un path y deja que `<ui-bind>` desactive el botón:\n\n```html\n<ui-bind path=\"formstate.invalid\" config=\"disabled\"><button>Save</button></ui-bind>\n\n<script>\nON('ready', function() {\n\n  var check = function() {\n    ERRORS('form', function(components) {\n      SET('formstate.invalid', components.length > 0);\n    });\n  };\n\n  WATCH('form', check);\n  check();\n\n});\n</script>\n```\n\nEl botón está desactivado mientras el nombre esté vacío y se activa tras `SET('form.name', 'Ann')`.\n\n## Enviar\n\nComprueba los errores, envía `GET('form')` y restablece el formulario si todo va bien. El flag `@change` marca los campos como tocados y modificados, lo que muestra sus mensajes cuando el usuario envía demasiado pronto.\n\n```js\nfunction submit() {\n  ERRORS('form', function(components) {\n\n    if (components.length) {\n      SET('form @change', GET('form'));\n      return;\n    }\n\n    AJAX('POST /api/contact/', GET('form'), function(response) {\n      if (response.success)\n        SET('form @reset', {});\n    });\n  });\n}\n```\n\n## Restablecer y rellenar el formulario\n\n| Llamada | Efecto |\n| --- | --- |\n| `SET('form.name @change', value)` | Establece el valor y marca el campo como tocado y modificado. |\n| `RESET('form')` | Borra el estado de tocado y modificado y conserva los valores. |\n| `SET('form @reset', data)` | Sustituye los datos y borra el estado. Úsalo para cargar un registro en un formulario. |\n| `SET('form @default', {})` | Sustituye los datos, borra el estado y aplica los valores predeterminados. |\n\nUn valor predeterminado es una expresión JavaScript en el atributo `default` del componente. Se aplica al arrancar y, con el flag `@default`, siempre que el valor esté vacío.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name\"></ui-component>\n<ui-component name=\"input\" path=\"form.country\" config=\"label:Country\" default=\"'Slovakia'\"></ui-component>\n\n<script>\nvar show = function(label) {\n  var c = FIND('.form.name');\n  console.log(label, JSON.stringify(GET('form')), c.config.touched, c.config.modified);\n};\n\nON('ready', function() {\n  SET('form.name @change', 'Ann');\n  show('@change');\n  RESET('form');\n  show('RESET');\n  SET('form @reset', { name: 'Bob', country: 'Austria' });\n  show('@reset');\n  SET('form @default', {});\n  show('@default');\n});\n</script>\n```\n\n```text\n@change {\"country\":\"Slovakia\",\"name\":\"Ann\"} 1 1\nRESET {\"country\":\"Slovakia\",\"name\":\"Ann\"} 0 0\n@reset {\"name\":\"Bob\",\"country\":\"Austria\"} 0 0\n@default {\"country\":\"Slovakia\"} 0 0\n```\n\nEncontrarás más flags en [Flags y modificadores de path](../flags/).\n\n## Convertir el valor\n\nLa clave `type` de la configuración convierte el texto del `<input>` cuando `autobind20()` lo escribe en el modelo. Con `type:number`, al escribir `42` se guarda el número `42`:\n\n```html\n<ui-component name=\"input\" path=\"form.age\" config=\"label:Age;type:number\"></ui-component>\n```\n\n## Un campo obligatorio según una condición\n\nEl comando `required` de `<ui-bind>` establece `config.required` en los componentes que contiene. Llama a `self.validate2()` desde `self.configure` para volver a validar cuando cambie la opción:\n\n```html\n<ui-bind path=\"form.company\" config=\"required\">\n  <div><ui-component name=\"input\" path=\"form.vat\" config=\"label:VAT number\"></ui-component></div>\n</ui-bind>\n\n<script>\nCOMPONENT('input', function(self, config) {\n\n  self.make = function() {\n    self.html('<input type=\"text\" />');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    return !config.required || !!value;\n  };\n\n  self.configure = function(key) {\n    if (key === 'required')\n      self.validate2();\n  };\n\n});\n</script>\n```\n\nAl principio, el campo vacío es válido. Tras `SET('form.company', true)` es obligatorio y no válido, y tras `SET('form.company', false)` vuelve a ser válido.\n\n## Formularios dentro de un plugin\n\nUn [plugin](../plugins/) es el lugar natural para un formulario. Los campos usan paths con `?`, `exports.set('@reset', data)` rellena el formulario y `exports.form` devuelve los datos y borra el estado de los campos.\n\n```html\n<ui-plugin path=\"contact\">\n  <ui-component name=\"input\" path=\"?.name\" config=\"label:Name;required:true\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('contact', function(exports) {\n\n  exports.load = function(data) {\n    exports.set('@reset', data);\n  };\n\n  exports.save = function() {\n    ERRORS(exports.name, function(components) {\n      console.log('errors', components.length);\n      if (!components.length)\n        console.log(JSON.stringify(exports.form));\n    });\n  };\n});\n</script>\n```\n\nAl llamar a `EXEC('contact/save')` con el formulario vacío se imprime `errors 1`. Tras `EXEC('contact/load', { name: 'Ann' })` y `SET('contact.name @change', 'Anna')`, se imprime `errors 0` y `{\"name\":\"Anna\"}`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNK1md61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/forms/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Formulaires et validation","summary":"Comment construire un formulaire à partir de composants, le valider, afficher les erreurs, l'envoyer et le réinitialiser.","markdown":"---\ntitle: Formulaires et validation\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/forms/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Formulaires et validation\n\n> Comment construire un formulaire à partir de composants, le valider, afficher les erreurs, l'envoyer et le réinitialiser.\n\nUn formulaire est un groupe de composants liés à des paths sous un même objet, par exemple `form.name` et `form.email`. Chaque composant conserve son propre état : si l'utilisateur l'a touché, s'il l'a modifié et si sa valeur est valide. Ce guide construit un formulaire pas à pas. La façon d'écrire des composants en général est expliquée dans [Créer des composants](../creating-components/).\n\n## Un champ avec validation\n\nUn composant participe à la validation quand il définit `self.validate`. La fonction reçoit la valeur et s'exécute chaque fois que celle-ci change.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n\n<script>\nCOMPONENT('input', 'label:Field', function(self, config) {\n\n  self.make = function() {\n    self.html('<label>' + config.label + '</label><input type=\"text\" /><em></em>');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    if (!config.required)\n      return true;\n    if (!value)\n      return 'This field is required';\n    if (config.email && !value.isEmail())\n      return 'Enter a valid email address';\n    return true;\n  };\n\n  self.state = function() {\n    self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n  };\n\n});\n</script>\n```\n\n`self.autobind20()` relie le `<input>` au path. Quand l'utilisateur écrit `ann` dans le champ e-mail et le quitte, le modèle de données vaut `{\"email\":\"ann\"}` et le message `Enter a valid email address` apparaît.\n\nLe résultat de `self.validate` définit `config.invalid` :\n\n| Résultat | Signification | `config.invalid` |\n| --- | --- | --- |\n| `true` ou une chaîne vide | Valide | `false` |\n| Une chaîne non vide | Invalide, avec un message | Le message |\n| Toute autre valeur | Invalide | `true` |\n\n## État du champ\n\n| Valeur | Classe CSS | Définie quand |\n| --- | --- | --- |\n| `config.touched` | `ui-touched` | L'utilisateur a écrit dans le champ ou l'a quitté. |\n| `config.modified` | `ui-modified` | L'utilisateur a modifié la valeur. |\n| `config.invalid` | `ui-invalid` | La valeur n'a pas passé la validation. |\n| `config.disabled` | `ui-disabled` | Le composant est désactivé. |\n\nLa bibliothèque tient à jour les classes de l'élément `<ui-component>` et appelle `self.state()` après chaque changement d'état.\n\nUn champ obligatoire vide est invalide dès le chargement de la page. Tester `config.touched` comme dans l'exemple ci-dessus garde le message masqué tant que l'utilisateur n'a pas travaillé avec le champ.\n\n## Vérifier le formulaire\n\n`ERRORS(path, callback)` renvoie les composants invalides sous un path. Il accepte aussi un élément jQuery et cherche à l'intérieur de celui-ci. `COMPONENTS(path)` renvoie les composants qui correspondent aux flags du path.\n\n```html\n<div id=\"contact\">\n  <ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.note\" config=\"label:Note\"></ui-component>\n</div>\n\n<script>\nON('ready', function() {\n  ERRORS('form', function(components) {\n    for (var component of components)\n      console.log(component.path.toString(), '-', component.config.invalid);\n  });\n\n  ERRORS($('#contact'), function(components) {\n    console.log(components.length);\n  });\n\n  console.log(COMPONENTS('form @invalid').length);\n  console.log(COMPONENTS('form @valid').length);\n  console.log(COMPONENTS('form @required').length);\n  console.log(COMPONENTS('form @modified').length);\n});\n</script>\n```\n\n```text\nform.name - This field is required\nform.email - This field is required\n2\n2\n1\n2\n0\n```\n\n`COMPONENTS()` comprend les flags `@invalid`, `@valid`, `@touched`, `@modified`, `@required`, `@disabled`, `@enabled`, `@visible` et `@hidden`. `ERRORS('form @visible', callback)` ignore les champs masqués.\n\n## Désactiver le bouton d'envoi\n\nObserve le formulaire, conserve le résultat dans un path et laisse `<ui-bind>` désactiver le bouton :\n\n```html\n<ui-bind path=\"formstate.invalid\" config=\"disabled\"><button>Save</button></ui-bind>\n\n<script>\nON('ready', function() {\n\n  var check = function() {\n    ERRORS('form', function(components) {\n      SET('formstate.invalid', components.length > 0);\n    });\n  };\n\n  WATCH('form', check);\n  check();\n\n});\n</script>\n```\n\nLe bouton est désactivé tant que le nom est vide et s'active après `SET('form.name', 'Ann')`.\n\n## Envoyer\n\nVérifie les erreurs, envoie `GET('form')` et réinitialise le formulaire après la réussite. Le flag `@change` marque les champs comme touchés et modifiés, ce qui révèle leurs messages quand l'utilisateur envoie trop tôt.\n\n```js\nfunction submit() {\n  ERRORS('form', function(components) {\n\n    if (components.length) {\n      SET('form @change', GET('form'));\n      return;\n    }\n\n    AJAX('POST /api/contact/', GET('form'), function(response) {\n      if (response.success)\n        SET('form @reset', {});\n    });\n  });\n}\n```\n\n## Réinitialiser et remplir le formulaire\n\n| Appel | Effet |\n| --- | --- |\n| `SET('form.name @change', value)` | Définit la valeur et marque le champ comme touché et modifié. |\n| `RESET('form')` | Efface l'état touché et modifié et conserve les valeurs. |\n| `SET('form @reset', data)` | Remplace les données et efface l'état. Utilise-le pour charger un enregistrement dans un formulaire. |\n| `SET('form @default', {})` | Remplace les données, efface l'état et applique les valeurs par défaut. |\n\nUne valeur par défaut est une expression JavaScript placée dans l'attribut `default` du composant. Elle est appliquée au démarrage et par le flag `@default` chaque fois que la valeur est vide.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name\"></ui-component>\n<ui-component name=\"input\" path=\"form.country\" config=\"label:Country\" default=\"'Slovakia'\"></ui-component>\n\n<script>\nvar show = function(label) {\n  var c = FIND('.form.name');\n  console.log(label, JSON.stringify(GET('form')), c.config.touched, c.config.modified);\n};\n\nON('ready', function() {\n  SET('form.name @change', 'Ann');\n  show('@change');\n  RESET('form');\n  show('RESET');\n  SET('form @reset', { name: 'Bob', country: 'Austria' });\n  show('@reset');\n  SET('form @default', {});\n  show('@default');\n});\n</script>\n```\n\n```text\n@change {\"country\":\"Slovakia\",\"name\":\"Ann\"} 1 1\nRESET {\"country\":\"Slovakia\",\"name\":\"Ann\"} 0 0\n@reset {\"name\":\"Bob\",\"country\":\"Austria\"} 0 0\n@default {\"country\":\"Slovakia\"} 0 0\n```\n\nD'autres flags sont décrits dans [Flags et modificateurs de path](../flags/).\n\n## Convertir la valeur\n\nLa clé `type` de la configuration convertit le texte du `<input>` quand `autobind20()` l'écrit dans le modèle de données. Avec `type:number`, la saisie de `42` stocke le nombre `42` :\n\n```html\n<ui-component name=\"input\" path=\"form.age\" config=\"label:Age;type:number\"></ui-component>\n```\n\n## Un champ obligatoire sous condition\n\nLa commande `required` de `<ui-bind>` définit `config.required` sur les composants qu'il contient. Appelle `self.validate2()` depuis `self.configure` pour valider de nouveau quand l'option change :\n\n```html\n<ui-bind path=\"form.company\" config=\"required\">\n  <div><ui-component name=\"input\" path=\"form.vat\" config=\"label:VAT number\"></ui-component></div>\n</ui-bind>\n\n<script>\nCOMPONENT('input', function(self, config) {\n\n  self.make = function() {\n    self.html('<input type=\"text\" />');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    return !config.required || !!value;\n  };\n\n  self.configure = function(key) {\n    if (key === 'required')\n      self.validate2();\n  };\n\n});\n</script>\n```\n\nLe champ vide est d'abord valide. Après `SET('form.company', true)`, il est obligatoire et invalide, et après `SET('form.company', false)`, il redevient valide.\n\n## Formulaires dans un plugin\n\nUn [plugin](../plugins/) est un emplacement naturel pour un formulaire. Les champs utilisent des paths `?`, `exports.set('@reset', data)` remplit le formulaire et `exports.form` renvoie les données et efface l'état des champs.\n\n```html\n<ui-plugin path=\"contact\">\n  <ui-component name=\"input\" path=\"?.name\" config=\"label:Name;required:true\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('contact', function(exports) {\n\n  exports.load = function(data) {\n    exports.set('@reset', data);\n  };\n\n  exports.save = function() {\n    ERRORS(exports.name, function(components) {\n      console.log('errors', components.length);\n      if (!components.length)\n        console.log(JSON.stringify(exports.form));\n    });\n  };\n});\n</script>\n```\n\nAppeler `EXEC('contact/save')` sur le formulaire vide affiche `errors 1`. Après `EXEC('contact/load', { name: 'Ann' })` et `SET('contact.name @change', 'Anna')`, il affiche `errors 0` et `{\"name\":\"Anna\"}`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNK1md61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/forms/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Moduli e validazione","summary":"Come creare un modulo con i componenti, validarlo, mostrare gli errori, inviarlo e reimpostarlo.","markdown":"---\ntitle: Moduli e validazione\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/forms/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Moduli e validazione\n\n> Come creare un modulo con i componenti, validarlo, mostrare gli errori, inviarlo e reimpostarlo.\n\nUn modulo è un gruppo di componenti associati a path sotto un unico oggetto, ad esempio `form.name` e `form.email`. Ogni componente conserva il proprio stato: se l'utente lo ha toccato, se lo ha modificato e se il suo valore è valido. Questa guida costruisce un modulo passo dopo passo. Come scrivere i componenti in generale è spiegato in [Creare componenti](../creating-components/).\n\n## Un campo con validazione\n\nUn componente partecipa alla validazione quando definisce `self.validate`. La funzione riceve il valore e viene eseguita ogni volta che il valore cambia.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n\n<script>\nCOMPONENT('input', 'label:Field', function(self, config) {\n\n  self.make = function() {\n    self.html('<label>' + config.label + '</label><input type=\"text\" /><em></em>');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    if (!config.required)\n      return true;\n    if (!value)\n      return 'This field is required';\n    if (config.email && !value.isEmail())\n      return 'Enter a valid email address';\n    return true;\n  };\n\n  self.state = function() {\n    self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n  };\n\n});\n</script>\n```\n\n`self.autobind20()` collega l'`<input>` al path. Quando l'utente scrive `ann` nel campo email e ne esce, il modello è `{\"email\":\"ann\"}` e compare il messaggio `Enter a valid email address`.\n\nIl risultato di `self.validate` imposta `config.invalid`:\n\n| Risultato | Significato | `config.invalid` |\n| --- | --- | --- |\n| `true` o una stringa vuota | Valido | `false` |\n| Una stringa non vuota | Non valido, con un messaggio | Il messaggio |\n| Qualsiasi altro valore | Non valido | `true` |\n\n## Stato del campo\n\n| Valore | Classe CSS | Impostato quando |\n| --- | --- | --- |\n| `config.touched` | `ui-touched` | L'utente ha digitato nel campo o ne è uscito. |\n| `config.modified` | `ui-modified` | L'utente ha modificato il valore. |\n| `config.invalid` | `ui-invalid` | Il valore non ha superato la validazione. |\n| `config.disabled` | `ui-disabled` | Il componente è disabilitato. |\n\nLa libreria mantiene aggiornate le classi sull'elemento `<ui-component>` e chiama `self.state()` dopo ogni cambio di stato.\n\nUn campo obbligatorio vuoto non è valido fin dal caricamento della pagina. Controllando `config.touched` come nell'esempio precedente, il messaggio resta nascosto finché l'utente non ha lavorato sul campo.\n\n## Controllare il modulo\n\n`ERRORS(path, callback)` restituisce i componenti non validi sotto un path. Accetta anche un elemento jQuery e cerca al suo interno. `COMPONENTS(path)` restituisce i componenti che corrispondono ai flag nel path.\n\n```html\n<div id=\"contact\">\n  <ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.note\" config=\"label:Note\"></ui-component>\n</div>\n\n<script>\nON('ready', function() {\n  ERRORS('form', function(components) {\n    for (var component of components)\n      console.log(component.path.toString(), '-', component.config.invalid);\n  });\n\n  ERRORS($('#contact'), function(components) {\n    console.log(components.length);\n  });\n\n  console.log(COMPONENTS('form @invalid').length);\n  console.log(COMPONENTS('form @valid').length);\n  console.log(COMPONENTS('form @required').length);\n  console.log(COMPONENTS('form @modified').length);\n});\n</script>\n```\n\n```text\nform.name - This field is required\nform.email - This field is required\n2\n2\n1\n2\n0\n```\n\n`COMPONENTS()` riconosce i flag `@invalid`, `@valid`, `@touched`, `@modified`, `@required`, `@disabled`, `@enabled`, `@visible` e `@hidden`. `ERRORS('form @visible', callback)` salta i campi nascosti.\n\n## Disabilitare il pulsante di invio\n\nOsserva il modulo, conserva il risultato in un path e lascia che `<ui-bind>` disabiliti il pulsante:\n\n```html\n<ui-bind path=\"formstate.invalid\" config=\"disabled\"><button>Save</button></ui-bind>\n\n<script>\nON('ready', function() {\n\n  var check = function() {\n    ERRORS('form', function(components) {\n      SET('formstate.invalid', components.length > 0);\n    });\n  };\n\n  WATCH('form', check);\n  check();\n\n});\n</script>\n```\n\nIl pulsante resta disabilitato finché il nome è vuoto e si abilita dopo `SET('form.name', 'Ann')`.\n\n## Inviare il modulo\n\nControlla gli errori, invia `GET('form')` e reimposta il modulo dopo l'esito positivo. Il flag `@change` segna i campi come toccati e modificati, così i loro messaggi compaiono quando l'utente invia il modulo troppo presto.\n\n```js\nfunction submit() {\n  ERRORS('form', function(components) {\n\n    if (components.length) {\n      SET('form @change', GET('form'));\n      return;\n    }\n\n    AJAX('POST /api/contact/', GET('form'), function(response) {\n      if (response.success)\n        SET('form @reset', {});\n    });\n  });\n}\n```\n\n## Reimpostare e riempire il modulo\n\n| Chiamata | Effetto |\n| --- | --- |\n| `SET('form.name @change', value)` | Imposta il valore e segna il campo come toccato e modificato. |\n| `RESET('form')` | Azzera lo stato di toccato e modificato e mantiene i valori. |\n| `SET('form @reset', data)` | Sostituisce i dati e azzera lo stato. Usalo per caricare un record in un modulo. |\n| `SET('form @default', {})` | Sostituisce i dati, azzera lo stato e applica i valori predefiniti. |\n\nUn valore predefinito è un'espressione JavaScript nell'attributo `default` del componente. Viene applicato all'avvio e dal flag `@default` ogni volta che il valore è vuoto.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name\"></ui-component>\n<ui-component name=\"input\" path=\"form.country\" config=\"label:Country\" default=\"'Slovakia'\"></ui-component>\n\n<script>\nvar show = function(label) {\n  var c = FIND('.form.name');\n  console.log(label, JSON.stringify(GET('form')), c.config.touched, c.config.modified);\n};\n\nON('ready', function() {\n  SET('form.name @change', 'Ann');\n  show('@change');\n  RESET('form');\n  show('RESET');\n  SET('form @reset', { name: 'Bob', country: 'Austria' });\n  show('@reset');\n  SET('form @default', {});\n  show('@default');\n});\n</script>\n```\n\n```text\n@change {\"country\":\"Slovakia\",\"name\":\"Ann\"} 1 1\nRESET {\"country\":\"Slovakia\",\"name\":\"Ann\"} 0 0\n@reset {\"name\":\"Bob\",\"country\":\"Austria\"} 0 0\n@default {\"country\":\"Slovakia\"} 0 0\n```\n\nAltri flag sono descritti in [Flag e modificatori di path](../flags/).\n\n## Convertire il valore\n\nLa chiave `type` della configurazione converte il testo dell'`<input>` quando `autobind20()` lo scrive nel modello. Con `type:number`, digitando `42` viene salvato il numero `42`:\n\n```html\n<ui-component name=\"input\" path=\"form.age\" config=\"label:Age;type:number\"></ui-component>\n```\n\n## Un campo obbligatorio in base a una condizione\n\nIl comando `required` di `<ui-bind>` imposta `config.required` sui componenti al suo interno. Chiama `self.validate2()` da `self.configure` per validare di nuovo quando l'opzione cambia:\n\n```html\n<ui-bind path=\"form.company\" config=\"required\">\n  <div><ui-component name=\"input\" path=\"form.vat\" config=\"label:VAT number\"></ui-component></div>\n</ui-bind>\n\n<script>\nCOMPONENT('input', function(self, config) {\n\n  self.make = function() {\n    self.html('<input type=\"text\" />');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    return !config.required || !!value;\n  };\n\n  self.configure = function(key) {\n    if (key === 'required')\n      self.validate2();\n  };\n\n});\n</script>\n```\n\nAll'inizio il campo vuoto è valido. Dopo `SET('form.company', true)` è obbligatorio e non valido, mentre dopo `SET('form.company', false)` torna valido.\n\n## Moduli dentro un plugin\n\nUn [plugin](../plugins/) è il posto naturale per un modulo. I campi usano path con `?`, `exports.set('@reset', data)` riempie il modulo ed `exports.form` restituisce i dati e azzera lo stato dei campi.\n\n```html\n<ui-plugin path=\"contact\">\n  <ui-component name=\"input\" path=\"?.name\" config=\"label:Name;required:true\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('contact', function(exports) {\n\n  exports.load = function(data) {\n    exports.set('@reset', data);\n  };\n\n  exports.save = function() {\n    ERRORS(exports.name, function(components) {\n      console.log('errors', components.length);\n      if (!components.length)\n        console.log(JSON.stringify(exports.form));\n    });\n  };\n});\n</script>\n```\n\nChiamando `EXEC('contact/save')` sul modulo vuoto viene stampato `errors 1`. Dopo `EXEC('contact/load', { name: 'Ann' })` e `SET('contact.name @change', 'Anna')`, vengono stampati `errors 0` e `{\"name\":\"Anna\"}`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNK1md61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/forms/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Formuláre a validácia","summary":"Ako zostaviť formulár z komponentov, zvalidovať ho, zobraziť chyby, odoslať ho a vynulovať.","markdown":"---\ntitle: \"Formuláre a validácia\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/forms/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Formuláre a validácia\n\n> Ako zostaviť formulár z komponentov, zvalidovať ho, zobraziť chyby, odoslať ho a vynulovať.\n\nFormulár je skupina komponentov naviazaných na path pod jedným objektom, napríklad `form.name` a `form.email`. Každý komponent si drží vlastný stav: či sa ho používateľ dotkol, či ho zmenil a či je jeho hodnota platná. Táto príručka zostavuje formulár krok za krokom. Ako písať komponenty všeobecne, vysvetľuje časť [Vytváranie komponentov](../creating-components/).\n\n## Pole s validáciou\n\nKomponent sa zapojí do validácie, keď definuje `self.validate`. Funkcia dostane hodnotu a spustí sa pri každej jej zmene.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n<ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n\n<script>\nCOMPONENT('input', 'label:Field', function(self, config) {\n\n  self.make = function() {\n    self.html('<label>' + config.label + '</label><input type=\"text\" /><em></em>');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    if (!config.required)\n      return true;\n    if (!value)\n      return 'This field is required';\n    if (config.email && !value.isEmail())\n      return 'Enter a valid email address';\n    return true;\n  };\n\n  self.state = function() {\n    self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n  };\n\n});\n</script>\n```\n\n`self.autobind20()` prepojí `<input>` s path. Keď používateľ napíše do poľa pre e-mail `ann` a opustí ho, model je `{\"email\":\"ann\"}` a objaví sa správa `Enter a valid email address`.\n\nVýsledok `self.validate` nastaví `config.invalid`:\n\n| Výsledok | Význam | `config.invalid` |\n| --- | --- | --- |\n| `true` alebo prázdny reťazec | Platné | `false` |\n| Neprázdny reťazec | Neplatné, so správou | Správa |\n| Čokoľvek iné | Neplatné | `true` |\n\n## Stav poľa\n\n| Hodnota | CSS trieda | Nastaví sa, keď |\n| --- | --- | --- |\n| `config.touched` | `ui-touched` | Používateľ písal do poľa alebo ho opustil. |\n| `config.modified` | `ui-modified` | Používateľ zmenil hodnotu. |\n| `config.invalid` | `ui-invalid` | Hodnota neprešla validáciou. |\n| `config.disabled` | `ui-disabled` | Komponent je vypnutý. |\n\nKnižnica udržiava triedy na elemente `<ui-component>` aktuálne a po každej zmene stavu zavolá `self.state()`.\n\nPovinné prázdne pole je neplatné od chvíle načítania stránky. Testovanie `config.touched` ako v príklade vyššie drží správu skrytú, kým používateľ s poľom nepracoval.\n\n## Kontrola formulára\n\n`ERRORS(path, callback)` vráti neplatné komponenty pod path. Prijíma aj jQuery element a hľadá v jeho vnútri. `COMPONENTS(path)` vráti komponenty, ktoré zodpovedajú flagom v path.\n\n```html\n<div id=\"contact\">\n  <ui-component name=\"input\" path=\"form.name\" config=\"label:Name;required:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.email\" config=\"label:Email;required:true;email:true\"></ui-component>\n  <ui-component name=\"input\" path=\"form.note\" config=\"label:Note\"></ui-component>\n</div>\n\n<script>\nON('ready', function() {\n  ERRORS('form', function(components) {\n    for (var component of components)\n      console.log(component.path.toString(), '-', component.config.invalid);\n  });\n\n  ERRORS($('#contact'), function(components) {\n    console.log(components.length);\n  });\n\n  console.log(COMPONENTS('form @invalid').length);\n  console.log(COMPONENTS('form @valid').length);\n  console.log(COMPONENTS('form @required').length);\n  console.log(COMPONENTS('form @modified').length);\n});\n</script>\n```\n\n```text\nform.name - This field is required\nform.email - This field is required\n2\n2\n1\n2\n0\n```\n\n`COMPONENTS()` rozumie flagom `@invalid`, `@valid`, `@touched`, `@modified`, `@required`, `@disabled`, `@enabled`, `@visible` a `@hidden`. `ERRORS('form @visible', callback)` preskočí skryté polia.\n\n## Vypnutie odosielacieho tlačidla\n\nSleduj formulár, výsledok si drž v path a tlačidlo nechaj vypnúť elementom `<ui-bind>`:\n\n```html\n<ui-bind path=\"formstate.invalid\" config=\"disabled\"><button>Save</button></ui-bind>\n\n<script>\nON('ready', function() {\n\n  var check = function() {\n    ERRORS('form', function(components) {\n      SET('formstate.invalid', components.length > 0);\n    });\n  };\n\n  WATCH('form', check);\n  check();\n\n});\n</script>\n```\n\nTlačidlo je vypnuté, kým je meno prázdne, a po `SET('form.name', 'Ann')` sa zapne.\n\n## Odoslanie\n\nSkontroluj chyby, odošli `GET('form')` a po úspechu formulár vynuluj. Flag `@change` označí polia ako dotknuté a upravené, čím odhalí ich správy, keď používateľ odošle formulár priskoro.\n\n```js\nfunction submit() {\n  ERRORS('form', function(components) {\n\n    if (components.length) {\n      SET('form @change', GET('form'));\n      return;\n    }\n\n    AJAX('POST /api/contact/', GET('form'), function(response) {\n      if (response.success)\n        SET('form @reset', {});\n    });\n  });\n}\n```\n\n## Vynulovanie a vyplnenie formulára\n\n| Volanie | Účinok |\n| --- | --- |\n| `SET('form.name @change', value)` | Nastaví hodnotu a označí pole ako dotknuté a upravené. |\n| `RESET('form')` | Vymaže stav dotknutia a úpravy a ponechá hodnoty. |\n| `SET('form @reset', data)` | Nahradí dáta a vymaže stav. Použi to na načítanie záznamu do formulára. |\n| `SET('form @default', {})` | Nahradí dáta, vymaže stav a použije predvolené hodnoty. |\n\nPredvolená hodnota je JavaScriptový výraz v atribúte `default` komponentu. Použije sa pri štarte a cez flag `@default` vždy, keď je hodnota prázdna.\n\n```html\n<ui-component name=\"input\" path=\"form.name\" config=\"label:Name\"></ui-component>\n<ui-component name=\"input\" path=\"form.country\" config=\"label:Country\" default=\"'Slovakia'\"></ui-component>\n\n<script>\nvar show = function(label) {\n  var c = FIND('.form.name');\n  console.log(label, JSON.stringify(GET('form')), c.config.touched, c.config.modified);\n};\n\nON('ready', function() {\n  SET('form.name @change', 'Ann');\n  show('@change');\n  RESET('form');\n  show('RESET');\n  SET('form @reset', { name: 'Bob', country: 'Austria' });\n  show('@reset');\n  SET('form @default', {});\n  show('@default');\n});\n</script>\n```\n\n```text\n@change {\"country\":\"Slovakia\",\"name\":\"Ann\"} 1 1\nRESET {\"country\":\"Slovakia\",\"name\":\"Ann\"} 0 0\n@reset {\"name\":\"Bob\",\"country\":\"Austria\"} 0 0\n@default {\"country\":\"Slovakia\"} 0 0\n```\n\nĎalšie flagy opisuje časť [Flagy a modifikátory path](../flags/).\n\n## Prevod hodnoty\n\nKľúč `type` v konfigurácii prevedie text z `<input>`, keď ho `autobind20()` zapisuje do modelu. S `type:number` uloží napísanie `42` číslo `42`:\n\n```html\n<ui-component name=\"input\" path=\"form.age\" config=\"label:Age;type:number\"></ui-component>\n```\n\n## Pole povinné za určitej podmienky\n\nPríkaz `required` elementu `<ui-bind>` nastaví `config.required` komponentom v jeho vnútri. Zavolaj `self.validate2()` zo `self.configure`, aby sa pri zmene možnosti validácia zopakovala:\n\n```html\n<ui-bind path=\"form.company\" config=\"required\">\n  <div><ui-component name=\"input\" path=\"form.vat\" config=\"label:VAT number\"></ui-component></div>\n</ui-bind>\n\n<script>\nCOMPONENT('input', function(self, config) {\n\n  self.make = function() {\n    self.html('<input type=\"text\" />');\n    self.autobind20();\n  };\n\n  self.validate = function(value) {\n    return !config.required || !!value;\n  };\n\n  self.configure = function(key) {\n    if (key === 'required')\n      self.validate2();\n  };\n\n});\n</script>\n```\n\nPrázdne pole je spočiatku platné. Po `SET('form.company', true)` je povinné a neplatné a po `SET('form.company', false)` je znova platné.\n\n## Formuláre v plugine\n\n[Plugin](../plugins/) je prirodzeným domovom formulára. Polia používajú path s `?`, `exports.set('@reset', data)` formulár vyplní a `exports.form` vráti dáta a vymaže stav polí.\n\n```html\n<ui-plugin path=\"contact\">\n  <ui-component name=\"input\" path=\"?.name\" config=\"label:Name;required:true\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('contact', function(exports) {\n\n  exports.load = function(data) {\n    exports.set('@reset', data);\n  };\n\n  exports.save = function() {\n    ERRORS(exports.name, function(components) {\n      console.log('errors', components.length);\n      if (!components.length)\n        console.log(JSON.stringify(exports.form));\n    });\n  };\n});\n</script>\n```\n\nVolanie `EXEC('contact/save')` na prázdnom formulári vypíše `errors 1`. Po `EXEC('contact/load', { name: 'Ann' })` a `SET('contact.name @change', 'Anna')` vypíše `errors 0` a `{\"name\":\"Anna\"}`.\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNX1ud61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/guides/localization/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"en","title":"Localization","summary":"How to translate texts and adapt dates, numbers and currencies to a language.","markdown":"---\ntitle: Localization\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/guides/localization/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Localization\n\n> How to translate texts and adapt dates, numbers and currencies to a language.\n\nLocalization has two parts: translating the texts of the application, and showing dates, numbers and currencies the way the user expects.\n\n## Marking and translating texts\n\nA translatable text is written as `@(text)`. `LOCALIZE(text)` loads a dictionary and `TRANSLATE(text)` replaces the marked texts in a string.\n\nThe key of a dictionary entry is the hash of the original text in base 36, created with `HASH(text).toString(36)`. Each line of the dictionary has the form `key : translation`, and lines starting with `//` are comments.\n\n```js\nvar key = HASH('Save changes').toString(36);\nconsole.log(key);\n\nLOCALIZE([\n  '// German',\n  key + ' : Änderungen speichern',\n  HASH('Time').toString(36) + ' : Zeit: 10:30'\n].join('\\n'));\n\nconsole.log(TRANSLATE('<button>@(Save changes)</button>'));\nconsole.log(TRANSLATE('@(Time) / @(Not translated)'));\nconsole.log(JSON.stringify(DEF.dictionary));\n```\n\n```text\nbqgoqo\n<button>Änderungen speichern</button>\nZeit: 10:30 / Not translated\n{\"bqgoqo\":\"Änderungen speichern\",\"1jvfx\":\"Zeit: 10:30\"}\n```\n\nA text without a translation keeps its original wording. Keys may also start with the letter `T`, as in the resource files of the Total.js framework. Loaded entries are kept in `DEF.dictionary`, and each call to `LOCALIZE()` adds to them.\n\n## Loading a dictionary from a file\n\n```js\nAJAX('GET /locale/de.resource', function(text) {\n  LOCALIZE(text);\n  console.log(TRANSLATE('@(Close)')); // Schliessen\n});\n```\n\n## Where texts are translated\n\nContent loaded with `IMPORT()` and `<ui-import>` is translated automatically, so load the dictionary first. The static HTML of the page is not translated.\n\n```html\n<div id=\"page\">@(Save)</div>\n<div id=\"part\"></div>\n\n<script>\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\n\n// /parts/save.html contains: <button>@(Save)</button>\nIMPORT('/parts/save.html', '#part', function() {\n  console.log($('#part').html()); // <button>Speichern</button>\n  console.log($('#page').html()); // @(Save)\n});\n</script>\n```\n\nA component translates its own markup by calling `TRANSLATE()`:\n\n```js\nCOMPONENT('savebutton', function(self) {\n  self.make = function() {\n    self.html(TRANSLATE('<button>@(Save)</button>'));\n  };\n});\n```\n\nMore about loading content is in [Importing content](../importing/).\n\n## Sending the language to the server\n\n`DEF.language` is added to the URL of every `AJAX()` request, unless the URL already contains the parameter. `DEF.languagekey` is the name of the parameter, and the default is `language`. `ENVIRONMENT(name, version, language)` sets the storage name, the version and the language in one call.\n\n```js\nENVIRONMENT('myapp', '1.5', 'de');\n\nAJAX('GET /api/products/', NOOP);\nAJAX('GET /parts/menu.html', NOOP);\nAJAX('GET /api/products/?language=en', NOOP);\n```\n\nThe requests go to these addresses:\n\n```text\n/api/products/?language=de\n/parts/menu.html?version=1.5&language=de\n/api/products/?language=en\n```\n\n## Dates\n\n`MONTHS` and `DAYS` hold the names used by `Date.format()`, and `DEF.dateformat` is the format used when no format is given. `DAYS` starts with Sunday.\n\n```js\nMONTHS[0] = 'Januar';\nDAYS[1] = 'Montag';\nDEF.dateformat = 'dd.MM.yyyy';\n\nvar date = new Date(2026, 0, 5, 14, 3);\n\ndate.format();                     // 05.01.2026\ndate.format('dddd, d. MMMM yyyy'); // Montag, 5. Januar 2026\ndate.format('HH:mm');              // 14:03\n```\n\nThe tokens of the format are listed in [Date](../../reference/date/).\n\n## Numbers\n\n`DEF.thousandsseparator` and `DEF.decimalseparator` control `Number.format()`:\n\n```js\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\n(1234567.891).format(2); // 1.234.567,89\n```\n\n## Currencies\n\n`DEF.currencies` holds a formatting function for each currency, and `DEF.currency` is the default one. `Number.currency()` and the Tangular helper `currency` use them.\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' €';\n};\nDEF.currency = 'eur';\n\n(1234.5).currency();      // 1.234,50 €\n(1234.5).currency('eur'); // 1.234,50 €\n\nTangular.render('{{ price | currency }}', { price: 99 }); // 99,00 €\n```\n\nThe output above uses the separators from the previous section.\n\n## Plural forms\n\n`Number.pluralize(zero, one, few, other)` selects a text by the number. `few` applies to the numbers from 2 to 4, and `other` to the rest. `#` is replaced by the number and `##` by the formatted number.\n\n```js\nvar text = function(count) {\n  return count.pluralize('No files', '# file', '# files (few)', '# files');\n};\n\ntext(0); // No files\ntext(1); // 1 file\ntext(3); // 3 files (few)\ntext(5); // 5 files\n\n(1500).pluralize('none', 'one', 'few', '## files'); // 1 500 files\n```\n\nIn a template, the same function is available as the helper `pluralize`. See [Templates with Tangular](../tangular/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNX1ud61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/localization/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"de","title":"Lokalisierung","summary":"Wie du Texte übersetzt und Datumsangaben, Zahlen und Währungen an eine Sprache anpasst.","markdown":"---\ntitle: Lokalisierung\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/guides/localization/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Lokalisierung\n\n> Wie du Texte übersetzt und Datumsangaben, Zahlen und Währungen an eine Sprache anpasst.\n\nLokalisierung besteht aus zwei Teilen: die Texte der Anwendung zu übersetzen und Datumsangaben, Zahlen und Währungen so anzuzeigen, wie der Benutzer es erwartet.\n\n## Texte markieren und übersetzen\n\nEin übersetzbarer Text wird als `@(text)` geschrieben. `LOCALIZE(text)` lädt ein Wörterbuch, und `TRANSLATE(text)` ersetzt die markierten Texte in einem String.\n\nDer Schlüssel eines Wörterbucheintrags ist der Hash des Originaltexts zur Basis 36, erzeugt mit `HASH(text).toString(36)`. Jede Zeile des Wörterbuchs hat die Form `key : translation`, und Zeilen, die mit `//` beginnen, sind Kommentare.\n\n```js\nvar key = HASH('Save changes').toString(36);\nconsole.log(key);\n\nLOCALIZE([\n  '// German',\n  key + ' : Änderungen speichern',\n  HASH('Time').toString(36) + ' : Zeit: 10:30'\n].join('\\n'));\n\nconsole.log(TRANSLATE('<button>@(Save changes)</button>'));\nconsole.log(TRANSLATE('@(Time) / @(Not translated)'));\nconsole.log(JSON.stringify(DEF.dictionary));\n```\n\n```text\nbqgoqo\n<button>Änderungen speichern</button>\nZeit: 10:30 / Not translated\n{\"bqgoqo\":\"Änderungen speichern\",\"1jvfx\":\"Zeit: 10:30\"}\n```\n\nEin Text ohne Übersetzung behält seinen ursprünglichen Wortlaut. Schlüssel dürfen auch mit dem Buchstaben `T` beginnen, wie in den Ressourcendateien des Total.js-Frameworks. Geladene Einträge liegen in `DEF.dictionary`, und jeder Aufruf von `LOCALIZE()` ergänzt sie.\n\n## Ein Wörterbuch aus einer Datei laden\n\n```js\nAJAX('GET /locale/de.resource', function(text) {\n  LOCALIZE(text);\n  console.log(TRANSLATE('@(Close)')); // Schliessen\n});\n```\n\n## Wo Texte übersetzt werden\n\nMit `IMPORT()` und `<ui-import>` geladene Inhalte werden automatisch übersetzt, lade also zuerst das Wörterbuch. Das statische HTML der Seite wird nicht übersetzt.\n\n```html\n<div id=\"page\">@(Save)</div>\n<div id=\"part\"></div>\n\n<script>\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\n\n// /parts/save.html contains: <button>@(Save)</button>\nIMPORT('/parts/save.html', '#part', function() {\n  console.log($('#part').html()); // <button>Speichern</button>\n  console.log($('#page').html()); // @(Save)\n});\n</script>\n```\n\nEine Komponente übersetzt ihr eigenes Markup, indem sie `TRANSLATE()` aufruft:\n\n```js\nCOMPONENT('savebutton', function(self) {\n  self.make = function() {\n    self.html(TRANSLATE('<button>@(Save)</button>'));\n  };\n});\n```\n\nMehr zum Laden von Inhalten erfährst du unter [Inhalte importieren](../importing/).\n\n## Die Sprache an den Server senden\n\n`DEF.language` wird an die URL jeder `AJAX()`-Anfrage angehängt, sofern die URL den Parameter nicht bereits enthält. `DEF.languagekey` ist der Name des Parameters, Standard ist `language`. `ENVIRONMENT(name, version, language)` setzt den Speichernamen, die Version und die Sprache in einem Aufruf.\n\n```js\nENVIRONMENT('myapp', '1.5', 'de');\n\nAJAX('GET /api/products/', NOOP);\nAJAX('GET /parts/menu.html', NOOP);\nAJAX('GET /api/products/?language=en', NOOP);\n```\n\nDie Anfragen gehen an diese Adressen:\n\n```text\n/api/products/?language=de\n/parts/menu.html?version=1.5&language=de\n/api/products/?language=en\n```\n\n## Datumsangaben\n\n`MONTHS` und `DAYS` enthalten die von `Date.format()` verwendeten Namen, und `DEF.dateformat` ist das Format, das gilt, wenn keines angegeben ist. `DAYS` beginnt mit Sonntag.\n\n```js\nMONTHS[0] = 'Januar';\nDAYS[1] = 'Montag';\nDEF.dateformat = 'dd.MM.yyyy';\n\nvar date = new Date(2026, 0, 5, 14, 3);\n\ndate.format();                     // 05.01.2026\ndate.format('dddd, d. MMMM yyyy'); // Montag, 5. Januar 2026\ndate.format('HH:mm');              // 14:03\n```\n\nDie Tokens des Formats findest du unter [Date](../../reference/date/).\n\n## Zahlen\n\n`DEF.thousandsseparator` und `DEF.decimalseparator` steuern `Number.format()`:\n\n```js\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\n(1234567.891).format(2); // 1.234.567,89\n```\n\n## Währungen\n\n`DEF.currencies` enthält für jede Währung eine Formatierungsfunktion, und `DEF.currency` ist die Standardwährung. `Number.currency()` und der Tangular-Helper `currency` verwenden sie.\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' €';\n};\nDEF.currency = 'eur';\n\n(1234.5).currency();      // 1.234,50 €\n(1234.5).currency('eur'); // 1.234,50 €\n\nTangular.render('{{ price | currency }}', { price: 99 }); // 99,00 €\n```\n\nDie Ausgabe oben verwendet die Trennzeichen aus dem vorherigen Abschnitt.\n\n## Pluralformen\n\n`Number.pluralize(zero, one, few, other)` wählt einen Text anhand der Zahl. `few` gilt für die Zahlen von 2 bis 4 und `other` für den Rest. `#` wird durch die Zahl ersetzt und `##` durch die formatierte Zahl.\n\n```js\nvar text = function(count) {\n  return count.pluralize('No files', '# file', '# files (few)', '# files');\n};\n\ntext(0); // No files\ntext(1); // 1 file\ntext(3); // 3 files (few)\ntext(5); // 5 files\n\n(1500).pluralize('none', 'one', 'few', '## files'); // 1 500 files\n```\n\nIn einem Template steht dieselbe Funktion als Helper `pluralize` zur Verfügung. Siehe [Templates mit Tangular](../tangular/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNX1ud61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/localization/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"es","title":"Localización","summary":"Cómo traducir textos y adaptar fechas, números y monedas a un idioma.","markdown":"---\ntitle: \"Localización\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/guides/localization/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Localización\n\n> Cómo traducir textos y adaptar fechas, números y monedas a un idioma.\n\nLa localización tiene dos partes: traducir los textos de la aplicación y mostrar las fechas, los números y las monedas como espera el usuario.\n\n## Marcar y traducir textos\n\nUn texto traducible se escribe como `@(text)`. `LOCALIZE(text)` carga un diccionario y `TRANSLATE(text)` sustituye los textos marcados de una cadena.\n\nLa clave de una entrada del diccionario es el hash del texto original en base 36, creado con `HASH(text).toString(36)`. Cada línea del diccionario tiene la forma `key : translation`, y las líneas que empiezan por `//` son comentarios.\n\n```js\nvar key = HASH('Save changes').toString(36);\nconsole.log(key);\n\nLOCALIZE([\n  '// German',\n  key + ' : Änderungen speichern',\n  HASH('Time').toString(36) + ' : Zeit: 10:30'\n].join('\\n'));\n\nconsole.log(TRANSLATE('<button>@(Save changes)</button>'));\nconsole.log(TRANSLATE('@(Time) / @(Not translated)'));\nconsole.log(JSON.stringify(DEF.dictionary));\n```\n\n```text\nbqgoqo\n<button>Änderungen speichern</button>\nZeit: 10:30 / Not translated\n{\"bqgoqo\":\"Änderungen speichern\",\"1jvfx\":\"Zeit: 10:30\"}\n```\n\nUn texto sin traducción conserva su redacción original. Las claves también pueden empezar por la letra `T`, como en los archivos de recursos del framework Total.js. Las entradas cargadas se guardan en `DEF.dictionary`, y cada llamada a `LOCALIZE()` añade otras nuevas.\n\n## Cargar un diccionario desde un archivo\n\n```js\nAJAX('GET /locale/de.resource', function(text) {\n  LOCALIZE(text);\n  console.log(TRANSLATE('@(Close)')); // Schliessen\n});\n```\n\n## Dónde se traducen los textos\n\nEl contenido cargado con `IMPORT()` y `<ui-import>` se traduce automáticamente, así que carga antes el diccionario. El HTML estático de la página no se traduce.\n\n```html\n<div id=\"page\">@(Save)</div>\n<div id=\"part\"></div>\n\n<script>\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\n\n// /parts/save.html contains: <button>@(Save)</button>\nIMPORT('/parts/save.html', '#part', function() {\n  console.log($('#part').html()); // <button>Speichern</button>\n  console.log($('#page').html()); // @(Save)\n});\n</script>\n```\n\nUn componente traduce su propio marcado llamando a `TRANSLATE()`:\n\n```js\nCOMPONENT('savebutton', function(self) {\n  self.make = function() {\n    self.html(TRANSLATE('<button>@(Save)</button>'));\n  };\n});\n```\n\nEncontrarás más sobre la carga de contenido en [Importar contenido](../importing/).\n\n## Enviar el idioma al servidor\n\n`DEF.language` se añade a la URL de cada petición `AJAX()`, salvo que la URL ya contenga el parámetro. `DEF.languagekey` es el nombre del parámetro, y su valor predeterminado es `language`. `ENVIRONMENT(name, version, language)` establece en una sola llamada el nombre del almacenamiento, la versión y el idioma.\n\n```js\nENVIRONMENT('myapp', '1.5', 'de');\n\nAJAX('GET /api/products/', NOOP);\nAJAX('GET /parts/menu.html', NOOP);\nAJAX('GET /api/products/?language=en', NOOP);\n```\n\nLas peticiones van a estas direcciones:\n\n```text\n/api/products/?language=de\n/parts/menu.html?version=1.5&language=de\n/api/products/?language=en\n```\n\n## Fechas\n\n`MONTHS` y `DAYS` contienen los nombres que usa `Date.format()`, y `DEF.dateformat` es el formato que se usa cuando no se indica ninguno. `DAYS` empieza por el domingo.\n\n```js\nMONTHS[0] = 'Januar';\nDAYS[1] = 'Montag';\nDEF.dateformat = 'dd.MM.yyyy';\n\nvar date = new Date(2026, 0, 5, 14, 3);\n\ndate.format();                     // 05.01.2026\ndate.format('dddd, d. MMMM yyyy'); // Montag, 5. Januar 2026\ndate.format('HH:mm');              // 14:03\n```\n\nLos tokens del formato aparecen en [Date](../../reference/date/).\n\n## Números\n\n`DEF.thousandsseparator` y `DEF.decimalseparator` controlan `Number.format()`:\n\n```js\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\n(1234567.891).format(2); // 1.234.567,89\n```\n\n## Monedas\n\n`DEF.currencies` contiene una función de formato para cada moneda, y `DEF.currency` es la predeterminada. `Number.currency()` y el helper `currency` de Tangular las usan.\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' €';\n};\nDEF.currency = 'eur';\n\n(1234.5).currency();      // 1.234,50 €\n(1234.5).currency('eur'); // 1.234,50 €\n\nTangular.render('{{ price | currency }}', { price: 99 }); // 99,00 €\n```\n\nLa salida anterior usa los separadores de la sección previa.\n\n## Formas de plural\n\n`Number.pluralize(zero, one, few, other)` selecciona un texto según el número. `few` se aplica a los números del 2 al 4, y `other` al resto. `#` se sustituye por el número y `##` por el número con formato.\n\n```js\nvar text = function(count) {\n  return count.pluralize('No files', '# file', '# files (few)', '# files');\n};\n\ntext(0); // No files\ntext(1); // 1 file\ntext(3); // 3 files (few)\ntext(5); // 5 files\n\n(1500).pluralize('none', 'one', 'few', '## files'); // 1 500 files\n```\n\nEn una plantilla, la misma función está disponible como helper `pluralize`. Consulta [Plantillas con Tangular](../tangular/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNX1ud61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/localization/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"fr","title":"Localisation","summary":"Comment traduire les textes et adapter les dates, les nombres et les devises à une langue.","markdown":"---\ntitle: Localisation\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/guides/localization/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Localisation\n\n> Comment traduire les textes et adapter les dates, les nombres et les devises à une langue.\n\nLa localisation comporte deux volets : traduire les textes de l'application, et afficher les dates, les nombres et les devises comme l'utilisateur s'y attend.\n\n## Marquer et traduire les textes\n\nUn texte traduisible s'écrit `@(text)`. `LOCALIZE(text)` charge un dictionnaire et `TRANSLATE(text)` remplace les textes marqués dans une chaîne.\n\nLa clé d'une entrée du dictionnaire est le hachage du texte d'origine en base 36, créé avec `HASH(text).toString(36)`. Chaque ligne du dictionnaire a la forme `key : translation`, et les lignes commençant par `//` sont des commentaires.\n\n```js\nvar key = HASH('Save changes').toString(36);\nconsole.log(key);\n\nLOCALIZE([\n  '// German',\n  key + ' : Änderungen speichern',\n  HASH('Time').toString(36) + ' : Zeit: 10:30'\n].join('\\n'));\n\nconsole.log(TRANSLATE('<button>@(Save changes)</button>'));\nconsole.log(TRANSLATE('@(Time) / @(Not translated)'));\nconsole.log(JSON.stringify(DEF.dictionary));\n```\n\n```text\nbqgoqo\n<button>Änderungen speichern</button>\nZeit: 10:30 / Not translated\n{\"bqgoqo\":\"Änderungen speichern\",\"1jvfx\":\"Zeit: 10:30\"}\n```\n\nUn texte sans traduction conserve sa formulation d'origine. Les clés peuvent aussi commencer par la lettre `T`, comme dans les fichiers de ressources du framework Total.js. Les entrées chargées sont conservées dans `DEF.dictionary`, et chaque appel à `LOCALIZE()` les complète.\n\n## Charger un dictionnaire depuis un fichier\n\n```js\nAJAX('GET /locale/de.resource', function(text) {\n  LOCALIZE(text);\n  console.log(TRANSLATE('@(Close)')); // Schliessen\n});\n```\n\n## Où les textes sont traduits\n\nLe contenu chargé avec `IMPORT()` et `<ui-import>` est traduit automatiquement : charge donc d'abord le dictionnaire. Le HTML statique de la page n'est pas traduit.\n\n```html\n<div id=\"page\">@(Save)</div>\n<div id=\"part\"></div>\n\n<script>\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\n\n// /parts/save.html contains: <button>@(Save)</button>\nIMPORT('/parts/save.html', '#part', function() {\n  console.log($('#part').html()); // <button>Speichern</button>\n  console.log($('#page').html()); // @(Save)\n});\n</script>\n```\n\nUn composant traduit son propre balisage en appelant `TRANSLATE()` :\n\n```js\nCOMPONENT('savebutton', function(self) {\n  self.make = function() {\n    self.html(TRANSLATE('<button>@(Save)</button>'));\n  };\n});\n```\n\nPour en savoir plus sur le chargement de contenu, lis [Importer du contenu](../importing/).\n\n## Envoyer la langue au serveur\n\n`DEF.language` est ajouté à l'URL de chaque requête `AJAX()`, sauf si l'URL contient déjà le paramètre. `DEF.languagekey` est le nom du paramètre, et sa valeur par défaut est `language`. `ENVIRONMENT(name, version, language)` définit le nom du stockage, la version et la langue en un seul appel.\n\n```js\nENVIRONMENT('myapp', '1.5', 'de');\n\nAJAX('GET /api/products/', NOOP);\nAJAX('GET /parts/menu.html', NOOP);\nAJAX('GET /api/products/?language=en', NOOP);\n```\n\nLes requêtes sont envoyées à ces adresses :\n\n```text\n/api/products/?language=de\n/parts/menu.html?version=1.5&language=de\n/api/products/?language=en\n```\n\n## Dates\n\n`MONTHS` et `DAYS` contiennent les noms utilisés par `Date.format()`, et `DEF.dateformat` est le format utilisé quand aucun format n'est indiqué. `DAYS` commence par le dimanche.\n\n```js\nMONTHS[0] = 'Januar';\nDAYS[1] = 'Montag';\nDEF.dateformat = 'dd.MM.yyyy';\n\nvar date = new Date(2026, 0, 5, 14, 3);\n\ndate.format();                     // 05.01.2026\ndate.format('dddd, d. MMMM yyyy'); // Montag, 5. Januar 2026\ndate.format('HH:mm');              // 14:03\n```\n\nLes jetons du format sont répertoriés dans [Date](../../reference/date/).\n\n## Nombres\n\n`DEF.thousandsseparator` et `DEF.decimalseparator` contrôlent `Number.format()` :\n\n```js\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\n(1234567.891).format(2); // 1.234.567,89\n```\n\n## Devises\n\n`DEF.currencies` contient une fonction de formatage pour chaque devise, et `DEF.currency` est la devise par défaut. `Number.currency()` et le helper Tangular `currency` les utilisent.\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' €';\n};\nDEF.currency = 'eur';\n\n(1234.5).currency();      // 1.234,50 €\n(1234.5).currency('eur'); // 1.234,50 €\n\nTangular.render('{{ price | currency }}', { price: 99 }); // 99,00 €\n```\n\nLa sortie ci-dessus utilise les séparateurs de la section précédente.\n\n## Formes du pluriel\n\n`Number.pluralize(zero, one, few, other)` sélectionne un texte en fonction du nombre. `few` s'applique aux nombres de 2 à 4, et `other` aux autres. `#` est remplacé par le nombre et `##` par le nombre formaté.\n\n```js\nvar text = function(count) {\n  return count.pluralize('No files', '# file', '# files (few)', '# files');\n};\n\ntext(0); // No files\ntext(1); // 1 file\ntext(3); // 3 files (few)\ntext(5); // 5 files\n\n(1500).pluralize('none', 'one', 'few', '## files'); // 1 500 files\n```\n\nDans un modèle, la même fonction est disponible sous la forme du helper `pluralize`. Consulte [Modèles avec Tangular](../tangular/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNX1ud61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/localization/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"it","title":"Localizzazione","summary":"Come tradurre i testi e adattare date, numeri e valute a una lingua.","markdown":"---\ntitle: Localizzazione\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/guides/localization/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Localizzazione\n\n> Come tradurre i testi e adattare date, numeri e valute a una lingua.\n\nLa localizzazione ha due parti: tradurre i testi dell'applicazione e mostrare date, numeri e valute nel modo che l'utente si aspetta.\n\n## Contrassegnare e tradurre i testi\n\nUn testo traducibile si scrive come `@(text)`. `LOCALIZE(text)` carica un dizionario e `TRANSLATE(text)` sostituisce i testi contrassegnati in una stringa.\n\nLa chiave di una voce del dizionario è l'hash del testo originale in base 36, creato con `HASH(text).toString(36)`. Ogni riga del dizionario ha la forma `key : translation` e le righe che iniziano con `//` sono commenti.\n\n```js\nvar key = HASH('Save changes').toString(36);\nconsole.log(key);\n\nLOCALIZE([\n  '// German',\n  key + ' : Änderungen speichern',\n  HASH('Time').toString(36) + ' : Zeit: 10:30'\n].join('\\n'));\n\nconsole.log(TRANSLATE('<button>@(Save changes)</button>'));\nconsole.log(TRANSLATE('@(Time) / @(Not translated)'));\nconsole.log(JSON.stringify(DEF.dictionary));\n```\n\n```text\nbqgoqo\n<button>Änderungen speichern</button>\nZeit: 10:30 / Not translated\n{\"bqgoqo\":\"Änderungen speichern\",\"1jvfx\":\"Zeit: 10:30\"}\n```\n\nUn testo senza traduzione mantiene la sua formulazione originale. Le chiavi possono anche iniziare con la lettera `T`, come nei file di risorse del framework Total.js. Le voci caricate vengono conservate in `DEF.dictionary` e ogni chiamata a `LOCALIZE()` ne aggiunge altre.\n\n## Caricare un dizionario da un file\n\n```js\nAJAX('GET /locale/de.resource', function(text) {\n  LOCALIZE(text);\n  console.log(TRANSLATE('@(Close)')); // Schliessen\n});\n```\n\n## Dove vengono tradotti i testi\n\nI contenuti caricati con `IMPORT()` e `<ui-import>` vengono tradotti automaticamente, quindi carica prima il dizionario. L'HTML statico della pagina non viene tradotto.\n\n```html\n<div id=\"page\">@(Save)</div>\n<div id=\"part\"></div>\n\n<script>\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\n\n// /parts/save.html contains: <button>@(Save)</button>\nIMPORT('/parts/save.html', '#part', function() {\n  console.log($('#part').html()); // <button>Speichern</button>\n  console.log($('#page').html()); // @(Save)\n});\n</script>\n```\n\nUn componente traduce il proprio markup chiamando `TRANSLATE()`:\n\n```js\nCOMPONENT('savebutton', function(self) {\n  self.make = function() {\n    self.html(TRANSLATE('<button>@(Save)</button>'));\n  };\n});\n```\n\nTrovi altre informazioni sul caricamento dei contenuti in [Importare contenuti](../importing/).\n\n## Inviare la lingua al server\n\n`DEF.language` viene aggiunto all'URL di ogni richiesta `AJAX()`, a meno che l'URL non contenga già il parametro. `DEF.languagekey` è il nome del parametro e il valore predefinito è `language`. `ENVIRONMENT(name, version, language)` imposta il nome dello storage, la versione e la lingua con una sola chiamata.\n\n```js\nENVIRONMENT('myapp', '1.5', 'de');\n\nAJAX('GET /api/products/', NOOP);\nAJAX('GET /parts/menu.html', NOOP);\nAJAX('GET /api/products/?language=en', NOOP);\n```\n\nLe richieste vanno a questi indirizzi:\n\n```text\n/api/products/?language=de\n/parts/menu.html?version=1.5&language=de\n/api/products/?language=en\n```\n\n## Date\n\n`MONTHS` e `DAYS` contengono i nomi usati da `Date.format()` e `DEF.dateformat` è il formato usato quando non ne viene indicato uno. `DAYS` inizia dalla domenica.\n\n```js\nMONTHS[0] = 'Januar';\nDAYS[1] = 'Montag';\nDEF.dateformat = 'dd.MM.yyyy';\n\nvar date = new Date(2026, 0, 5, 14, 3);\n\ndate.format();                     // 05.01.2026\ndate.format('dddd, d. MMMM yyyy'); // Montag, 5. Januar 2026\ndate.format('HH:mm');              // 14:03\n```\n\nI token del formato sono elencati in [Date](../../reference/date/).\n\n## Numeri\n\n`DEF.thousandsseparator` e `DEF.decimalseparator` controllano `Number.format()`:\n\n```js\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\n(1234567.891).format(2); // 1.234.567,89\n```\n\n## Valute\n\n`DEF.currencies` contiene una funzione di formattazione per ogni valuta e `DEF.currency` è quella predefinita. `Number.currency()` e l'helper Tangular `currency` le usano.\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' €';\n};\nDEF.currency = 'eur';\n\n(1234.5).currency();      // 1.234,50 €\n(1234.5).currency('eur'); // 1.234,50 €\n\nTangular.render('{{ price | currency }}', { price: 99 }); // 99,00 €\n```\n\nL'output precedente usa i separatori della sezione precedente.\n\n## Forme plurali\n\n`Number.pluralize(zero, one, few, other)` seleziona un testo in base al numero. `few` si applica ai numeri da 2 a 4 e `other` a tutti gli altri. `#` viene sostituito dal numero e `##` dal numero formattato.\n\n```js\nvar text = function(count) {\n  return count.pluralize('No files', '# file', '# files (few)', '# files');\n};\n\ntext(0); // No files\ntext(1); // 1 file\ntext(3); // 3 files (few)\ntext(5); // 5 files\n\n(1500).pluralize('none', 'one', 'few', '## files'); // 1 500 files\n```\n\nIn un template, la stessa funzione è disponibile come helper `pluralize`. Consulta [Template con Tangular](../tangular/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcNX1ud61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/localization/","project":"jcomponent-v20","version":"20-015","section":"guides","language":"sk","title":"Lokalizácia","summary":"Ako prekladať texty a prispôsobiť dátumy, čísla a meny jazyku.","markdown":"---\ntitle: \"Lokalizácia\"\nproject: jComponent V20\nversion: 20.015\nsection: guides\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/guides/localization/\nupdated: 2026-11-18T13:55:39.124Z\n---\n\n# Lokalizácia\n\n> Ako prekladať texty a prispôsobiť dátumy, čísla a meny jazyku.\n\nLokalizácia má dve časti: preklad textov aplikácie a zobrazovanie dátumov, čísel a mien tak, ako to používateľ očakáva.\n\n## Označovanie a preklad textov\n\nPreložiteľný text sa zapisuje ako `@(text)`. `LOCALIZE(text)` načíta slovník a `TRANSLATE(text)` nahradí označené texty v reťazci.\n\nKľúčom položky slovníka je hash pôvodného textu v základe 36, vytvorený cez `HASH(text).toString(36)`. Každý riadok slovníka má tvar `key : translation` a riadky začínajúce na `//` sú komentáre.\n\n```js\nvar key = HASH('Save changes').toString(36);\nconsole.log(key);\n\nLOCALIZE([\n  '// German',\n  key + ' : Änderungen speichern',\n  HASH('Time').toString(36) + ' : Zeit: 10:30'\n].join('\\n'));\n\nconsole.log(TRANSLATE('<button>@(Save changes)</button>'));\nconsole.log(TRANSLATE('@(Time) / @(Not translated)'));\nconsole.log(JSON.stringify(DEF.dictionary));\n```\n\n```text\nbqgoqo\n<button>Änderungen speichern</button>\nZeit: 10:30 / Not translated\n{\"bqgoqo\":\"Änderungen speichern\",\"1jvfx\":\"Zeit: 10:30\"}\n```\n\nText bez prekladu si ponechá pôvodné znenie. Kľúče môžu začínať aj písmenom `T`, ako v súboroch zdrojov frameworku Total.js. Načítané položky sa uchovávajú v `DEF.dictionary` a každé volanie `LOCALIZE()` k nim pridáva ďalšie.\n\n## Načítanie slovníka zo súboru\n\n```js\nAJAX('GET /locale/de.resource', function(text) {\n  LOCALIZE(text);\n  console.log(TRANSLATE('@(Close)')); // Schliessen\n});\n```\n\n## Kde sa texty prekladajú\n\nObsah načítaný cez `IMPORT()` a `<ui-import>` sa prekladá automaticky, preto najprv načítaj slovník. Statické HTML stránky sa neprekladá.\n\n```html\n<div id=\"page\">@(Save)</div>\n<div id=\"part\"></div>\n\n<script>\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\n\n// /parts/save.html contains: <button>@(Save)</button>\nIMPORT('/parts/save.html', '#part', function() {\n  console.log($('#part').html()); // <button>Speichern</button>\n  console.log($('#page').html()); // @(Save)\n});\n</script>\n```\n\nKomponent preloží svoje vlastné značkovanie zavolaním `TRANSLATE()`:\n\n```js\nCOMPONENT('savebutton', function(self) {\n  self.make = function() {\n    self.html(TRANSLATE('<button>@(Save)</button>'));\n  };\n});\n```\n\nViac o načítavaní obsahu sa dočítaš v časti [Import obsahu](../importing/).\n\n## Odosielanie jazyka na server\n\n`DEF.language` sa pridáva do URL každej požiadavky `AJAX()`, pokiaľ URL daný parameter už neobsahuje. `DEF.languagekey` je názov parametra a predvolene je to `language`. `ENVIRONMENT(name, version, language)` nastaví názov úložiska, verziu a jazyk jedným volaním.\n\n```js\nENVIRONMENT('myapp', '1.5', 'de');\n\nAJAX('GET /api/products/', NOOP);\nAJAX('GET /parts/menu.html', NOOP);\nAJAX('GET /api/products/?language=en', NOOP);\n```\n\nPožiadavky idú na tieto adresy:\n\n```text\n/api/products/?language=de\n/parts/menu.html?version=1.5&language=de\n/api/products/?language=en\n```\n\n## Dátumy\n\n`MONTHS` a `DAYS` obsahujú názvy, ktoré používa `Date.format()`, a `DEF.dateformat` je formát použitý vtedy, keď žiadny nie je zadaný. `DAYS` začína nedeľou.\n\n```js\nMONTHS[0] = 'Januar';\nDAYS[1] = 'Montag';\nDEF.dateformat = 'dd.MM.yyyy';\n\nvar date = new Date(2026, 0, 5, 14, 3);\n\ndate.format();                     // 05.01.2026\ndate.format('dddd, d. MMMM yyyy'); // Montag, 5. Januar 2026\ndate.format('HH:mm');              // 14:03\n```\n\nTokeny formátu uvádza časť [Date](../../reference/date/).\n\n## Čísla\n\n`DEF.thousandsseparator` a `DEF.decimalseparator` riadia `Number.format()`:\n\n```js\nDEF.thousandsseparator = '.';\nDEF.decimalseparator = ',';\n\n(1234567.891).format(2); // 1.234.567,89\n```\n\n## Meny\n\n`DEF.currencies` obsahuje formátovaciu funkciu pre každú menu a `DEF.currency` je predvolená mena. Používajú ich `Number.currency()` a helper Tangular `currency`.\n\n```js\nDEF.currencies.eur = function(value) {\n  return value.format(2) + ' €';\n};\nDEF.currency = 'eur';\n\n(1234.5).currency();      // 1.234,50 €\n(1234.5).currency('eur'); // 1.234,50 €\n\nTangular.render('{{ price | currency }}', { price: 99 }); // 99,00 €\n```\n\nVýstup vyššie používa oddeľovače z predchádzajúcej časti.\n\n## Tvary množného čísla\n\n`Number.pluralize(zero, one, few, other)` vyberie text podľa čísla. `few` platí pre čísla od 2 do 4 a `other` pre ostatné. `#` sa nahradí číslom a `##` naformátovaným číslom.\n\n```js\nvar text = function(count) {\n  return count.pluralize('No files', '# file', '# files (few)', '# files');\n};\n\ntext(0); // No files\ntext(1); // 1 file\ntext(3); // 3 files (few)\ntext(5); // 5 files\n\n(1500).pluralize('none', 'one', 'few', '## files'); // 1 500 files\n```\n\nV šablóne je tá istá funkcia dostupná ako helper `pluralize`. Pozri [Šablóny s Tangular](../tangular/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:39.124Z"}
{"id":"JamcS61wo61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/globals/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"Global functions","summary":"The functions and variables that the library adds to the window object.","markdown":"---\ntitle: Global functions\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/globals/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Global functions\n\n> The functions and variables that the library adds to the window object.\n\nThe library adds these functions and variables to `window`, so they are available everywhere in your code. Start with [Paths](../../guides/paths/) and [Data binding](../../guides/data-binding/) to see how they work together.\n\n## API\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nPrepares a piece of HTML for a specific path and identifier.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The value for `~PATH~` and `CLASS`. Use `null` to skip these replacements. |\n| `id` | `String` | yes |  | The value for `~ID~`. Use `null` to skip this replacement. |\n| `text` | `String` | yes |  | The text to prepare. |\n\nReturns: `String` The prepared text.\n\nThe method translates `@(text)` markup, applies `--name--` variables and replaces `~CDN~` with [DEF.cdn](../def/). When `path` is set, `~PATH~` and `CLASS` become the path, `<ui-plugin>` elements without a `path` attribute receive it, and the first `PLUGIN(function(` becomes `PLUGIN('path', function(`. When `id` is set, `~ID~` becomes the identifier. A `text` that is empty or is not a string is returned unchanged.\n\nExample: Replace the keywords\n```js\nvar html = '<div class=\"CLASS\" data-id=\"~ID~\">~PATH~</div>';\nconsole.log(ADAPT('users', 'u1', html)); // <div class=\"users\" data-id=\"u1\">users</div>\n```\n\n### AJAX(url, [data], callback, [onprogress], [scope], [id])\n\nType: `method`\n\nSends an HTTP request and delivers the response to a function or a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The method, the address and optional keywords, for example `POST /api/users/ ERROR`. |\n| `data` | `Object` | no |  | The request body: an object sent as JSON, a string sent as form data, or `FormData`. |\n| `callback` | `Function|String` | yes |  | A function that receives the response, or a path that receives it. |\n| `onprogress` | `Function|String` | no |  | A function or a path that receives the upload percentage. |\n| `scope` | `Object` | no | `window` | The object in which a `callback` path is resolved. |\n| `id` | `String` | no | `url` | The key used by `SYNC` and by the cache. |\n\nThe `url` starts with the HTTP method, followed by the address and optional keywords separated by spaces:\n\n| Keyword | Meaning |\n| --- | --- |\n| `ERROR` | Passes the response through [ERROR()](../globals/). If it holds an error, the `ERROR` event is emitted and `callback` does not run. An error status without a response body emits the `ERROR` event with the status code. |\n| `SYNC` | Queues requests with the same `id`, so that they run one after another. |\n| `<1 minute>` | Caches the response for the given time with [CACHE()](../globals/), unless it is an error. While the request is pending, other calls with the same `id` wait for its response, so only one request is sent. |\n| `#name` | Loads the code list `name` first. See [CL()](../globals/). |\n| `@flag` | Emits the flag when the request is sent. See [Flags and path modifiers](../../guides/flags/). |\n\nAn object in `data` is sent as JSON, a string is sent as it is with the content type `application/x-www-form-urlencoded`, and `FormData` is sent as a form.\n\nA status code of 400 or higher counts as an error. A request that cannot reach the server, is aborted or runs out of time has the status code `0`, and `callback` receives an empty response. A response with a JSON content type is parsed with [PARSE()](../globals/). Every request adds the headers from [DEF.headers](../def/). When [DEF.language](../def/) is set, it is added to the query string. When [DEF.version](../def/) is set, it is added to the query string of `.html` addresses.\n\nThe `request` and `response` [events](../events/) let you inspect or change each call. Once the request is sent, `options.xhr` in the `request` event holds its `XMLHttpRequest`, so `options.xhr.abort()` stops it. `UPLOAD()` is the same function under another name.\n\nExample: Read a response\n```js\nAJAX('GET /api/users/', function(response) {\n\tconsole.log(response.length); // 2\n});\n```\n\nExample: Store a response in a path\n```js\nAJAX('POST /api/orders/', { amount: 10 }, 'orders.last');\n\nWATCH('orders.last', function(value) {\n\tconsole.log(value.id); // 100\n});\n```\n\nExample: Send form data\n```js\nAJAX('POST /api/login/', 'name=Ann&remember=1', function(response) {\n\tconsole.log(response.ok); // true\n});\n```\n\nExample: Stop a request\n```js\nvar request;\n\nON('request', options => request = options);\nON('ERROR', status => console.log('failed', status)); // failed 0\n\nAJAX('GET /api/report/ ERROR', NOOP);\nrequest.xhr.abort();\n```\n\n### API(url, name, [data], callback, [scope])\n\nType: `method`\n\nCalls a Total.js API endpoint on a specific address.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The address of the endpoint. |\n| `name` | `String` | yes |  | The name of the operation, optionally followed by keywords. |\n| `data` | `Object` | no |  | The data of the operation. |\n| `callback` | `Function|String` | yes |  | A function or a path that receives the response. |\n| `scope` | `Object` | no | `window` | The object in which a `callback` path is resolved. |\n\nThe method sends `POST url` with the JSON body `{ schema: name, data: data }`. Keywords accepted by [AJAX()](../globals/) can follow the name, for example `users_list ERROR`. To use one fixed address, see [TAPI()](../globals/) and [PIPE()](../globals/).\n\nExample: Call an operation\n```js\nAPI('/admin/api/', 'users_read', { id: 5 }, function(response) {\n\tconsole.log(response.name); // Peter\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nSets the colour scheme of the page through CSS variables and body classes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | The switches and the CSS variables. |\n\nEvery key becomes a CSS variable on `:root`, except the four switches below. The `color` key also updates [DEF.color](../def/) and adds the variable `--rgb` with the red, green and blue values of a hexadecimal colour with three or six digits.\n\n| Key | Meaning |\n| --- | --- |\n| `dark` or `darkmode` | Toggles the class `ui-dark` on the body. |\n| `large` or `largemode` | Toggles the class `ui-large` on the body. |\n\nThe class prefix comes from [DEF.prefixcsslibrary](../def/).\n\nExample: Dark theme with an accent colour\n```js\nAPPEARANCE({ dark: true, color: '#4285F4' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#4285F4;--rgb:66,133,244}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\nExample: A short colour\n```js\nAPPEARANCE({ color: '#abc' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#abc;--rgb:170,187,204}\n```\n\n### ASETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nCreates a function that calls a component method later.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The selector and the method, in the same form as in `SETTER()`. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nReturns: `Function` A function without arguments.\n\nEach call of the returned function runs [SETTER()](../globals/) with the arguments given here.\n\nExample: Prepare a call\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log('added', value); // added 5\n\t};\n});\n\nON('ready', function() {\n\tvar add = ASETTER('counter/add', 5);\n\tadd();\n});\n</script>\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nReads a `data-*` attribute from an element or from its closest parent that has it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Event|Element|Object` | yes |  | The starting point. |\n| `name` | `String` | no | `id` | The attribute name without the `data-` prefix. |\n\nReturns: `String` The value of the attribute.\n\nThe `element` can be a jQuery object, a jQuery event (its `currentTarget` is used) or a DOM element. For a plain object, the method returns the property `name`. Any other value is returned as it is.\n\nExample: Read the closest identifier\n```html\n<div data-id=\"15\" data-type=\"user\"><button id=\"save\">Save</button></div>\n\n<script>\nvar button = $('#save');\nconsole.log(ATTRD(button)); // 15\nconsole.log(ATTRD(button, 'type')); // user\nconsole.log(ATTRD({ id: 20 })); // 20\n</script>\n```\n\n### BLOCKED(key, timeout, [callback])\n\nType: `method`\n\nLimits how often an operation can run.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The name of the operation. |\n| `timeout` | `Number|String` | yes |  | The time in milliseconds, or a text such as `5 minutes`. |\n| `callback` | `Function` | no |  | A function that runs when the operation is not blocked. |\n\nReturns: `Boolean` `true` when the operation is blocked.\n\nThe first call blocks `key` for the given time and returns `false`. Further calls return `true` until the time passes. A block of 10 seconds or longer is kept in `localStorage`, so it survives a page reload.\n\nExample: Allow one click per second\n```js\nON('ready', function() {\n\tconsole.log(BLOCKED('save', 1000)); // false\n\tconsole.log(BLOCKED('save', 1000)); // true\n});\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nReads or writes a value in the persistent cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The key. |\n| `value` | `Object` | no |  | The value to store. |\n| `expire` | `String` | no |  | The lifetime of the value, or `session`. |\n\nReturns: `Object` The stored value when reading, otherwise nothing.\n\nWith `expire`, the method stores the value. Without it, the method returns the stored value, or `null` when the value is missing or has expired. The value `session` keeps the data in memory until the page is closed. Any other value is a time such as `10 minutes`, `2 hours`, `1 day`, `1 week`, `1 month` or `1 year`, and the data is saved through [DEF.onstoragesave](../def/).\n\nThe cache is loaded when the library starts, so use it from the `ready` [event](../events/) onward.\n\nExample: Write and read\n```js\nON('ready', function() {\n\tCACHE('filter', { page: 2 }, '1 day');\n\tconsole.log(CACHE('filter')); // {\"page\":2}\n\tconsole.log(CACHE('missing')); // null\n});\n```\n\n### CACHEPATH(path, expire, [def])\n\nType: `method`\n\nKeeps the value of a path in the cache between visits.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `expire` | `String` | yes |  | The lifetime of the saved value, for example `1 day`. |\n| `def` | `Object|Function` | no |  | The value used when nothing is saved. A function is called to get it. |\n\nThe method saves every change of the path with [CACHE()](../globals/) for the time in `expire`. When the path is empty, the saved value is written to it, and when nothing is saved, `def` is written. A path that already holds a value keeps it.\n\nCalled before the library has loaded the cache, the method waits for it and then restores the value. Plugins have the same method with a relative path: [plugin.cachepath()](../plugin/).\n\nExample: Remember a filter\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n\nSET('filter.q', 'lamp');\n// After a reload of the page, GET('filter.q') returns lamp\n```\n\n### CL(name, [callback])\n\nType: `method`\n\nLoads code lists registered with `CLINIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | One name, or several names separated by commas. |\n| `callback` | `Function` | no |  | A function that runs when the lists are loaded. |\n\nA code list is shared data, such as a list of countries, stored in [DEF.cl](../def/). A list is loaded once. The `callback` runs when all the lists are available. A name that is not registered yet is checked again every 500 milliseconds until it appears.\n\nExample: Load a list on demand\n```js\nCLINIT('countries', function(next) {\n\tnext([{ id: 'SK', name: 'Slovakia' }]);\n});\n\nON('ready', function() {\n\tCL('countries', function() {\n\t\tconsole.log(DEF.cl.countries.length); // 1\n\t});\n});\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nCancels a timer created with `setTimeout2()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the timer. |\n\nReturns: `Boolean` `true` when the timer exists.\n\nExample: Cancel a timer\n```js\nsetTimeout2('search', NOOP, 1000);\nconsole.log(clearTimeout2('search')); // true\nconsole.log(clearTimeout2('unknown')); // false\n```\n\n### CLINIT(name, source, [init])\n\nType: `method`\n\nRegisters the source of a code list.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the code list. |\n| `source` | `Function|String` | yes |  | A function, a request or an operation. |\n| `init` | `Boolean` | no | `false` | Loads the list immediately. |\n\nWhen `source` is a function, it receives `next(value, [extend])`. Pass the list to `next()`. With `extend` set to `true`, `value` is an object whose keys are stored as separate code lists.\n\nWhen `source` is a string, a value that starts with an HTTP method is loaded with [AJAX()](../globals/). Any other value is an operation for [TAPI()](../globals/).\n\nExample: Load several lists at once\n```js\nCLINIT('all', function(next) {\n\tnext({ colors: ['red'], sizes: ['XL'] }, true);\n}, true);\n\nON('ready', function() {\n\tsetTimeout(function() {\n\t\tconsole.log(DEF.cl.colors, DEF.cl.sizes); // [\"red\"] [\"XL\"]\n\t}, 100);\n});\n```\n\n### CLONE(value, [raw])\n\nType: `method`\n\nCreates a deep copy of a value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|String` | yes |  | The value to copy, or a path. |\n| `raw` | `Boolean` | no | `false` | Treats a string as a plain value. |\n\nReturns: `Object` The copy.\n\nA string is treated as a path to an object or an array, and the value found there is copied. With `raw` set to `true`, a string is returned as it is. Objects are copied through JSON, and dates inside them stay dates.\n\nExample: Copy an object\n```js\nvar a = { user: { name: 'Peter' } };\nvar b = CLONE(a);\nb.user.name = 'Lucia';\nconsole.log(a.user.name); // Peter\n```\n\nExample: Copy the value of a path\n```js\nSET('form', { name: 'Peter' });\nvar copy = CLONE('form');\nconsole.log(copy); // {\"name\":\"Peter\"}\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nLoads code lists again from their sources.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | One name, or several names separated by commas. |\n| `callback` | `Function` | no |  | A function that runs when the lists are reloaded. |\n\nOnly lists that are already loaded are reloaded. Other names are skipped.\n\nExample: Refresh a list\n```js\nvar counter = 0;\n\nCLINIT('stats', function(next) {\n\tnext([++counter]);\n});\n\nON('ready', function() {\n\tCL('stats', function() {\n\t\tCLRELOAD('stats', function() {\n\t\t\tconsole.log(DEF.cl.stats); // [2]\n\t\t});\n\t});\n});\n```\n\n### CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuns a command on every component that registers it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The command, optionally followed by flags. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nComponents register commands with [command()](../component/). Flags can follow the name after a space, for example `CMD('refresh @saved')`: they are emitted first, as with [SET()](../globals/). To run a command only in a part of the page, use [$(selector).CMD()](../jquery/) or [plugin.cmd()](../plugin/).\n\nExample: Clear every list\n```html\n<ui-component name=\"list\"></ui-component>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nvar count = 0;\n\nCOMPONENT('list', function(self) {\n\tself.command('clear', value => count += value);\n});\n\nON('ready', function() {\n\tCMD('clear', 1);\n\tconsole.log(count); // 2\n});\n</script>\n```\n\n### COMPONENT(name, [config], callback, [dependencies], [css])\n\nType: `method`\n\nRegisters a component declaration.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the component. |\n| `config` | `String` | no |  | The default configuration in the form `key:value;key:value`. |\n| `callback` | `Function` | yes |  | The declaration: `function(self, config, cls)`. |\n| `dependencies` | `String|Array` | no |  | Addresses to import first, separated by commas. An array can also contain functions that receive `next`. |\n| `css` | `String` | no |  | The styles of the component. |\n\nThe `callback` runs once for every instance, and receives the instance, its configuration and its CSS class. In the `css` argument, the word `CLASS` becomes `ui-` followed by the component name. See [Creating components](../../guides/creating-components/) and the [Component](../component/) object.\n\nExample: Declare a component\n```html\n<ui-component name=\"hello\"></ui-component>\n\n<script>\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.element.aclass(cls).html('Hello ' + config.name);\n\t\tconsole.log(self.element.html()); // Hello World\n\t};\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nReturns the components bound to a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with flags. |\n\nReturns: `Array` The matching [component](../component/) instances.\n\nThe path includes everything below it, so `form` also returns a component bound to `form.name`. Flags in the path narrow the result: `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` and `@enabled`.\n\nExample: Find the required fields\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.setter = NOOP;\n});\n\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tconsole.log(COMPONENTS('form @required').length); // 1\n});\n</script>\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nChanges the configuration of existing and future components.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | The components to configure. |\n| `config` | `String|Object` | yes |  | The configuration, as an object or in the form `key:value;key:value`. |\n\nThe `selector` can be:\n\n| Selector | Matches |\n| --- | --- |\n| `name` | Components with this name. |\n| `#id` | The component with this identifier. |\n| `.path` | Components whose path contains `path`. |\n| `*` | All components. |\n| `a, b` | Several selectors separated by commas. |\n| `function(instance)` | Components for which the function returns `true`. |\n\nExample: Configure by name\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tCONFIG('box', 'color:red;size:10');\n\tconsole.log(FIND('box').config.size); // 10\n});\n</script>\n```\n\n### COOKIES\n\nType: `property`\n\nReads and writes browser cookies.\n\nReturns: `Object` The object with the methods.\n\nThe object has three methods:\n\n| Method | Description |\n| --- | --- |\n| `COOKIES.get(name)` | Returns the value, or an empty string. |\n| `COOKIES.set(name, value, [expire], [samesite])` | Writes a cookie for the path `/`. `expire` is a number of days, a `Date` or a text such as `1 day`. Without `expire`, the cookie is kept until the browser is closed. `samesite` is for example `lax`. |\n| `COOKIES.rem(name)` | Removes the cookie. |\n\nExample: Write and read a cookie\n```js\nCOOKIES.set('theme', 'dark', '1 month', 'lax');\nconsole.log(COOKIES.get('theme')); // dark\n```\n\nExample: Keep a cookie for a week\n```js\nCOOKIES.set('token', 'a=1', 7);\nconsole.log(COOKIES.get('token')); // a=1\n```\n\n### COPY(source, target)\n\nType: `method`\n\nCopies the properties of one object to another.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | The object to read from. |\n| `target` | `Object` | yes |  | The object to write to. |\n\nReturns: `Object` The `target` object.\n\nNested objects are cloned, so later changes in `source` do not affect `target`.\n\nExample: Merge two objects\n```js\nvar target = { a: 1 };\nCOPY({ b: { c: 2 } }, target);\nconsole.log(target); // {\"a\":1,\"b\":{\"c\":2}}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nAnother name for `STYLE()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | The CSS. |\n| `id` | `String` | no |  | The identifier of the style element. |\n| `selector` | `String` | no |  | A selector that prefixes every rule. |\n\nSee [STYLE()](../globals/). Setting `window.jc_globals = { CSS: false }` ahead of the library script leaves this global undefined.\n\n### DAYS\n\nType: `property`\n\nThe English names of the days of the week, starting with Sunday.\n\nReturns: `Array` Seven strings.\n\nExample: Read a day\n```js\nconsole.log(DAYS[1]); // Monday\n```\n\n### DEF\n\nType: `property`\n\nThe default settings of the library.\n\nReturns: `Object` The settings.\n\nDescribed on its own page: [DEF](../def/).\n\n### DECRYPT(text, [key], [type])\n\nType: `method`\n\nReads a value written by `ENCRYPT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | The text from `ENCRYPT()`. |\n| `key` | `String` | no |  | The key. |\n| `type` | `String` | no |  | The prefix of the text. |\n\nReturns: `Object` The value, or `undefined`.\n\nThe `key` and the `type` must be the ones given to [ENCRYPT()](../globals/). The method returns `undefined` when the checksum does not match them, which is the case for a changed text. A value that starts with `[`, `{` or `\"` is parsed as JSON.\n\nExample: Read an object back\n```js\nvar text = ENCRYPT({ id: 5 }, 'secret', 'U');\n\nconsole.log(text.charAt(0)); // U\nconsole.log(DECRYPT(text, 'secret', 'U')); // {\"id\":5}\nconsole.log(DECRYPT(text, 'secret')); // undefined\n```\n\n### DIFFDOM(element, selector, html, [attribute])\n\nType: `method`\n\nUpdates the children of an element so that they match new HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | The parent element. |\n| `selector` | `String` | yes |  | A selector of the compared children. |\n| `html` | `String` | yes |  | The new content. |\n| `attribute` | `String` | no |  | The attribute used for the comparison. |\n\nReturns: `Object` The number of added, kept and removed elements: `{ add, upd, rem }`.\n\nChildren that have not changed stay in the DOM, so they keep their state. Children are compared by their whole HTML, or by the value of `attribute` when it is set.\n\nExample: Update a list\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n\n<script>\nvar list = $('#list');\nvar result = DIFFDOM(list, 'li', '<li>A</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log(list.html()); // <li>A</li><li>C</li>\n</script>\n```\n\n### EMIT(name, [a], [b], [c], [d])\n\nType: `method`\n\nEmits an event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nHandlers registered with [ON()](../globals/), and handlers registered on [components](../component/) and [plugins](../plugin/), receive the arguments. Flags can follow the name, for example `refresh @loading`. The events of the library are listed in [Events](../events/).\n\nExample: Emit a custom event\n```js\nON('saved', function(id, name) {\n\tconsole.log(id, name); // 5 Peter\n});\n\nEMIT('saved', 5, 'Peter');\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nA frozen empty array.\n\nReturns: `Array` An array that cannot be changed.\n\nExample: A shared default value\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nA frozen empty object.\n\nReturns: `Object` An object that cannot be changed.\n\nExample: A shared default value\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nEncodes a value as text with a checksum.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | The value. |\n| `key` | `String` | no |  | The key of the checksum. |\n| `type` | `String` | no |  | A prefix written at the beginning of the text. |\n\nReturns: `String` The encoded text.\n\nAn object or an array is serialized with [STRINGIFY()](../globals/) first. The result has the `type` as a prefix, the value in hexadecimal digits, the letter `x` and a checksum made with [HASH()](../globals/) from the value, the `key` and the `type`.\n\nThe value can be read back by anyone, so do not use the method to hide data: the key only lets [DECRYPT()](../globals/) find out whether the text was changed.\n\nExample: Encode and decode\n```js\nvar text = ENCRYPT('hello', 'secret');\n\nconsole.log(text); // 68656c6c6fxds46dr\nconsole.log(DECRYPT(text, 'secret')); // hello\nconsole.log(DECRYPT(text, 'other')); // undefined\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nReads or writes environment variables.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | The name, or an object with names and values. |\n| `value` | `Object` | no |  | The value to write. |\n\nReturns: `Object` The value of the variable.\n\nVariables are stored in [DEF.env](../def/). A text can refer to them as `[name]`: paths, addresses and configuration values replace this notation with the value. Pass an object to write several variables. Every write emits the `env` [event](../events/).\n\nExample: Use a variable in a text\n```js\nENV('api', '/api/v1/');\nconsole.log(ENV('api')); // /api/v1/\nconsole.log('[api]users/'.env()); // /api/v1/users/\n```\n\n### ENVIRONMENT(name, [version], [language], [env])\n\nType: `method`\n\nSets the storage key, version, language and environment variables of the app.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The key used in `localStorage`. |\n| `version` | `String` | no |  | The version of the app. |\n| `language` | `String` | no |  | The language of the app. |\n| `env` | `Object` | no |  | Environment variables. |\n\nThe method assigns [DEF.localstorage](../def/), [DEF.version](../def/) and [DEF.language](../def/), and passes `env` to [ENV()](../globals/). Call it directly after the library script, so that the app reads its own storage.\n\nExample: Configure an app\n```js\nENVIRONMENT('myapp', '1.0', 'en', { title: 'My app' });\n\nconsole.log(DEF.localstorage, DEF.version, DEF.language); // myapp 1.0 en\nconsole.log(ENV('title')); // My app\n```\n\n### ERROR(response, [success], [error])\n\nType: `method`\n\nChecks a response for errors and runs the matching handler.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | The response to check. |\n| `success` | `Function|String` | no |  | Runs when there is no error. |\n| `error` | `Function|String` | no |  | Runs when there is an error. |\n\nReturns: `Boolean` `true` when the response holds an error.\n\nA response is an error when it is an `Error` object, has an `error` property, or is an array whose first item has one. An error emits the `ERROR` [event](../events/).\n\n`success` and `error` can be functions, or names for [SEEX()](../globals/).\n\nCall `ERROR(success, [error])` without a response to create a function that you can pass as a callback.\n\nExample: Check a response\n```js\nconsole.log(ERROR({ id: 1 })); // false\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\n```\n\nExample: Create a callback\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 1\n});\n\ncallback({ id: 1 });\n```\n\n### ERRORS(path, callback)\n\nType: `method`\n\nReturns the invalid components of a path or of an element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|jQuery` | yes |  | A path, or an element that contains the components. |\n| `callback` | `Function` | yes |  | A function that receives an array of [components](../component/). |\n\nExample: Validate a form\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.validate = function(value) {\n\t\treturn !!value;\n\t};\n});\n\nON('ready', function() {\n\tERRORS('form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a function by its name.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The target of the call. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nThe form of `name` decides what is called:\n\n| Name | Calls |\n| --- | --- |\n| `name` | A global function. |\n| `FUNC.name` | A function found at a path. |\n| `plugin/method` | A method of a [plugin](../plugin/). |\n| `*/method` | A method of the common plugin. |\n| `-component/method` | A component method, through [SETTER()](../globals/). |\n| `#event` | An event, through [EMIT()](../globals/). |\n\nAdd the flag `@important` to retry every 500 milliseconds until the function exists, for example `EXEC('app/refresh @important')`. `EXE()` is the same function under another name.\n\nExample: Call a function by path\n```js\nFUNC.sum = function(a, b) {\n\tconsole.log(a + b); // 5\n};\n\nEXEC('FUNC.sum', 2, 3);\n```\n\nExample: Wait for a function\n```js\nEXEC('app.start @important', 'now');\n\nsetTimeout(function() {\n\twindow.app = {};\n\tapp.start = function(value) {\n\t\tconsole.log(value); // now\n\t};\n}, 100);\n```\n\n### EXTENSION(name, [config], callback)\n\nType: `method`\n\nExtends a component or a plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The component name, or `@` followed by the plugin name. |\n| `config` | `String|Object` | no |  | Configuration added to each instance. |\n| `callback` | `Function` | yes |  | A function `(instance, config, cls)`, where `cls` is the CSS class of the instance. `this` is the instance. |\n\nThe `callback` runs for every existing instance and for every new one, right after the declaration, always with the same arguments. For a plugin, write `@` in front of its name.\n\nExample: Add a method to a component\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nEXTENSION('box', 'color:red', function(self, config) {\n\tself.describe = function() {\n\t\treturn config.color;\n\t};\n});\n\nON('ready', function() {\n\tconsole.log(FIND('box').describe()); // red\n});\n</script>\n```\n\n### FIND(selector, [all])\n\nType: `method`\n\nFinds a component that is ready.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | The name, the identifier or the path. |\n| `all` | `Boolean` | no | `false` | Returns all the matches in an array. |\n\nReturns: `Component|Array` The first [component](../component/), or an array when `all` is `true`.\n\nThe `selector` is a component name, `#id` for an identifier, or `.path` for a path.\n\nExample: Find by name and by path\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('field').name); // field\n\tconsole.log(FIND('.form.name').path.path); // form.name\n\tconsole.log(FIND('field', true).length); // 1\n});\n</script>\n```\n\n### FLAGS(flags, [callback])\n\nType: `method`\n\nEmits flags and then runs a function.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | The flags, for example `@loading @save`. |\n| `callback` | `Function` | no |  | A function that runs afterwards. |\n\nEach flag emits the event `@flag name`, which you can capture with [ON()](../globals/). See [Flags and path modifiers](../../guides/flags/).\n\nExample: Capture a flag\n```js\nON('@flag loading', function() {\n\tconsole.log('flag captured'); // flag captured\n});\n\nFLAGS('@loading', function() {\n\tconsole.log('done'); // done\n});\n```\n\n### FN(code)\n\nType: `method`\n\nCompiles an arrow function from a string.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | yes |  | The code of the function. |\n\nReturns: `Function` The compiled function.\n\nThe code can have up to four arguments. Code without an arrow becomes a function with the argument `value`. Compiled functions are cached.\n\nExample: Compile functions\n```js\nconsole.log(FN('n => n * 2')(4)); // 8\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value + 1')(1)); // 2\n```\n\n### FREE()\n\nType: `method`\n\nRemoves components, bindings and plugins whose elements have left the DOM.\n\nThe library runs this cleanup every minute. Call it when you need the instances to be removed right away.\n\nExample: Remove a detached component\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\t$('ui-component').remove();\n\tFREE();\n\tconsole.log(COMPONENTS('form').length); // 0\n});\n</script>\n```\n\n### FUNC\n\nType: `property`\n\nAn empty object for the functions of your app.\n\nReturns: `Object` The container.\n\nFunctions stored here can be called by path with [EXEC()](../globals/).\n\nExample: Store a function\n```js\nFUNC.hello = function() {\n\treturn 'Hello';\n};\n\nconsole.log(FUNC.hello()); // Hello\n```\n\n### GET(path, [noflags])\n\nType: `method`\n\nReads the value of a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with flags. |\n| `noflags` | `Boolean` | no | `false` | Reads the value without applying the flags. |\n\nReturns: `Object` The value.\n\nWhen the path contains flags, they are applied to the components of the path: `GET('form @reset')` returns the value and resets their state. See [Paths](../../guides/paths/).\n\nExample: Read values\n```js\nSET('user.name', 'Peter');\n\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\n### GUID([length])\n\nType: `method`\n\nGenerates a random identifier.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | no |  | The length of the identifier. |\n\nReturns: `String` The identifier.\n\nWithout `length`, the result has the 36-character form of a UUID. With `length`, it is a string of lowercase letters and digits.\n\nExample: Generate identifiers\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value)\n\nType: `method`\n\nCreates a numeric hash of a value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Number|Boolean|Object|Date` | yes |  | The value. |\n\nReturns: `Number` The hash.\n\nA number is returned as it is, `true` gives `1`, a date gives its time in milliseconds, and an empty value gives `0`. Objects are serialized first.\n\nExample: Hash a string\n```js\nconsole.log(HASH('hello')); // 99162322\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nChecks whether an element nested in the page is hidden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | An element placed inside another element of the body. |\n\nReturns: `Boolean` `true` when the element is hidden.\n\nThe element counts as hidden when it has no offset parent, which is the case for `display:none`. A missing element also counts as hidden. To check the position in the viewport, use [VISIBLE()](../globals/).\n\nExample: Check an element\n```html\n<main><div id=\"a\" style=\"display:none\"></div><div id=\"b\"></div></main>\n\n<script>\nconsole.log(HIDDEN($('#a'))); // true\nconsole.log(HIDDEN($('#b'))); // false\n</script>\n```\n\n### IMPORT(url, [target], [callback], [prepare])\n\nType: `method`\n\nLoads a script, a stylesheet or a piece of HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The address and optional keywords. |\n| `target` | `String|jQuery|Element` | no | `body` | The element that receives HTML content. |\n| `callback` | `Function` | no |  | A function that runs when the content is loaded. |\n| `prepare` | `Function` | no |  | A function that receives the HTML and returns the text to insert. |\n\nAddresses ending with `.js` or `.css` are added to the page head. Any other address is downloaded and inserted into `target`. Keywords can be combined with the address:\n\n| Keyword | Meaning |\n| --- | --- |\n| `<name>` | Skips the import when the global variable `name` exists. |\n| `.js`, `.css`, `.html` | Sets the type of the content when the address does not show it. |\n| `@singleton` | Imports the address only once. |\n| `@prepend` | Inserts the content at the beginning of `target`. |\n\nWhen a script or a stylesheet cannot be loaded, the library writes a warning to the console and `callback` still runs.\n\nSee [Importing content](../../guides/importing/).\n\nExample: Insert a piece of HTML\n```html\n<div id=\"menu\"></div>\n\n<script>\nIMPORT('/parts/menu.html', '#menu', function() {\n\tconsole.log($('#menu').html()); // <b>Menu</b>\n});\n</script>\n```\n\nExample: Skip a library that exists\n```js\nIMPORT('<jQuery> /js/jquery.min.js', function() {\n\tconsole.log('jQuery is available'); // jQuery is available\n});\n```\n\n### INC(path, [value])\n\nType: `method`\n\nIncreases the number stored in a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `value` | `Number` | no | `1` | The amount to add. |\n\nAn empty path starts at `0`. A string is converted to a number. Use a negative `value` to decrease the number.\n\nExample: Increase a counter\n```js\nSET('stats.visits', 10);\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 16\n```\n\n### inDOM(element)\n\nType: `method`\n\nChecks whether an element is attached to the document body.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | A DOM element. |\n\nReturns: `Boolean` `true` when the element is attached, otherwise nothing.\n\nExample: Check an element\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(!!inDOM(document.createElement('div'))); // false\n```\n\n### isIE\n\nType: `property`\n\nTells whether the browser is Internet Explorer.\n\nReturns: `Boolean` The result of the detection.\n\n### isMOBILE\n\nType: `property`\n\nTells whether the user agent belongs to a mobile device.\n\nReturns: `Boolean` The result of the detection.\n\n### isPRIVATEMODE\n\nType: `property`\n\nTells whether `localStorage` is unavailable, as in some private windows. The value is set while the library starts, so read it from the `ready` event onward.\n\nReturns: `Boolean` The result of the detection.\n\n### isROBOT\n\nType: `property`\n\nTells whether the user agent belongs to a search engine or a crawler.\n\nReturns: `Boolean` The result of the detection.\n\n### isSTANDALONE\n\nType: `property`\n\nTells whether the page runs as an installed web app.\n\nReturns: `Boolean` The result of the detection.\n\n### isTOUCH\n\nType: `property`\n\nTells whether the device supports touch input.\n\nReturns: `Boolean` The result of the detection.\n\n### jComponent\n\nType: `property`\n\nThe main object of the library.\n\nReturns: `Object` The main object.\n\nThe same object as [MAIN](../main/).\n\n### LOCALIZE(text)\n\nType: `method`\n\nLoads translations into the dictionary.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | The lines with translations. |\n\nEach line has the form `key : translation`, and lines starting with `//` are skipped. The key is the hash of the original text, in base 36, with the prefix `T`. The translations are stored in [DEF.dictionary](../def/) and used by [TRANSLATE()](../globals/). See [Localization](../../guides/localization/).\n\nExample: Load a translation\n```js\nvar key = 'T' + HASH('Hello').toString(36);\n\nLOCALIZE(key + ' : Hola');\nconsole.log(TRANSLATE('@(Hello)')); // Hola\n```\n\n### M\n\nType: `property`\n\nA short name of the main object.\n\nReturns: `Object` The main object.\n\nThe same object as [MAIN](../main/).\n\n### MAIN\n\nType: `property`\n\nThe main object of the library.\n\nReturns: `Object` The main object.\n\nDescribed on its own page: [MAIN](../main/).\n\n### MONTHS\n\nType: `property`\n\nThe English names of the months, starting with January.\n\nReturns: `Array` Twelve strings.\n\nExample: Read a month\n```js\nconsole.log(MONTHS[0]); // January\n```\n\n### NEWUIBIND(element, [path], [config])\n\nType: `method`\n\nCreates a data binding on an element from code.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | The element. |\n| `path` | `String` | no |  | The path to observe. |\n| `config` | `String` | no |  | The binding commands. |\n\nThe binding works like the [ui-bind](../ui-bind/) element. Without `path` and `config`, the values are read from the attributes of the element.\n\nExample: Bind an element to a path\n```html\n<div id=\"name\"></div>\n\n<script>\nSET('user.name', 'Peter');\nNEWUIBIND($('#name'), 'user.name', 'text:value');\n\nsetTimeout(function() {\n\tconsole.log($('#name').html()); // Peter\n}, 200);\n</script>\n```\n\n### NODEINDEXOF(element)\n\nType: `method`\n\nReturns the position of an element among its siblings.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | The element. |\n\nReturns: `Number` The zero-based position.\n\nExample: Read a position\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li></ul>\n\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, reference, [before])\n\nType: `method`\n\nInserts an element next to another element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | The element to insert. |\n| `reference` | `jQuery|Element` | yes |  | The reference element. |\n| `before` | `Boolean` | no | `false` | Inserts the element in front of the reference. |\n\nExample: Move an element\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEINSERT($('#c'), $('#a'), true);\nconsole.log($('ul').text()); // CAB\n</script>\n```\n\n### NODEMOVE(element, [up])\n\nType: `method`\n\nMoves an element one position among its siblings.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | The element. |\n| `up` | `Boolean` | no | `false` | Moves the element towards the start. Otherwise it moves towards the end. |\n\nExample: Reorder a list\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BAC\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nA function that does nothing.\n\nUse it as a default callback.\n\nExample: A default callback\n```js\nvar callback = NOOP;\nconsole.log(typeof(callback)); // function\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nChecks whether the page is in the background.\n\nReturns: `Boolean` `true` when the document is hidden.\n\nExample: Check the page\n```js\nconsole.log(NOTFOCUSED()); // false\n```\n\n### NOW\n\nType: `property`\n\nThe current date, refreshed once a minute.\n\nReturns: `Date` The date.\n\nUse it when a precision of one minute is enough. It avoids creating a new `Date` object for each use.\n\nExample: Read the date\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path)\n\nType: `method`\n\nSets a path to `null`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\n`NULL()` is the same function under another name.\n\nExample: Clear a value\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### OFF(name, [callback])\n\nType: `method`\n\nRemoves event handlers.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `callback` | `Function` | no |  | The handler to remove. |\n\nWithout `callback`, all the handlers of the event are removed. Several events can be joined with `+`.\n\nExample: Remove a handler\n```js\nvar count = 0;\nvar handler = function() {\n\tcount++;\n};\n\nON('refresh', handler);\nEMIT('refresh');\nOFF('refresh', handler);\nEMIT('refresh');\nconsole.log(count); // 1\n```\n\n### ON(name, callback, [init])\n\nType: `method`\n\nRegisters an event handler.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `callback` | `Function` | yes |  | The handler. It receives the arguments of the event. |\n| `init` | `Boolean` | no | `false` | Also calls the handler once, without arguments. |\n\nSeveral events can be joined with `+`, for example `saved + removed`. A handler for `ready` or `init` runs immediately when the library has started. The events of the library are listed in [Events](../events/).\n\nExample: Capture two events\n```js\nvar count = 0;\n\nON('saved + removed', function() {\n\tcount++;\n});\n\nEMIT('saved');\nEMIT('removed');\nconsole.log(count); // 2\n```\n\n### PARSE(value)\n\nType: `method`\n\nParses JSON and converts date strings to `Date` objects.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | The JSON, a selector or an object. |\n\nReturns: `Object` The parsed value, or `null`.\n\nA value starting with `#` or `.` is a selector: the JSON is read from the content of that element. An object is returned as it is. Invalid JSON returns `null`.\n\nExample: Parse JSON\n```js\nvar data = PARSE('{\"created\":\"2024-05-01T10:00:00.000Z\"}');\nconsole.log(data.created instanceof Date); // true\nconsole.log(PARSE('invalid')); // null\n```\n\n### PIPE(name, [data], callback, [scope])\n\nType: `method`\n\nCalls an operation on the address from `DEF.pipe`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the operation, optionally followed by keywords. |\n| `data` | `Object` | no |  | The data of the operation. |\n| `callback` | `Function|String` | yes |  | A function or a path that receives the response. |\n| `scope` | `Object` | no | `window` | The object in which a `callback` path is resolved. |\n\nIt works like [API()](../globals/), with the address taken from [DEF.pipe](../def/).\n\nExample: Call an operation\n```js\nDEF.pipe = '/pipe/';\n\nPIPE('orders_list', function(response) {\n\tconsole.log(response.length); // 1\n});\n```\n\n### PLUGIN(name, [config], callback, [dependencies])\n\nType: `method`\n\nRegisters a plugin declaration.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the plugin. |\n| `config` | `String` | no |  | The default configuration in the form `key:value;key:value`. |\n| `callback` | `Function` | yes |  | The declaration: `function(self, config)`. |\n| `dependencies` | `String|Array` | no |  | Addresses to import first. |\n\nThe `callback` runs when a [ui-plugin](../ui-plugin/) element with this path is created. The name `*` registers the common plugin. See [Plugins](../../guides/plugins/) and the [Plugin](../plugin/) object.\n\nExample: Declare a plugin\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('Hello ' + name); // Hello Peter\n\t};\n});\n\nON('ready', function() {\n\tEXEC('users/hello', 'Peter');\n});\n</script>\n```\n\n### PLUGINS\n\nType: `property`\n\nThe running plugin instances, by name.\n\nReturns: `Object` The [plugin](../plugin/) instances.\n\nExample: Read a plugin\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('ready', function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n});\n</script>\n```\n\n### PREF\n\nType: `property`\n\nPersistent user preferences.\n\nReturns: `Object` The preferences.\n\nDescribed on its own page: [PREF](../pref/).\n\n### PUSH(path, value)\n\nType: `method`\n\nAdds an item to the array stored in a path and notifies the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path of an existing array. |\n| `value` | `Object` | yes |  | The item. |\n\nWrite `^` in front of the path to add the item at the beginning of the array.\n\nExample: Add items\n```js\nSET('tags', ['b']);\nPUSH('tags', 'c');\nPUSH('^tags', 'a');\nconsole.log(GET('tags')); // [\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], data)\n\nType: `method`\n\nAdds data to an address as a query string.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | The address. |\n| `data` | `Object` | yes |  | The values. |\n\nReturns: `String` The address with the query string.\n\nEmpty values are skipped, dates are converted to ISO strings and arrays are joined with commas. The `url` can start with an HTTP method.\n\nExample: Build addresses\n```js\nconsole.log(QUERIFY('/users/', { page: 2, q: 'a b' })); // /users/?page=2&q=a%20b\nconsole.log(QUERIFY('GET /users/', { page: 2 })); // GET /users/?page=2\nconsole.log(QUERIFY({ page: 2 })); // ?page=2\n```\n\n### REPO\n\nType: `property`\n\nAn empty object for the shared data of your app.\n\nReturns: `Object` The container.\n\nExample: Store a value\n```js\nREPO.title = 'My app';\nconsole.log(REPO.title); // My app\n```\n\n### RESET(path)\n\nType: `method`\n\nResets the state of the components bound to a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nThe `touched` and `modified` states return to their defaults. The value of the path does not change.\n\nExample: Reset a form\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tSET('form.name @change', 'Peter');\n\tconsole.log(FIND('field').config.modified); // 1\n\tRESET('form');\n\tconsole.log(FIND('field').config.modified); // 0\n\tconsole.log(GET('form.name')); // Peter\n});\n</script>\n```\n\n### SCROLLBAR(element, [options])\n\nType: `method`\n\nAdds a custom scrollbar to an element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | The element. |\n| `options` | `Object` | no |  | The options. |\n\nReturns: `Object` The scrollbar.\n\nOptions:\n\n| Option | Type | Description |\n| --- | --- | --- |\n| `native` | Boolean | Keeps the scrollbar of the browser and only sets the overflow. |\n| `orientation` | String | `x` or `y`. By default, both directions are active. |\n| `visibleX`, `visibleY` | Boolean | Keeps the track visible when there is nothing to scroll. |\n| `wrap` | Boolean | `false` uses the existing content as the scroll area. |\n| `controls` | jQuery | The element that receives the scrollbar tracks. |\n| `shadow` | Boolean | Adds shadows on the scrollable edges. |\n| `padding` | Number | The distance of the tracks from the edge. Default `5`. |\n| `minsize` | Number | The minimum size of the bar. Default `50`. |\n| `thickness` | Number | The thickness used when CSS does not define it. Default `10`. |\n| `margin`, `marginX`, `marginY` | Number | Adjust the size of the scroll area. |\n| `offsetX`, `offsetY` | Number | Adjust the measured size of the element. |\n| `floating` | Boolean | `false` reserves space for the bars. |\n| `parent` | String\\|jQuery | The element whose size is used. |\n| `interval` | Number | The time between size checks, in milliseconds. Default `54321`. |\n| `autoresize` | Boolean | `false` stops measuring the element again when the window is resized. Default `true`. |\n| `onscroll`, `onidle`, `onresize` | Function | Handlers that receive the scrollbar. |\n\nThe returned object provides:\n\n| Member | Description |\n| --- | --- |\n| `area` | The scrolling element. |\n| `body` | The element with the content. |\n| `element` | The original element. |\n| `resize()` | Measures the element again. |\n| `scrollTop([value])` | Reads or sets the vertical position. A string such as `'+20'` moves relative to the current position. |\n| `scrollLeft([value])` | Reads or sets the horizontal position, with the same rules. |\n| `scrollBottom(offset)` | Scrolls to the bottom, minus `offset`. |\n| `scrollRight(offset)` | Scrolls to the right edge, minus `offset`. |\n| `scroll(x, y)` | Scrolls to a position. |\n| `sync(element, [direction])` | Synchronizes scrolling with another element. `direction` is `x` or `y`. |\n| `destroy()` | Stops the scrollbar. |\n\nThe `scroll` and `scrollidle` [events](../events/) report scrolling.\n\nExample: Scroll from code\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nvar scrollbar = SCROLLBAR($('#panel'));\n\nscrollbar.area.css('overflow', 'auto');\nscrollbar.resize(false, true);\nscrollbar.scrollTop(30);\nconsole.log(scrollbar.scrollTop()); // 30\nscrollbar.scrollTop('+20');\nconsole.log(scrollbar.scrollTop()); // 50\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nReturns the width of the scrollbar of the browser.\n\nReturns: `Number` The width in pixels.\n\nExample: Read the width\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a function or writes a value, depending on the name.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The target. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nThe form `plugin/method` calls a plugin method, and the name of a global function calls that function. Any other name is a path, and `a` is written to it with [SET()](../globals/).\n\nExample: Write to a path\n```js\nSEEX('form.name', 'Peter');\nconsole.log(GET('form.name')); // Peter\n```\n\nExample: Call a global function\n```js\nwindow.notify = function(text) {\n\tconsole.log(text); // Saved\n};\n\nSEEX('notify', 'Saved');\n```\n\n### SET(path, value)\n\nType: `method`\n\nWrites a value to a path and notifies everything that observes it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with flags. |\n| `value` | `Object` | yes |  | The value, or a function `(current)` that returns it. |\n\nMissing objects along the path are created. Flags are part of the path, for example `form.name @change`. The form `path[]` appends the value to an array. A function as `value` receives the current value, and its result is written. See [Paths](../../guides/paths/) and [Flags and path modifiers](../../guides/flags/).\n\nExample: Write values\n```js\nSET('user.name', 'Peter');\nSET('user.tags[]', 'admin');\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"tags\":[\"admin\"]}\n```\n\nExample: Write a value from the current one\n```js\nSET('cart.count', 1);\nSET('cart.count', value => value + 1);\nconsole.log(GET('cart.count')); // 2\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a method on the components that match a selector.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The selector and the method. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nThe `name` has the form `selector/method`:\n\n| Selector | Matches |\n| --- | --- |\n| `name` | Components with this name. |\n| `#id` | The component with this identifier. |\n| `*` | All components that have the method. |\n\nThe flag `@important` retries every 500 milliseconds until a matching component with the method exists. A component declared as lazy is created by the first call, unless the name starts with `!`.\n\nExample: Call a component method\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log(value); // 5\n\t};\n});\n\nON('ready', function() {\n\tSETTER('counter/add', 5);\n});\n</script>\n```\n\n### setTimeout2(name, callback, timeout, [limit], [param])\n\nType: `method`\n\nRuns a function after a delay, restarting the delay on each call with the same name.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the timer. |\n| `callback` | `Function` | yes |  | The function. |\n| `timeout` | `Number` | yes |  | The delay in milliseconds. |\n| `limit` | `Number` | no |  | The maximum number of calls in one waiting period. |\n| `param` | `Object` | no |  | The argument of the function. |\n\nReturns: `String` The name of the timer. A call ignored by `limit` returns nothing.\n\nWith `limit`, the delay is restarted at most `limit` times. Further calls are ignored until the function runs, so it cannot be postponed forever.\n\nExample: Run once after the last call\n```js\nvar count = 0;\nvar run = function() {\n\tcount++;\n\tconsole.log(count); // 1\n};\n\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\n```\n\n### STRINGIFY(value, [compress], [fields], [encrypt])\n\nType: `method`\n\nSerializes a value to JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value. |\n| `compress` | `Boolean` | no | `false` | Removes empty values. |\n| `fields` | `Array|Object|Function` | no |  | The keys to keep. |\n| `encrypt` | `Boolean|String` | no |  | `true` encodes the JSON with [ENCRYPT()](../globals/). A string does the same and is the key. |\n\nReturns: `String` The JSON.\n\nWith `compress` set to `true`, strings are trimmed, and empty strings, `false` and `null` are left out. The `fields` argument selects the keys: an array of allowed keys, an object where `false` excludes a key, or a function `(key, value)` that returns `true` for the keys to keep.\n\nExample: Compress and filter\n```js\nvar data = { name: ' Peter ', note: '', age: 30 };\n\nconsole.log(STRINGIFY(data, true)); // {\"name\":\"Peter\",\"age\":30}\nconsole.log(STRINGIFY(data, false, ['age'])); // {\"age\":30}\n```\n\nExample: Encode the JSON\n```js\nvar text = STRINGIFY({ id: 5 }, false, null, 'secret');\nconsole.log(DECRYPT(text, 'secret')); // {\"id\":5}\n```\n\n### STYLE(value, [id], [selector])\n\nType: `method`\n\nAdds CSS to the page.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | The CSS. |\n| `id` | `String` | no |  | The identifier of the style element. |\n| `selector` | `String` | no |  | A selector that prefixes every rule. |\n\nAn element with the same `id` is replaced. The element has the identifier `css` followed by `id`. With `selector`, every rule is prefixed with this selector.\n\nExample: Add scoped styles\n```js\nSTYLE('b { color: red }', 'theme', '.panel');\nconsole.log($('#csstheme').html()); // .panel b{ color: red }\n```\n\n### TAPI(name, [data], callback, [scope])\n\nType: `method`\n\nCalls a Total.js API operation on the address from `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the operation, optionally followed by keywords. |\n| `data` | `Object` | no |  | The data of the operation. |\n| `callback` | `Function|String` | yes |  | A function or a path that receives the response. |\n| `scope` | `Object` | no | `window` | The object in which a `callback` path is resolved. |\n\nIt works like [API()](../globals/), with the address taken from [DEF.api](../def/).\n\nExample: Store a response in a path\n```js\nDEF.api = '/admin/api/';\n\nTAPI('users_list', { page: 1 }, 'users.items');\n\nWATCH('users.items', function(value) {\n\tconsole.log(value.length); // 2\n});\n```\n\n### TEMP\n\nType: `property`\n\nAn object for short-lived data.\n\nReturns: `Object` The container.\n\nThe library replaces it with an empty object every minute.\n\nExample: Store a value\n```js\nTEMP.result = 5;\nconsole.log(TEMP.result); // 5\n```\n\n### TOGGLE(path)\n\nType: `method`\n\nInverts the boolean value of a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nExample: Toggle a value\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### Total\n\nType: `property`\n\nThe main object of the library.\n\nReturns: `Object` The main object.\n\nThe same object as [MAIN](../main/).\n\n### TRANSLATE(text)\n\nType: `method`\n\nReplaces the `@(text)` markup with translations.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | The text with the markup. |\n\nReturns: `String` The translated text.\n\nText without a translation stays in its original language. Translations are loaded with [LOCALIZE()](../globals/).\n\nExample: Translate a text\n```js\nLOCALIZE('T' + HASH('Yes').toString(36) + ' : Ano');\nconsole.log(TRANSLATE('@(Yes) / @(No)')); // Ano / No\n```\n\n### UNAUTHORIZED(...permissions)\n\nType: `method`\n\nChecks the permissions of the signed-in user.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `permissions` | `String` | yes |  | One or more permissions. |\n\nReturns: `Boolean` `true` when access is denied.\n\nThe method reads the global variable `user`. A user with `sa` or `su` set has all the permissions. Otherwise, the permissions come from `user.permissions` or `user.roles`, as an array or an object. The result is `true` when the user has none of the given permissions, or when `user` does not exist.\n\nExample: Check a permission\n```js\nwindow.user = { roles: ['editor'] };\n\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [callback])\n\nType: `method`\n\nRemoves watchers from a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. Several paths can be joined with `+`. |\n| `callback` | `Function` | no |  | The watcher to remove. |\n\nWithout `callback`, all the watchers of the path are removed.\n\nExample: Stop watching\n```js\nvar count = 0;\nvar watcher = function() {\n\tcount++;\n};\n\nWATCH('form.name', watcher);\nSET('form.name', 'A');\nUNWATCH('form.name', watcher);\nSET('form.name', 'B');\nconsole.log(count); // 1\n```\n\n### UPD(path)\n\nType: `method`\n\nNotifies a path after its value was changed directly.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with flags. |\n\n`UPDATE()` is the same function under another name.\n\nExample: Notify after a direct change\n```js\nwindow.form = { name: 'A' };\n\nWATCH('form.name', function(value) {\n\tconsole.log(value); // B\n});\n\nform.name = 'B';\nUPD('form.name');\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nChecks the vertical position of an element relative to the viewport.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | The element. |\n| `threshold` | `Number` | no | `0` | The number of pixels of the element that must be inside the viewport. |\n| `mode` | `String` | no | `visible` | `visible`, `above` or `below`. |\n\nReturns: `Boolean` The result of the check.\n\nThe `mode` selects the check: `visible` tests whether the element is in the viewport, `above` whether it is above it, and `below` whether it is below it. A hidden element returns `false`.\n\nExample: Check an element\n```html\n<div id=\"top\">Top</div>\n<div style=\"height:5000px\"></div>\n<div id=\"far\">Far</div>\n\n<script>\nconsole.log(VISIBLE($('#top'))); // true\nconsole.log(VISIBLE($('#far'))); // false\nconsole.log(VISIBLE($('#far'), 0, 'below')); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nA short name of the `window` object.\n\nReturns: `Object` The `window` object.\n\nExample: Compare the objects\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback)\n\nType: `method`\n\nRuns a function when a condition is met.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | A function or a path. |\n| `callback` | `Function` | yes |  | The function to run. |\n\nThe condition is checked immediately and then every 500 milliseconds. A function must return a truthy value. For a path, the wait ends when the path holds a truthy value.\n\nExample: Wait for a value\n```js\nWAIT('app.config', function() {\n\tconsole.log(GET('app.config.name')); // Demo\n});\n\nsetTimeout(function() {\n\tSET('app.config', { name: 'Demo' });\n}, 100);\n```\n\n### WARN(...values)\n\nType: `method`\n\nPrints a warning to the browser console.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `values` | `Object` | yes |  | The values to print. |\n\n### WATCH(path, callback, [init])\n\nType: `method`\n\nObserves changes of a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `callback` | `Function` | yes |  | A function that receives `(value, flags, path)`: the watched value, the flags and the changed path. |\n| `init` | `Boolean` | no | `false` | Also calls the watcher once after the registration. |\n\nA watcher runs when its own path changes, when a parent path changes, and when a path nested below it changes. Several paths can be joined with `+`.\n\nExample: Observe a path\n```js\nWATCH('user.name', function(value, flags, path) {\n\tconsole.log(value, path); // Peter user.name\n});\n\nSET('user.name', 'Peter');\n```\n\n### WH\n\nType: `property`\n\nThe height of the window in pixels.\n\nReturns: `Number` The height.\n\nThe value is set while the library starts, and is refreshed when the window is resized.\n\nExample: Read the height\n```js\nON('ready', function() {\n\tconsole.log(typeof(WH)); // number\n});\n```\n\n### WIDTH([element])\n\nType: `method`\n\nReturns the name of the device size for the width of an element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | The measured element. |\n\nReturns: `String` The name of the size.\n\nThe sizes `xs`, `sm`, `md` and `lg` are defined in [DEF.devices](../def/).\n\nExample: Measure an element\n```html\n<div id=\"box\" style=\"width:800px\"></div>\n\n<script>\nconsole.log(WIDTH($('#box'))); // sm\n</script>\n```\n\n### WW\n\nType: `property`\n\nThe width of the window in pixels.\n\nReturns: `Number` The width.\n\nThe value is set while the library starts, and is refreshed when the window is resized.\n\nExample: Read the width\n```js\nON('ready', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n","entries":[{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], callback, [onprogress], [scope], [id])","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(key, timeout, [callback])","since":"","deprecated":false},{"type":"method","name":"CACHE()","signature":"CACHE(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"CACHEPATH()","signature":"CACHEPATH(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, [callback])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [raw])","since":"","deprecated":false},{"type":"method","name":"CLRELOAD()","signature":"CLRELOAD(name, [callback])","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], callback, [dependencies], [css])","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"COMPONENTS(path)","since":"","deprecated":false},{"type":"method","name":"CONFIG()","signature":"CONFIG(selector, config)","since":"","deprecated":false},{"type":"property","name":"COOKIES","signature":"COOKIES","since":"","deprecated":false},{"type":"method","name":"COPY()","signature":"COPY(source, target)","since":"","deprecated":false},{"type":"method","name":"CSS()","signature":"CSS(value, [id], [selector])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(text, [key], [type])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"EMPTYARRAY","signature":"EMPTYARRAY","since":"","deprecated":false},{"type":"property","name":"EMPTYOBJECT","signature":"EMPTYOBJECT","since":"","deprecated":false},{"type":"method","name":"ENCRYPT()","signature":"ENCRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"method","name":"ENV()","signature":"ENV(name, [value])","since":"","deprecated":false},{"type":"method","name":"ENVIRONMENT()","signature":"ENVIRONMENT(name, [version], [language], [env])","since":"","deprecated":false},{"type":"method","name":"ERROR()","signature":"ERROR(response, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, callback)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], callback)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [all])","since":"","deprecated":false},{"type":"method","name":"FLAGS()","signature":"FLAGS(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(code)","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE()","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [noflags])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([length])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value)","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value])","since":"","deprecated":false},{"type":"method","name":"inDOM()","signature":"inDOM(element)","since":"","deprecated":false},{"type":"property","name":"isIE","signature":"isIE","since":"","deprecated":false},{"type":"property","name":"isMOBILE","signature":"isMOBILE","since":"","deprecated":false},{"type":"property","name":"isPRIVATEMODE","signature":"isPRIVATEMODE","since":"","deprecated":false},{"type":"property","name":"isROBOT","signature":"isROBOT","since":"","deprecated":false},{"type":"property","name":"isSTANDALONE","signature":"isSTANDALONE","since":"","deprecated":false},{"type":"property","name":"isTOUCH","signature":"isTOUCH","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"method","name":"LOCALIZE()","signature":"LOCALIZE(text)","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"method","name":"NEWUIBIND()","signature":"NEWUIBIND(element, [path], [config])","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, reference, [before])","since":"","deprecated":false},{"type":"method","name":"NODEMOVE()","signature":"NODEMOVE(element, [up])","since":"","deprecated":false},{"type":"method","name":"NOOP()","signature":"NOOP()","since":"","deprecated":false},{"type":"method","name":"NOTFOCUSED()","signature":"NOTFOCUSED()","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path)","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [callback])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value)","since":"","deprecated":false},{"type":"method","name":"PIPE()","signature":"PIPE(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [config], callback, [dependencies])","since":"","deprecated":false},{"type":"property","name":"PLUGINS","signature":"PLUGINS","since":"","deprecated":false},{"type":"property","name":"PREF","signature":"PREF","since":"","deprecated":false},{"type":"method","name":"PUSH()","signature":"PUSH(path, value)","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], data)","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path)","since":"","deprecated":false},{"type":"method","name":"SCROLLBAR()","signature":"SCROLLBAR(element, [options])","since":"","deprecated":false},{"type":"method","name":"SCROLLBARWIDTH()","signature":"SCROLLBARWIDTH()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, callback, timeout, [limit], [param])","since":"","deprecated":false},{"type":"method","name":"STRINGIFY()","signature":"STRINGIFY(value, [compress], [fields], [encrypt])","since":"","deprecated":false},{"type":"method","name":"STYLE()","signature":"STYLE(value, [id], [selector])","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path)","since":"","deprecated":false},{"type":"property","name":"Total","signature":"Total","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...permissions)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [callback])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path)","since":"","deprecated":false},{"type":"method","name":"VISIBLE()","signature":"VISIBLE(element, [threshold], [mode])","since":"","deprecated":false},{"type":"property","name":"W","signature":"W","since":"","deprecated":false},{"type":"method","name":"WAIT()","signature":"WAIT(condition, callback)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...values)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcS61wo61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/globals/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"Globale Funktionen","summary":"Die Funktionen und Variablen, die die Bibliothek dem Objekt window hinzufügt.","markdown":"---\ntitle: Globale Funktionen\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/globals/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Globale Funktionen\n\n> Die Funktionen und Variablen, die die Bibliothek dem Objekt window hinzufügt.\n\nDie Bibliothek fügt `window` diese Funktionen und Variablen hinzu, sodass sie überall in deinem Code verfügbar sind. Beginne mit [Paths](../../guides/paths/) und [Datenbindung](../../guides/data-binding/), um zu sehen, wie sie zusammenspielen.\n\n## API\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nBereitet ein Stück HTML für einen bestimmten Path und eine bestimmte Kennung vor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Wert für `~PATH~` und `CLASS`. Mit `null` überspringst du diese Ersetzungen. |\n| `id` | `String` | yes |  | Der Wert für `~ID~`. Mit `null` überspringst du diese Ersetzung. |\n| `text` | `String` | yes |  | Der vorzubereitende Text. |\n\nReturns: `String` Der vorbereitete Text.\n\nDie Methode übersetzt `@(text)`-Markup, wendet `--name--`-Variablen an und ersetzt `~CDN~` durch [DEF.cdn](../def/). Ist `path` gesetzt, werden `~PATH~` und `CLASS` zum Path, `<ui-plugin>`-Elemente ohne Attribut `path` erhalten ihn, und das erste `PLUGIN(function(` wird zu `PLUGIN('path', function(`. Ist `id` gesetzt, wird `~ID~` zur Kennung. Ein `text`, der leer oder kein String ist, wird unverändert zurückgegeben.\n\nExample: Die Schlüsselwörter ersetzen\n```js\nvar html = '<div class=\"CLASS\" data-id=\"~ID~\">~PATH~</div>';\nconsole.log(ADAPT('users', 'u1', html)); // <div class=\"users\" data-id=\"u1\">users</div>\n```\n\n### AJAX(url, [data], callback, [onprogress], [scope], [id])\n\nType: `method`\n\nSendet eine HTTP-Anfrage und liefert die Antwort an eine Funktion oder einen Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die Methode, die Adresse und optionale Schlüsselwörter, zum Beispiel `POST /api/users/ ERROR`. |\n| `data` | `Object` | no |  | Der Body der Anfrage: ein Objekt, das als JSON gesendet wird, ein String, der als Formulardaten gesendet wird, oder `FormData`. |\n| `callback` | `Function|String` | yes |  | Eine Funktion oder ein Path, die bzw. der die Antwort erhält. |\n| `onprogress` | `Function|String` | no |  | Eine Funktion oder ein Path, die bzw. der den Upload-Fortschritt in Prozent erhält. |\n| `scope` | `Object` | no | `window` | Das Objekt, in dem ein `callback`-Path aufgelöst wird. |\n| `id` | `String` | no | `url` | Der Schlüssel, den `SYNC` und der Cache verwenden. |\n\nDie `url` beginnt mit der HTTP-Methode, gefolgt von der Adresse und optionalen, durch Leerzeichen getrennten Schlüsselwörtern:\n\n| Schlüsselwort | Bedeutung |\n| --- | --- |\n| `ERROR` | Leitet die Antwort durch [ERROR()](../globals/). Enthält sie einen Fehler, wird das Event `ERROR` ausgelöst, und `callback` läuft nicht. Ein Fehlerstatus ohne Body in der Antwort löst das Event `ERROR` mit dem Statuscode aus. |\n| `SYNC` | Reiht Anfragen mit derselben `id` in eine Warteschlange ein, sodass sie nacheinander laufen. |\n| `<1 minute>` | Speichert die Antwort für die angegebene Zeit mit [CACHE()](../globals/) im Cache, außer es ist ein Fehler. Solange die Anfrage läuft, warten andere Aufrufe mit derselben `id` auf ihre Antwort, sodass nur eine Anfrage gesendet wird. |\n| `#name` | Lädt zuerst die Codeliste `name`. Siehe [CL()](../globals/). |\n| `@flag` | Löst das Flag aus, wenn die Anfrage gesendet wird. Siehe [Flags und Path-Modifikatoren](../../guides/flags/). |\n\nEin Objekt in `data` wird als JSON gesendet, ein String unverändert mit dem Inhaltstyp `application/x-www-form-urlencoded` und `FormData` als Formular.\n\nEin Statuscode ab 400 gilt als Fehler. Eine Anfrage, die den Server nicht erreicht, abgebrochen wird oder in ein Timeout läuft, hat den Statuscode `0`, und `callback` erhält eine leere Antwort. Eine Antwort mit JSON-Inhaltstyp wird mit [PARSE()](../globals/) geparst. Jede Anfrage fügt die Header aus [DEF.headers](../def/) hinzu. Ist [DEF.language](../def/) gesetzt, wird es dem Query-String hinzugefügt. Ist [DEF.version](../def/) gesetzt, wird es dem Query-String von `.html`-Adressen hinzugefügt.\n\nMit den [Events](../events/) `request` und `response` kannst du jeden Aufruf prüfen oder ändern. Sobald die Anfrage gesendet ist, enthält `options.xhr` im Event `request` ihren `XMLHttpRequest`, sodass `options.xhr.abort()` sie stoppt. `UPLOAD()` ist dieselbe Funktion unter einem anderen Namen.\n\nExample: Eine Antwort lesen\n```js\nAJAX('GET /api/users/', function(response) {\n\tconsole.log(response.length); // 2\n});\n```\n\nExample: Eine Antwort in einem Path speichern\n```js\nAJAX('POST /api/orders/', { amount: 10 }, 'orders.last');\n\nWATCH('orders.last', function(value) {\n\tconsole.log(value.id); // 100\n});\n```\n\nExample: Formulardaten senden\n```js\nAJAX('POST /api/login/', 'name=Ann&remember=1', function(response) {\n\tconsole.log(response.ok); // true\n});\n```\n\nExample: Eine Anfrage stoppen\n```js\nvar request;\n\nON('request', options => request = options);\nON('ERROR', status => console.log('failed', status)); // failed 0\n\nAJAX('GET /api/report/ ERROR', NOOP);\nrequest.xhr.abort();\n```\n\n### API(url, name, [data], callback, [scope])\n\nType: `method`\n\nRuft einen Total.js-API-Endpunkt an einer bestimmten Adresse auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die Adresse des Endpunkts. |\n| `name` | `String` | yes |  | Der Name der Operation, optional gefolgt von Schlüsselwörtern. |\n| `data` | `Object` | no |  | Die Daten der Operation. |\n| `callback` | `Function|String` | yes |  | Eine Funktion oder ein Path, die bzw. der die Antwort erhält. |\n| `scope` | `Object` | no | `window` | Das Objekt, in dem ein `callback`-Path aufgelöst wird. |\n\nDie Methode sendet `POST url` mit dem JSON-Body `{ schema: name, data: data }`. Von [AJAX()](../globals/) akzeptierte Schlüsselwörter können auf den Namen folgen, zum Beispiel `users_list ERROR`. Für eine feste Adresse siehe [TAPI()](../globals/) und [PIPE()](../globals/).\n\nExample: Eine Operation aufrufen\n```js\nAPI('/admin/api/', 'users_read', { id: 5 }, function(response) {\n\tconsole.log(response.name); // Peter\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nLegt das Farbschema der Seite über CSS-Variablen und Klassen am Body fest.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Die Schalter und die CSS-Variablen. |\n\nJeder Schlüssel wird zu einer CSS-Variable auf `:root`, mit Ausnahme der vier Schalter unten. Der Schlüssel `color` aktualisiert außerdem [DEF.color](../def/) und fügt die Variable `--rgb` mit den Rot-, Grün- und Blauwerten einer drei- oder sechsstelligen Hexadezimalfarbe hinzu.\n\n| Schlüssel | Bedeutung |\n| --- | --- |\n| `dark` oder `darkmode` | Schaltet die Klasse `ui-dark` am Body um. |\n| `large` oder `largemode` | Schaltet die Klasse `ui-large` am Body um. |\n\nDas Klassenpräfix stammt aus [DEF.prefixcsslibrary](../def/).\n\nExample: Dunkles Theme mit Akzentfarbe\n```js\nAPPEARANCE({ dark: true, color: '#4285F4' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#4285F4;--rgb:66,133,244}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\nExample: Eine kurze Farbe\n```js\nAPPEARANCE({ color: '#abc' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#abc;--rgb:170,187,204}\n```\n\n### ASETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nErstellt eine Funktion, die später eine Methode einer Komponente aufruft.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Selektor und die Methode, in derselben Form wie bei `SETTER()`. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nReturns: `Function` Eine Funktion ohne Argumente.\n\nJeder Aufruf der zurückgegebenen Funktion führt [SETTER()](../globals/) mit den hier angegebenen Argumenten aus.\n\nExample: Einen Aufruf vorbereiten\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log('added', value); // added 5\n\t};\n});\n\nON('ready', function() {\n\tvar add = ASETTER('counter/add', 5);\n\tadd();\n});\n</script>\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nLiest ein `data-*`-Attribut von einem Element oder von dessen nächstem übergeordneten Element, das es besitzt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Event|Element|Object` | yes |  | Der Ausgangspunkt. |\n| `name` | `String` | no | `id` | Der Attributname ohne das Präfix `data-`. |\n\nReturns: `String` Der Wert des Attributs.\n\nDas `element` kann ein jQuery-Objekt, ein jQuery-Event (dessen `currentTarget` verwendet wird) oder ein DOM-Element sein. Bei einem einfachen Objekt gibt die Methode die Eigenschaft `name` zurück. Jeder andere Wert wird unverändert zurückgegeben.\n\nExample: Die nächstgelegene Kennung lesen\n```html\n<div data-id=\"15\" data-type=\"user\"><button id=\"save\">Save</button></div>\n\n<script>\nvar button = $('#save');\nconsole.log(ATTRD(button)); // 15\nconsole.log(ATTRD(button, 'type')); // user\nconsole.log(ATTRD({ id: 20 })); // 20\n</script>\n```\n\n### BLOCKED(key, timeout, [callback])\n\nType: `method`\n\nBegrenzt, wie oft eine Operation ausgeführt werden kann.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Name der Operation. |\n| `timeout` | `Number|String` | yes |  | Die Zeit in Millisekunden oder ein Text wie `5 minutes`. |\n| `callback` | `Function` | no |  | Eine Funktion, die läuft, wenn die Operation nicht gesperrt ist. |\n\nReturns: `Boolean` `true`, wenn die Operation gesperrt ist.\n\nDer erste Aufruf sperrt `key` für die angegebene Zeit und gibt `false` zurück. Weitere Aufrufe geben `true` zurück, bis die Zeit abgelaufen ist. Eine Sperre von 10 Sekunden oder länger wird in `localStorage` gehalten und übersteht so ein Neuladen der Seite.\n\nExample: Einen Klick pro Sekunde erlauben\n```js\nON('ready', function() {\n\tconsole.log(BLOCKED('save', 1000)); // false\n\tconsole.log(BLOCKED('save', 1000)); // true\n});\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nLiest oder schreibt einen Wert im persistenten Cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Schlüssel. |\n| `value` | `Object` | no |  | Der zu speichernde Wert. |\n| `expire` | `String` | no |  | Die Lebensdauer des Werts oder `session`. |\n\nReturns: `Object` Beim Lesen der gespeicherte Wert, sonst nichts.\n\nMit `expire` speichert die Methode den Wert. Ohne dieses Argument gibt sie den gespeicherten Wert zurück oder `null`, wenn der Wert fehlt oder abgelaufen ist. Der Wert `session` hält die Daten im Speicher, bis die Seite geschlossen wird. Jeder andere Wert ist eine Zeitangabe wie `10 minutes`, `2 hours`, `1 day`, `1 week`, `1 month` oder `1 year`, und die Daten werden über [DEF.onstoragesave](../def/) gespeichert.\n\nDer Cache wird beim Start der Bibliothek geladen, verwende ihn also ab dem [Event](../events/) `ready`.\n\nExample: Schreiben und lesen\n```js\nON('ready', function() {\n\tCACHE('filter', { page: 2 }, '1 day');\n\tconsole.log(CACHE('filter')); // {\"page\":2}\n\tconsole.log(CACHE('missing')); // null\n});\n```\n\n### CACHEPATH(path, expire, [def])\n\nType: `method`\n\nBewahrt den Wert eines Paths zwischen Besuchen im Cache auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `expire` | `String` | yes |  | Die Lebensdauer des gespeicherten Werts, zum Beispiel `1 day`. |\n| `def` | `Object|Function` | no |  | Der Wert, der verwendet wird, wenn nichts gespeichert ist. Eine Funktion wird aufgerufen, um ihn zu erhalten. |\n\nDie Methode speichert jede Änderung des Paths mit [CACHE()](../globals/) für die Zeit in `expire`. Ist der Path leer, wird der gespeicherte Wert hineingeschrieben, und ist nichts gespeichert, wird `def` geschrieben. Ein Path, der schon einen Wert enthält, behält ihn.\n\nWird die Methode aufgerufen, bevor die Bibliothek den Cache geladen hat, wartet sie darauf und stellt den Wert danach wieder her. Plugins haben dieselbe Methode mit einem relativen Path: [plugin.cachepath()](../plugin/).\n\nExample: Einen Filter merken\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n\nSET('filter.q', 'lamp');\n// After a reload of the page, GET('filter.q') returns lamp\n```\n\n### CL(name, [callback])\n\nType: `method`\n\nLädt mit `CLINIT()` registrierte Codelisten.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Ein Name oder mehrere durch Kommas getrennte Namen. |\n| `callback` | `Function` | no |  | Eine Funktion, die läuft, wenn die Listen geladen sind. |\n\nEine Codeliste enthält gemeinsam genutzte Daten, etwa eine Liste von Ländern, und liegt in [DEF.cl](../def/). Eine Liste wird einmal geladen. Der `callback` läuft, wenn alle Listen verfügbar sind. Ein noch nicht registrierter Name wird alle 500 Millisekunden erneut geprüft, bis er erscheint.\n\nExample: Eine Liste bei Bedarf laden\n```js\nCLINIT('countries', function(next) {\n\tnext([{ id: 'SK', name: 'Slovakia' }]);\n});\n\nON('ready', function() {\n\tCL('countries', function() {\n\t\tconsole.log(DEF.cl.countries.length); // 1\n\t});\n});\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nBricht einen mit `setTimeout2()` erstellten Timer ab.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Timers. |\n\nReturns: `Boolean` `true`, wenn der Timer existiert.\n\nExample: Einen Timer abbrechen\n```js\nsetTimeout2('search', NOOP, 1000);\nconsole.log(clearTimeout2('search')); // true\nconsole.log(clearTimeout2('unknown')); // false\n```\n\n### CLINIT(name, source, [init])\n\nType: `method`\n\nRegistriert die Quelle einer Codeliste.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Codeliste. |\n| `source` | `Function|String` | yes |  | Eine Funktion, eine Anfrage oder eine Operation. |\n| `init` | `Boolean` | no | `false` | Lädt die Liste sofort. |\n\nIst `source` eine Funktion, erhält sie `next(value, [extend])`. Übergib die Liste an `next()`. Ist `extend` auf `true` gesetzt, ist `value` ein Objekt, dessen Schlüssel als separate Codelisten gespeichert werden.\n\nIst `source` ein String, wird ein Wert, der mit einer HTTP-Methode beginnt, mit [AJAX()](../globals/) geladen. Jeder andere Wert ist eine Operation für [TAPI()](../globals/).\n\nExample: Mehrere Listen auf einmal laden\n```js\nCLINIT('all', function(next) {\n\tnext({ colors: ['red'], sizes: ['XL'] }, true);\n}, true);\n\nON('ready', function() {\n\tsetTimeout(function() {\n\t\tconsole.log(DEF.cl.colors, DEF.cl.sizes); // [\"red\"] [\"XL\"]\n\t}, 100);\n});\n```\n\n### CLONE(value, [raw])\n\nType: `method`\n\nErstellt eine tiefe Kopie eines Werts.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|String` | yes |  | Der zu kopierende Wert oder ein Path. |\n| `raw` | `Boolean` | no | `false` | Behandelt einen String als einfachen Wert. |\n\nReturns: `Object` Die Kopie.\n\nEin String wird als Path zu einem Objekt oder Array behandelt, und der dort gefundene Wert wird kopiert. Ist `raw` auf `true` gesetzt, wird ein String unverändert zurückgegeben. Objekte werden über JSON kopiert, und Datumswerte darin bleiben Datumswerte.\n\nExample: Ein Objekt kopieren\n```js\nvar a = { user: { name: 'Peter' } };\nvar b = CLONE(a);\nb.user.name = 'Lucia';\nconsole.log(a.user.name); // Peter\n```\n\nExample: Den Wert eines Paths kopieren\n```js\nSET('form', { name: 'Peter' });\nvar copy = CLONE('form');\nconsole.log(copy); // {\"name\":\"Peter\"}\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nLädt Codelisten erneut aus ihren Quellen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Ein Name oder mehrere durch Kommas getrennte Namen. |\n| `callback` | `Function` | no |  | Eine Funktion, die läuft, wenn die Listen neu geladen sind. |\n\nNur bereits geladene Listen werden neu geladen. Andere Namen werden übersprungen.\n\nExample: Eine Liste aktualisieren\n```js\nvar counter = 0;\n\nCLINIT('stats', function(next) {\n\tnext([++counter]);\n});\n\nON('ready', function() {\n\tCL('stats', function() {\n\t\tCLRELOAD('stats', function() {\n\t\t\tconsole.log(DEF.cl.stats); // [2]\n\t\t});\n\t});\n});\n```\n\n### CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nFührt einen Befehl auf jeder Komponente aus, die ihn registriert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Befehl, optional gefolgt von Flags. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nKomponenten registrieren Befehle mit [command()](../component/). Nach dem Namen können durch ein Leerzeichen getrennt Flags folgen, zum Beispiel `CMD('refresh @saved')`: Diese werden zuerst ausgelöst, wie bei [SET()](../globals/). Um einen Befehl nur in einem Teil der Seite auszuführen, verwende [$(selector).CMD()](../jquery/) oder [plugin.cmd()](../plugin/).\n\nExample: Jede Liste leeren\n```html\n<ui-component name=\"list\"></ui-component>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nvar count = 0;\n\nCOMPONENT('list', function(self) {\n\tself.command('clear', value => count += value);\n});\n\nON('ready', function() {\n\tCMD('clear', 1);\n\tconsole.log(count); // 2\n});\n</script>\n```\n\n### COMPONENT(name, [config], callback, [dependencies], [css])\n\nType: `method`\n\nRegistriert die Deklaration einer Komponente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Komponente. |\n| `config` | `String` | no |  | Die Standardkonfiguration in der Form `key:value;key:value`. |\n| `callback` | `Function` | yes |  | Die Deklaration: `function(self, config, cls)`. |\n| `dependencies` | `String|Array` | no |  | Zuerst zu importierende Adressen, durch Kommas getrennt. Ein Array kann auch Funktionen enthalten, die `next` erhalten. |\n| `css` | `String` | no |  | Die Styles der Komponente. |\n\nDer `callback` läuft einmal für jede Instanz und erhält die Instanz, ihre Konfiguration und ihre CSS-Klasse. Im Argument `css` wird das Wort `CLASS` zu `ui-` gefolgt vom Namen der Komponente. Siehe [Komponenten erstellen](../../guides/creating-components/) und das Objekt [Component](../component/).\n\nExample: Eine Komponente deklarieren\n```html\n<ui-component name=\"hello\"></ui-component>\n\n<script>\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.element.aclass(cls).html('Hello ' + config.name);\n\t\tconsole.log(self.element.html()); // Hello World\n\t};\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nGibt die an einen Path gebundenen Komponenten zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit Flags. |\n\nReturns: `Array` Die passenden Instanzen von [Component](../component/).\n\nDer Path schließt alles darunter ein, `form` liefert also auch eine an `form.name` gebundene Komponente. Flags im Path grenzen das Ergebnis ein: `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` und `@enabled`.\n\nExample: Die Pflichtfelder finden\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.setter = NOOP;\n});\n\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tconsole.log(COMPONENTS('form @required').length); // 1\n});\n</script>\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nÄndert die Konfiguration vorhandener und künftiger Komponenten.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | Die zu konfigurierenden Komponenten. |\n| `config` | `String|Object` | yes |  | Die Konfiguration als Objekt oder in der Form `key:value;key:value`. |\n\nDer `selector` kann Folgendes sein:\n\n| Selektor | Trifft auf |\n| --- | --- |\n| `name` | Komponenten mit diesem Namen. |\n| `#id` | Die Komponente mit dieser Kennung. |\n| `*` | Alle Komponenten. |\n| `.path` | Komponenten, deren Path `path` enthält. |\n| `a, b` | Mehrere durch Kommas getrennte Selektoren. |\n| `function(instance)` | Komponenten, für die die Funktion `true` zurückgibt. |\n\nExample: Nach Namen konfigurieren\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tCONFIG('box', 'color:red;size:10');\n\tconsole.log(FIND('box').config.size); // 10\n});\n</script>\n```\n\n### COOKIES\n\nType: `property`\n\nLiest und schreibt Browser-Cookies.\n\nReturns: `Object` Das Objekt mit den Methoden.\n\nDas Objekt hat drei Methoden:\n\n| Methode | Beschreibung |\n| --- | --- |\n| `COOKIES.get(name)` | Gibt den Wert oder einen leeren String zurück. |\n| `COOKIES.set(name, value, [expire], [samesite])` | Schreibt ein Cookie für den Path `/`. `expire` ist eine Anzahl von Tagen, ein `Date` oder ein Text wie `1 day`. Ohne `expire` bleibt das Cookie erhalten, bis der Browser geschlossen wird. `samesite` ist zum Beispiel `lax`. |\n| `COOKIES.rem(name)` | Entfernt das Cookie. |\n\nExample: Ein Cookie schreiben und lesen\n```js\nCOOKIES.set('theme', 'dark', '1 month', 'lax');\nconsole.log(COOKIES.get('theme')); // dark\n```\n\nExample: Ein Cookie eine Woche lang behalten\n```js\nCOOKIES.set('token', 'a=1', 7);\nconsole.log(COOKIES.get('token')); // a=1\n```\n\n### COPY(source, target)\n\nType: `method`\n\nKopiert die Eigenschaften eines Objekts in ein anderes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | Das Objekt, aus dem gelesen wird. |\n| `target` | `Object` | yes |  | Das Objekt, in das geschrieben wird. |\n\nReturns: `Object` Das Objekt `target`.\n\nVerschachtelte Objekte werden geklont, spätere Änderungen an `source` wirken sich also nicht auf `target` aus.\n\nExample: Zwei Objekte zusammenführen\n```js\nvar target = { a: 1 };\nCOPY({ b: { c: 2 } }, target);\nconsole.log(target); // {\"a\":1,\"b\":{\"c\":2}}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nEin anderer Name für `STYLE()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Das CSS. |\n| `id` | `String` | no |  | Die Kennung des Style-Elements. |\n| `selector` | `String` | no |  | Ein Selektor, der jeder Regel vorangestellt wird. |\n\nSiehe [STYLE()](../globals/). Setzt du `window.jc_globals = { CSS: false }` vor dem Skript der Bibliothek, bleibt dieses Global undefiniert.\n\n### DAYS\n\nType: `property`\n\nDie englischen Namen der Wochentage, beginnend mit Sonntag.\n\nReturns: `Array` Sieben Strings.\n\nExample: Einen Tag lesen\n```js\nconsole.log(DAYS[1]); // Monday\n```\n\n### DEF\n\nType: `property`\n\nDie Standardeinstellungen der Bibliothek.\n\nReturns: `Object` Die Einstellungen.\n\nAuf einer eigenen Seite beschrieben: [DEF](../def/).\n\n### DECRYPT(text, [key], [type])\n\nType: `method`\n\nLiest einen Wert, den `ENCRYPT()` geschrieben hat.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Der Text von `ENCRYPT()`. |\n| `key` | `String` | no |  | Der Schlüssel. |\n| `type` | `String` | no |  | Das Präfix des Texts. |\n\nReturns: `Object` Der Wert oder `undefined`.\n\n`key` und `type` müssen dieselben sein, die du [ENCRYPT()](../globals/) übergeben hast. Die Methode gibt `undefined` zurück, wenn die Prüfsumme nicht zu ihnen passt, was bei einem veränderten Text der Fall ist. Ein Wert, der mit `[`, `{` oder `\"` beginnt, wird als JSON geparst.\n\nExample: Ein Objekt zurücklesen\n```js\nvar text = ENCRYPT({ id: 5 }, 'secret', 'U');\n\nconsole.log(text.charAt(0)); // U\nconsole.log(DECRYPT(text, 'secret', 'U')); // {\"id\":5}\nconsole.log(DECRYPT(text, 'secret')); // undefined\n```\n\n### DIFFDOM(element, selector, html, [attribute])\n\nType: `method`\n\nAktualisiert die Kindelemente eines Elements, sodass sie zu neuem HTML passen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Das übergeordnete Element. |\n| `selector` | `String` | yes |  | Ein Selektor der verglichenen Kindelemente. |\n| `html` | `String` | yes |  | Der neue Inhalt. |\n| `attribute` | `String` | no |  | Das für den Vergleich verwendete Attribut. |\n\nReturns: `Object` Die Anzahl der hinzugefügten, beibehaltenen und entfernten Elemente: `{ add, upd, rem }`.\n\nUnveränderte Kindelemente bleiben im DOM und behalten so ihren Zustand. Kindelemente werden anhand ihres gesamten HTML verglichen oder, falls gesetzt, anhand des Werts von `attribute`.\n\nExample: Eine Liste aktualisieren\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n\n<script>\nvar list = $('#list');\nvar result = DIFFDOM(list, 'li', '<li>A</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log(list.html()); // <li>A</li><li>C</li>\n</script>\n```\n\n### EMIT(name, [a], [b], [c], [d])\n\nType: `method`\n\nLöst ein Event aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nMit [ON()](../globals/) registrierte Handler sowie auf [Komponenten](../component/) und [Plugins](../plugin/) registrierte Handler erhalten die Argumente. Auf den Namen können Flags folgen, zum Beispiel `refresh @loading`. Die Events der Bibliothek sind unter [Events](../events/) aufgeführt.\n\nExample: Ein eigenes Event auslösen\n```js\nON('saved', function(id, name) {\n\tconsole.log(id, name); // 5 Peter\n});\n\nEMIT('saved', 5, 'Peter');\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nEin eingefrorenes leeres Array.\n\nReturns: `Array` Ein Array, das nicht geändert werden kann.\n\nExample: Ein gemeinsamer Standardwert\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nEin eingefrorenes leeres Objekt.\n\nReturns: `Object` Ein Objekt, das nicht geändert werden kann.\n\nExample: Ein gemeinsamer Standardwert\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nKodiert einen Wert als Text mit einer Prüfsumme.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Der Wert. |\n| `key` | `String` | no |  | Der Schlüssel der Prüfsumme. |\n| `type` | `String` | no |  | Ein Präfix, das an den Anfang des Texts geschrieben wird. |\n\nReturns: `String` Der kodierte Text.\n\nEin Objekt oder ein Array wird zuerst mit [STRINGIFY()](../globals/) serialisiert. Das Ergebnis enthält `type` als Präfix, den Wert in hexadezimalen Ziffern, den Buchstaben `x` und eine Prüfsumme, die [HASH()](../globals/) aus dem Wert, `key` und `type` bildet.\n\nJeder kann den Wert zurücklesen, verwende die Methode also nicht, um Daten zu verbergen: Mit dem Schlüssel erkennt [DECRYPT()](../globals/) nur, ob der Text verändert wurde.\n\nExample: Kodieren und dekodieren\n```js\nvar text = ENCRYPT('hello', 'secret');\n\nconsole.log(text); // 68656c6c6fxds46dr\nconsole.log(DECRYPT(text, 'secret')); // hello\nconsole.log(DECRYPT(text, 'other')); // undefined\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nLiest oder schreibt Umgebungsvariablen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | Der Name oder ein Objekt mit Namen und Werten. |\n| `value` | `Object` | no |  | Der zu schreibende Wert. |\n\nReturns: `Object` Der Wert der Variable.\n\nVariablen werden in [DEF.env](../def/) gespeichert. Ein Text kann mit `[name]` auf sie verweisen: Paths, Adressen und Konfigurationswerte ersetzen diese Schreibweise durch den Wert. Übergib ein Objekt, um mehrere Variablen zu schreiben. Jeder Schreibvorgang löst das [Event](../events/) `env` aus.\n\nExample: Eine Variable in einem Text verwenden\n```js\nENV('api', '/api/v1/');\nconsole.log(ENV('api')); // /api/v1/\nconsole.log('[api]users/'.env()); // /api/v1/users/\n```\n\n### ENVIRONMENT(name, [version], [language], [env])\n\nType: `method`\n\nLegt den Speicherschlüssel, die Version, die Sprache und die Umgebungsvariablen der App fest.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der in `localStorage` verwendete Schlüssel. |\n| `version` | `String` | no |  | Die Version der App. |\n| `language` | `String` | no |  | Die Sprache der App. |\n| `env` | `Object` | no |  | Umgebungsvariablen. |\n\nDie Methode weist [DEF.localstorage](../def/), [DEF.version](../def/) und [DEF.language](../def/) zu und übergibt `env` an [ENV()](../globals/). Rufe sie direkt nach dem Skript der Bibliothek auf, damit die App ihren eigenen Speicher liest.\n\nExample: Eine App konfigurieren\n```js\nENVIRONMENT('myapp', '1.0', 'en', { title: 'My app' });\n\nconsole.log(DEF.localstorage, DEF.version, DEF.language); // myapp 1.0 en\nconsole.log(ENV('title')); // My app\n```\n\n### ERROR(response, [success], [error])\n\nType: `method`\n\nPrüft eine Antwort auf Fehler und führt den passenden Handler aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | Die zu prüfende Antwort. |\n| `success` | `Function|String` | no |  | Läuft, wenn kein Fehler vorliegt. |\n| `error` | `Function|String` | no |  | Läuft, wenn ein Fehler vorliegt. |\n\nReturns: `Boolean` `true`, wenn die Antwort einen Fehler enthält.\n\nEine Antwort gilt als Fehler, wenn sie ein `Error`-Objekt ist, eine Eigenschaft `error` hat oder ein Array ist, dessen erstes Element eine solche Eigenschaft hat. Ein Fehler löst das [Event](../events/) `ERROR` aus.\n\n`success` und `error` können Funktionen oder Namen für [SEEX()](../globals/) sein.\n\nRufe `ERROR(success, [error])` ohne Antwort auf, um eine Funktion zu erstellen, die du als Callback übergeben kannst.\n\nExample: Eine Antwort prüfen\n```js\nconsole.log(ERROR({ id: 1 })); // false\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\n```\n\nExample: Einen Callback erstellen\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 1\n});\n\ncallback({ id: 1 });\n```\n\n### ERRORS(path, callback)\n\nType: `method`\n\nGibt die ungültigen Komponenten eines Paths oder eines Elements zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|jQuery` | yes |  | Ein Path oder ein Element, das die Komponenten enthält. |\n| `callback` | `Function` | yes |  | Eine Funktion, die ein Array von [Komponenten](../component/) erhält. |\n\nExample: Ein Formular validieren\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.validate = function(value) {\n\t\treturn !!value;\n\t};\n});\n\nON('ready', function() {\n\tERRORS('form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuft eine Funktion über ihren Namen auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Das Ziel des Aufrufs. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nDie Form von `name` entscheidet, was aufgerufen wird:\n\n| Name | Ruft auf |\n| --- | --- |\n| `name` | Eine globale Funktion. |\n| `FUNC.name` | Eine Funktion an einem Path. |\n| `plugin/method` | Eine Methode eines [Plugins](../plugin/). |\n| `*/method` | Eine Methode des Plugins common. |\n| `-component/method` | Eine Methode einer Komponente, über [SETTER()](../globals/). |\n| `#event` | Ein Event, über [EMIT()](../globals/). |\n\nFüge das Flag `@important` hinzu, um es alle 500 Millisekunden erneut zu versuchen, bis die Funktion existiert, zum Beispiel `EXEC('app/refresh @important')`. `EXE()` ist dieselbe Funktion unter einem anderen Namen.\n\nExample: Eine Funktion über ihren Path aufrufen\n```js\nFUNC.sum = function(a, b) {\n\tconsole.log(a + b); // 5\n};\n\nEXEC('FUNC.sum', 2, 3);\n```\n\nExample: Auf eine Funktion warten\n```js\nEXEC('app.start @important', 'now');\n\nsetTimeout(function() {\n\twindow.app = {};\n\tapp.start = function(value) {\n\t\tconsole.log(value); // now\n\t};\n}, 100);\n```\n\n### EXTENSION(name, [config], callback)\n\nType: `method`\n\nErweitert eine Komponente oder ein Plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Komponente oder `@` gefolgt vom Namen des Plugins. |\n| `config` | `String|Object` | no |  | Konfiguration, die jeder Instanz hinzugefügt wird. |\n| `callback` | `Function` | yes |  | Eine Funktion `(instance, config, cls)`, wobei `cls` die CSS-Klasse der Instanz ist. `this` ist die Instanz. |\n\nDer `callback` läuft für jede vorhandene und jede neue Instanz, direkt nach der Deklaration, immer mit denselben Argumenten. Schreibe bei einem Plugin `@` vor dessen Namen.\n\nExample: Einer Komponente eine Methode hinzufügen\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nEXTENSION('box', 'color:red', function(self, config) {\n\tself.describe = function() {\n\t\treturn config.color;\n\t};\n});\n\nON('ready', function() {\n\tconsole.log(FIND('box').describe()); // red\n});\n</script>\n```\n\n### FIND(selector, [all])\n\nType: `method`\n\nFindet eine Komponente, die bereit ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Der Name, die Kennung oder der Path. |\n| `all` | `Boolean` | no | `false` | Gibt alle Treffer in einem Array zurück. |\n\nReturns: `Component|Array` Die erste [Komponente](../component/) oder ein Array, wenn `all` den Wert `true` hat.\n\nDer `selector` ist ein Komponentenname, `#id` für eine Kennung oder `.path` für einen Path.\n\nExample: Nach Name und Path suchen\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('field').name); // field\n\tconsole.log(FIND('.form.name').path.path); // form.name\n\tconsole.log(FIND('field', true).length); // 1\n});\n</script>\n```\n\n### FLAGS(flags, [callback])\n\nType: `method`\n\nLöst Flags aus und führt dann eine Funktion aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Die Flags, zum Beispiel `@loading @save`. |\n| `callback` | `Function` | no |  | Eine Funktion, die danach läuft. |\n\nJedes Flag löst das Event `@flag name` aus, das du mit [ON()](../globals/) abfangen kannst. Siehe [Flags und Path-Modifikatoren](../../guides/flags/).\n\nExample: Ein Flag abfangen\n```js\nON('@flag loading', function() {\n\tconsole.log('flag captured'); // flag captured\n});\n\nFLAGS('@loading', function() {\n\tconsole.log('done'); // done\n});\n```\n\n### FN(code)\n\nType: `method`\n\nKompiliert eine Pfeilfunktion aus einem String.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | yes |  | Der Code der Funktion. |\n\nReturns: `Function` Die kompilierte Funktion.\n\nDer Code kann bis zu vier Argumente haben. Code ohne Pfeil wird zu einer Funktion mit dem Argument `value`. Kompilierte Funktionen werden im Cache gehalten.\n\nExample: Funktionen kompilieren\n```js\nconsole.log(FN('n => n * 2')(4)); // 8\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value + 1')(1)); // 2\n```\n\n### FREE()\n\nType: `method`\n\nEntfernt Komponenten, Bindungen und Plugins, deren Elemente das DOM verlassen haben.\n\nDie Bibliothek führt diese Bereinigung jede Minute aus. Rufe die Funktion auf, wenn die Instanzen sofort entfernt werden sollen.\n\nExample: Eine losgelöste Komponente entfernen\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\t$('ui-component').remove();\n\tFREE();\n\tconsole.log(COMPONENTS('form').length); // 0\n});\n</script>\n```\n\n### FUNC\n\nType: `property`\n\nEin leeres Objekt für die Funktionen deiner App.\n\nReturns: `Object` Der Container.\n\nHier gespeicherte Funktionen lassen sich mit [EXEC()](../globals/) über ihren Path aufrufen.\n\nExample: Eine Funktion speichern\n```js\nFUNC.hello = function() {\n\treturn 'Hello';\n};\n\nconsole.log(FUNC.hello()); // Hello\n```\n\n### GET(path, [noflags])\n\nType: `method`\n\nLiest den Wert eines Paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit Flags. |\n| `noflags` | `Boolean` | no | `false` | Liest den Wert, ohne die Flags anzuwenden. |\n\nReturns: `Object` Der Wert.\n\nEnthält der Path Flags, werden sie auf die Komponenten des Paths angewendet: `GET('form @reset')` gibt den Wert zurück und setzt deren Zustand zurück. Siehe [Paths](../../guides/paths/).\n\nExample: Werte lesen\n```js\nSET('user.name', 'Peter');\n\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\n### GUID([length])\n\nType: `method`\n\nErzeugt eine zufällige Kennung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | no |  | Die Länge der Kennung. |\n\nReturns: `String` Die Kennung.\n\nOhne `length` hat das Ergebnis die 36-stellige Form einer UUID. Mit `length` ist es ein String aus Kleinbuchstaben und Ziffern.\n\nExample: Kennungen erzeugen\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value)\n\nType: `method`\n\nErzeugt einen numerischen Hash eines Werts.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Number|Boolean|Object|Date` | yes |  | Der Wert. |\n\nReturns: `Number` Der Hash.\n\nEine Zahl wird unverändert zurückgegeben, `true` ergibt `1`, ein Datum seine Zeit in Millisekunden und ein leerer Wert `0`. Objekte werden zuerst serialisiert.\n\nExample: Einen String hashen\n```js\nconsole.log(HASH('hello')); // 99162322\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nPrüft, ob ein in der Seite verschachteltes Element ausgeblendet ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Ein Element, das in einem anderen Element des Body liegt. |\n\nReturns: `Boolean` `true`, wenn das Element ausgeblendet ist.\n\nDas Element gilt als ausgeblendet, wenn es keinen Offset-Parent hat, was bei `display:none` der Fall ist. Auch ein fehlendes Element gilt als ausgeblendet. Um die Position im Viewport zu prüfen, verwendest du [VISIBLE()](../globals/).\n\nExample: Ein Element prüfen\n```html\n<main><div id=\"a\" style=\"display:none\"></div><div id=\"b\"></div></main>\n\n<script>\nconsole.log(HIDDEN($('#a'))); // true\nconsole.log(HIDDEN($('#b'))); // false\n</script>\n```\n\n### IMPORT(url, [target], [callback], [prepare])\n\nType: `method`\n\nLädt ein Skript, ein Stylesheet oder ein Stück HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die Adresse und optionale Schlüsselwörter. |\n| `target` | `String|jQuery|Element` | no | `body` | Das Element, das den HTML-Inhalt erhält. |\n| `callback` | `Function` | no |  | Eine Funktion, die läuft, wenn der Inhalt geladen ist. |\n| `prepare` | `Function` | no |  | Eine Funktion, die das HTML erhält und den einzufügenden Text zurückgibt. |\n\nAdressen, die auf `.js` oder `.css` enden, werden dem Head der Seite hinzugefügt. Jede andere Adresse wird heruntergeladen und in `target` eingefügt. Schlüsselwörter lassen sich mit der Adresse kombinieren:\n\n| Schlüsselwort | Bedeutung |\n| --- | --- |\n| `<name>` | Überspringt den Import, wenn die globale Variable `name` existiert. |\n| `.js`, `.css`, `.html` | Legt den Inhaltstyp fest, wenn die Adresse ihn nicht erkennen lässt. |\n| `@singleton` | Importiert die Adresse nur einmal. |\n| `@prepend` | Fügt den Inhalt am Anfang von `target` ein. |\n\nKann ein Skript oder ein Stylesheet nicht geladen werden, schreibt die Bibliothek eine Warnung in die Konsole, und `callback` läuft trotzdem.\n\nSiehe [Inhalte importieren](../../guides/importing/).\n\nExample: Ein Stück HTML einfügen\n```html\n<div id=\"menu\"></div>\n\n<script>\nIMPORT('/parts/menu.html', '#menu', function() {\n\tconsole.log($('#menu').html()); // <b>Menu</b>\n});\n</script>\n```\n\nExample: Eine vorhandene Bibliothek überspringen\n```js\nIMPORT('<jQuery> /js/jquery.min.js', function() {\n\tconsole.log('jQuery is available'); // jQuery is available\n});\n```\n\n### INC(path, [value])\n\nType: `method`\n\nErhöht die in einem Path gespeicherte Zahl.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `value` | `Number` | no | `1` | Der zu addierende Betrag. |\n\nEin leerer Path beginnt bei `0`. Ein String wird in eine Zahl umgewandelt. Mit einem negativen `value` verringerst du die Zahl.\n\nExample: Einen Zähler erhöhen\n```js\nSET('stats.visits', 10);\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 16\n```\n\n### inDOM(element)\n\nType: `method`\n\nPrüft, ob ein Element mit dem Body des Dokuments verbunden ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | Ein DOM-Element. |\n\nReturns: `Boolean` `true`, wenn das Element verbunden ist, sonst nichts.\n\nExample: Ein Element prüfen\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(!!inDOM(document.createElement('div'))); // false\n```\n\n### isIE\n\nType: `property`\n\nGibt an, ob der Browser Internet Explorer ist.\n\nReturns: `Boolean` Das Ergebnis der Erkennung.\n\n### isMOBILE\n\nType: `property`\n\nGibt an, ob der User-Agent zu einem Mobilgerät gehört.\n\nReturns: `Boolean` Das Ergebnis der Erkennung.\n\n### isPRIVATEMODE\n\nType: `property`\n\nGibt an, ob `localStorage` nicht verfügbar ist, wie in manchen privaten Fenstern. Der Wert wird beim Start der Bibliothek gesetzt, lies ihn also ab dem Event `ready`.\n\nReturns: `Boolean` Das Ergebnis der Erkennung.\n\n### isROBOT\n\nType: `property`\n\nGibt an, ob der User-Agent zu einer Suchmaschine oder einem Crawler gehört.\n\nReturns: `Boolean` Das Ergebnis der Erkennung.\n\n### isSTANDALONE\n\nType: `property`\n\nGibt an, ob die Seite als installierte Web-App läuft.\n\nReturns: `Boolean` Das Ergebnis der Erkennung.\n\n### isTOUCH\n\nType: `property`\n\nGibt an, ob das Gerät Touch-Eingaben unterstützt.\n\nReturns: `Boolean` Das Ergebnis der Erkennung.\n\n### jComponent\n\nType: `property`\n\nDas Hauptobjekt der Bibliothek.\n\nReturns: `Object` Das Hauptobjekt.\n\nDasselbe Objekt wie [MAIN](../main/).\n\n### LOCALIZE(text)\n\nType: `method`\n\nLädt Übersetzungen in das Wörterbuch.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Die Zeilen mit den Übersetzungen. |\n\nJede Zeile hat die Form `key : translation`, und Zeilen, die mit `//` beginnen, werden übersprungen. Der Schlüssel ist der Hash des Originaltexts zur Basis 36 mit dem Präfix `T`. Die Übersetzungen werden in [DEF.dictionary](../def/) gespeichert und von [TRANSLATE()](../globals/) verwendet. Siehe [Lokalisierung](../../guides/localization/).\n\nExample: Eine Übersetzung laden\n```js\nvar key = 'T' + HASH('Hello').toString(36);\n\nLOCALIZE(key + ' : Hola');\nconsole.log(TRANSLATE('@(Hello)')); // Hola\n```\n\n### M\n\nType: `property`\n\nEin kurzer Name für das Hauptobjekt.\n\nReturns: `Object` Das Hauptobjekt.\n\nDasselbe Objekt wie [MAIN](../main/).\n\n### MAIN\n\nType: `property`\n\nDas Hauptobjekt der Bibliothek.\n\nReturns: `Object` Das Hauptobjekt.\n\nAuf einer eigenen Seite beschrieben: [MAIN](../main/).\n\n### MONTHS\n\nType: `property`\n\nDie englischen Namen der Monate, beginnend mit Januar.\n\nReturns: `Array` Zwölf Strings.\n\nExample: Einen Monat lesen\n```js\nconsole.log(MONTHS[0]); // January\n```\n\n### NEWUIBIND(element, [path], [config])\n\nType: `method`\n\nErstellt per Code eine Datenbindung an einem Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Das Element. |\n| `path` | `String` | no |  | Der zu beobachtende Path. |\n| `config` | `String` | no |  | Die Befehle der Bindung. |\n\nDie Bindung funktioniert wie das Element [ui-bind](../ui-bind/). Ohne `path` und `config` werden die Werte aus den Attributen des Elements gelesen.\n\nExample: Ein Element an einen Path binden\n```html\n<div id=\"name\"></div>\n\n<script>\nSET('user.name', 'Peter');\nNEWUIBIND($('#name'), 'user.name', 'text:value');\n\nsetTimeout(function() {\n\tconsole.log($('#name').html()); // Peter\n}, 200);\n</script>\n```\n\n### NODEINDEXOF(element)\n\nType: `method`\n\nGibt die Position eines Elements unter seinen Geschwistern zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Das Element. |\n\nReturns: `Number` Die nullbasierte Position.\n\nExample: Eine Position lesen\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li></ul>\n\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, reference, [before])\n\nType: `method`\n\nFügt ein Element neben einem anderen Element ein.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Das einzufügende Element. |\n| `reference` | `jQuery|Element` | yes |  | Das Referenzelement. |\n| `before` | `Boolean` | no | `false` | Fügt das Element vor der Referenz ein. |\n\nExample: Ein Element verschieben\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEINSERT($('#c'), $('#a'), true);\nconsole.log($('ul').text()); // CAB\n</script>\n```\n\n### NODEMOVE(element, [up])\n\nType: `method`\n\nVerschiebt ein Element um eine Position unter seinen Geschwistern.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Das Element. |\n| `up` | `Boolean` | no | `false` | Verschiebt das Element in Richtung Anfang. Andernfalls verschiebt es sich in Richtung Ende. |\n\nExample: Eine Liste neu ordnen\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BAC\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nEine Funktion, die nichts macht.\n\nVerwende sie als Standard-Callback.\n\nExample: Ein Standard-Callback\n```js\nvar callback = NOOP;\nconsole.log(typeof(callback)); // function\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nPrüft, ob die Seite im Hintergrund ist.\n\nReturns: `Boolean` `true`, wenn das Dokument verborgen ist.\n\nExample: Die Seite prüfen\n```js\nconsole.log(NOTFOCUSED()); // false\n```\n\n### NOW\n\nType: `property`\n\nDas aktuelle Datum, einmal pro Minute aktualisiert.\n\nReturns: `Date` Das Datum.\n\nVerwende es, wenn eine Genauigkeit von einer Minute ausreicht. So wird nicht bei jeder Verwendung ein neues `Date`-Objekt erstellt.\n\nExample: Das Datum lesen\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path)\n\nType: `method`\n\nSetzt einen Path auf `null`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\n`NULL()` ist dieselbe Funktion unter einem anderen Namen.\n\nExample: Einen Wert leeren\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### OFF(name, [callback])\n\nType: `method`\n\nEntfernt Event-Handler.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `callback` | `Function` | no |  | Der zu entfernende Handler. |\n\nOhne `callback` werden alle Handler des Events entfernt. Mehrere Events lassen sich mit `+` verbinden.\n\nExample: Einen Handler entfernen\n```js\nvar count = 0;\nvar handler = function() {\n\tcount++;\n};\n\nON('refresh', handler);\nEMIT('refresh');\nOFF('refresh', handler);\nEMIT('refresh');\nconsole.log(count); // 1\n```\n\n### ON(name, callback, [init])\n\nType: `method`\n\nRegistriert einen Event-Handler.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `callback` | `Function` | yes |  | Der Handler. Er erhält die Argumente des Events. |\n| `init` | `Boolean` | no | `false` | Ruft den Handler zusätzlich einmal ohne Argumente auf. |\n\nMehrere Events lassen sich mit `+` verbinden, zum Beispiel `saved + removed`. Ein Handler für `ready` oder `init` läuft sofort, wenn die Bibliothek bereits gestartet ist. Die Events der Bibliothek sind unter [Events](../events/) aufgeführt.\n\nExample: Zwei Events abfangen\n```js\nvar count = 0;\n\nON('saved + removed', function() {\n\tcount++;\n});\n\nEMIT('saved');\nEMIT('removed');\nconsole.log(count); // 2\n```\n\n### PARSE(value)\n\nType: `method`\n\nParst JSON und wandelt Datums-Strings in `Date`-Objekte um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Das JSON, ein Selektor oder ein Objekt. |\n\nReturns: `Object` Der geparste Wert oder `null`.\n\nEin Wert, der mit `#` oder `.` beginnt, ist ein Selektor: Das JSON wird aus dem Inhalt dieses Elements gelesen. Ein Objekt wird unverändert zurückgegeben. Ungültiges JSON ergibt `null`.\n\nExample: JSON parsen\n```js\nvar data = PARSE('{\"created\":\"2024-05-01T10:00:00.000Z\"}');\nconsole.log(data.created instanceof Date); // true\nconsole.log(PARSE('invalid')); // null\n```\n\n### PIPE(name, [data], callback, [scope])\n\nType: `method`\n\nRuft eine Operation an der Adresse aus `DEF.pipe` auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Operation, optional gefolgt von Schlüsselwörtern. |\n| `data` | `Object` | no |  | Die Daten der Operation. |\n| `callback` | `Function|String` | yes |  | Eine Funktion oder ein Path, die bzw. der die Antwort erhält. |\n| `scope` | `Object` | no | `window` | Das Objekt, in dem ein `callback`-Path aufgelöst wird. |\n\nFunktioniert wie [API()](../globals/), wobei die Adresse aus [DEF.pipe](../def/) stammt.\n\nExample: Eine Operation aufrufen\n```js\nDEF.pipe = '/pipe/';\n\nPIPE('orders_list', function(response) {\n\tconsole.log(response.length); // 1\n});\n```\n\n### PLUGIN(name, [config], callback, [dependencies])\n\nType: `method`\n\nRegistriert die Deklaration eines Plugins.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Plugins. |\n| `config` | `String` | no |  | Die Standardkonfiguration in der Form `key:value;key:value`. |\n| `callback` | `Function` | yes |  | Die Deklaration: `function(self, config)`. |\n| `dependencies` | `String|Array` | no |  | Zuerst zu importierende Adressen. |\n\nDer `callback` läuft, wenn ein Element [ui-plugin](../ui-plugin/) mit diesem Path erstellt wird. Der Name `*` registriert das Plugin common. Siehe [Plugins](../../guides/plugins/) und das Objekt [Plugin](../plugin/).\n\nExample: Ein Plugin deklarieren\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('Hello ' + name); // Hello Peter\n\t};\n});\n\nON('ready', function() {\n\tEXEC('users/hello', 'Peter');\n});\n</script>\n```\n\n### PLUGINS\n\nType: `property`\n\nDie laufenden Plugin-Instanzen, nach Namen.\n\nReturns: `Object` Die Instanzen von [Plugin](../plugin/).\n\nExample: Ein Plugin lesen\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('ready', function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n});\n</script>\n```\n\n### PREF\n\nType: `property`\n\nPersistente Benutzereinstellungen.\n\nReturns: `Object` Die Einstellungen.\n\nAuf einer eigenen Seite beschrieben: [PREF](../pref/).\n\n### PUSH(path, value)\n\nType: `method`\n\nFügt dem in einem Path gespeicherten Array ein Element hinzu und benachrichtigt den Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path eines vorhandenen Arrays. |\n| `value` | `Object` | yes |  | Das Element. |\n\nSchreibe `^` vor den Path, um das Element am Anfang des Arrays einzufügen.\n\nExample: Elemente hinzufügen\n```js\nSET('tags', ['b']);\nPUSH('tags', 'c');\nPUSH('^tags', 'a');\nconsole.log(GET('tags')); // [\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], data)\n\nType: `method`\n\nHängt Daten als Query-String an eine Adresse an.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | Die Adresse. |\n| `data` | `Object` | yes |  | Die Werte. |\n\nReturns: `String` Die Adresse mit dem Query-String.\n\nLeere Werte werden übersprungen, Datumswerte in ISO-Strings umgewandelt und Arrays mit Kommas verbunden. Die `url` kann mit einer HTTP-Methode beginnen.\n\nExample: Adressen zusammensetzen\n```js\nconsole.log(QUERIFY('/users/', { page: 2, q: 'a b' })); // /users/?page=2&q=a%20b\nconsole.log(QUERIFY('GET /users/', { page: 2 })); // GET /users/?page=2\nconsole.log(QUERIFY({ page: 2 })); // ?page=2\n```\n\n### REPO\n\nType: `property`\n\nEin leeres Objekt für die gemeinsamen Daten deiner App.\n\nReturns: `Object` Der Container.\n\nExample: Einen Wert speichern\n```js\nREPO.title = 'My app';\nconsole.log(REPO.title); // My app\n```\n\n### RESET(path)\n\nType: `method`\n\nSetzt den Zustand der an einen Path gebundenen Komponenten zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nDie Zustände `touched` und `modified` kehren zu ihren Standardwerten zurück. Der Wert des Paths ändert sich nicht.\n\nExample: Ein Formular zurücksetzen\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tSET('form.name @change', 'Peter');\n\tconsole.log(FIND('field').config.modified); // 1\n\tRESET('form');\n\tconsole.log(FIND('field').config.modified); // 0\n\tconsole.log(GET('form.name')); // Peter\n});\n</script>\n```\n\n### SCROLLBAR(element, [options])\n\nType: `method`\n\nFügt einem Element eine eigene Scrollbar hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Das Element. |\n| `options` | `Object` | no |  | Die Optionen. |\n\nReturns: `Object` Die Scrollbar.\n\nOptionen:\n\n| Option | Typ | Beschreibung |\n| --- | --- | --- |\n| `native` | Boolean | Behält die Scrollbar des Browsers bei und setzt nur den Overflow. |\n| `orientation` | String | `x` oder `y`. Standardmäßig sind beide Richtungen aktiv. |\n| `visibleX`, `visibleY` | Boolean | Lässt die Spur sichtbar, wenn es nichts zu scrollen gibt. |\n| `wrap` | Boolean | `false` verwendet den vorhandenen Inhalt als Scrollbereich. |\n| `controls` | jQuery | Das Element, das die Spuren der Scrollbar erhält. |\n| `shadow` | Boolean | Fügt an den scrollbaren Rändern Schatten hinzu. |\n| `padding` | Number | Der Abstand der Spuren vom Rand. Standardwert: `5`. |\n| `minsize` | Number | Die Mindestgröße des Balkens. Standardwert: `50`. |\n| `thickness` | Number | Die Stärke, die gilt, wenn das CSS keine festlegt. Standardwert: `10`. |\n| `margin`, `marginX`, `marginY` | Number | Passen die Größe des Scrollbereichs an. |\n| `offsetX`, `offsetY` | Number | Passen die gemessene Größe des Elements an. |\n| `floating` | Boolean | `false` reserviert Platz für die Balken. |\n| `parent` | String\\|jQuery | Das Element, dessen Größe verwendet wird. |\n| `interval` | Number | Die Zeit zwischen den Größenprüfungen in Millisekunden. Standardwert: `54321`. |\n| `autoresize` | Boolean | `false` beendet das erneute Messen des Elements, wenn sich die Größe des Fensters ändert. Standardwert: `true`. |\n| `onscroll`, `onidle`, `onresize` | Function | Handler, die die Scrollbar erhalten. |\n\nDas zurückgegebene Objekt bietet:\n\n| Member | Beschreibung |\n| --- | --- |\n| `area` | Das scrollende Element. |\n| `body` | Das Element mit dem Inhalt. |\n| `element` | Das ursprüngliche Element. |\n| `resize()` | Misst das Element erneut. |\n| `scrollTop([value])` | Liest oder setzt die vertikale Position. Ein String wie `'+20'` verschiebt relativ zur aktuellen Position. |\n| `scrollLeft([value])` | Liest oder setzt die horizontale Position, nach denselben Regeln. |\n| `scrollBottom(offset)` | Scrollt nach unten, abzüglich `offset`. |\n| `scrollRight(offset)` | Scrollt zum rechten Rand, abzüglich `offset`. |\n| `scroll(x, y)` | Scrollt zu einer Position. |\n| `sync(element, [direction])` | Synchronisiert das Scrollen mit einem anderen Element. `direction` ist `x` oder `y`. |\n| `destroy()` | Beendet die Scrollbar. |\n\nDie [Events](../events/) `scroll` und `scrollidle` melden das Scrollen.\n\nExample: Per Code scrollen\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nvar scrollbar = SCROLLBAR($('#panel'));\n\nscrollbar.area.css('overflow', 'auto');\nscrollbar.resize(false, true);\nscrollbar.scrollTop(30);\nconsole.log(scrollbar.scrollTop()); // 30\nscrollbar.scrollTop('+20');\nconsole.log(scrollbar.scrollTop()); // 50\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nGibt die Breite der Scrollbar des Browsers zurück.\n\nReturns: `Number` Die Breite in Pixeln.\n\nExample: Die Breite lesen\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuft je nach Name eine Funktion auf oder schreibt einen Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Das Ziel. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nDie Form `plugin/method` ruft eine Plugin-Methode auf, und der Name einer globalen Funktion ruft diese Funktion auf. Jeder andere Name ist ein Path, in den `a` mit [SET()](../globals/) geschrieben wird.\n\nExample: In einen Path schreiben\n```js\nSEEX('form.name', 'Peter');\nconsole.log(GET('form.name')); // Peter\n```\n\nExample: Eine globale Funktion aufrufen\n```js\nwindow.notify = function(text) {\n\tconsole.log(text); // Saved\n};\n\nSEEX('notify', 'Saved');\n```\n\n### SET(path, value)\n\nType: `method`\n\nSchreibt einen Wert in einen Path und benachrichtigt alles, was ihn beobachtet.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit Flags. |\n| `value` | `Object` | yes |  | Der Wert oder eine Funktion `(current)`, die ihn zurückgibt. |\n\nFehlende Objekte entlang des Paths werden erstellt. Flags sind Teil des Paths, zum Beispiel `form.name @change`. Die Form `path[]` hängt den Wert an ein Array an. Eine Funktion als `value` erhält den aktuellen Wert, und ihr Ergebnis wird geschrieben. Siehe [Paths](../../guides/paths/) und [Flags und Path-Modifikatoren](../../guides/flags/).\n\nExample: Werte schreiben\n```js\nSET('user.name', 'Peter');\nSET('user.tags[]', 'admin');\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"tags\":[\"admin\"]}\n```\n\nExample: Einen Wert aus dem aktuellen schreiben\n```js\nSET('cart.count', 1);\nSET('cart.count', value => value + 1);\nconsole.log(GET('cart.count')); // 2\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuft eine Methode auf den Komponenten auf, die zu einem Selektor passen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Selektor und die Methode. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nDer `name` hat die Form `selector/method`:\n\n| Selektor | Trifft auf |\n| --- | --- |\n| `name` | Komponenten mit diesem Namen. |\n| `#id` | Die Komponente mit dieser Kennung. |\n| `*` | Alle Komponenten, die die Methode haben. |\n\nDas Flag `@important` versucht es alle 500 Millisekunden erneut, bis eine passende Komponente mit der Methode existiert. Eine als lazy deklarierte Komponente wird beim ersten Aufruf erstellt, sofern der Name nicht mit `!` beginnt.\n\nExample: Eine Methode einer Komponente aufrufen\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log(value); // 5\n\t};\n});\n\nON('ready', function() {\n\tSETTER('counter/add', 5);\n});\n</script>\n```\n\n### setTimeout2(name, callback, timeout, [limit], [param])\n\nType: `method`\n\nFührt eine Funktion nach einer Verzögerung aus und startet die Verzögerung bei jedem Aufruf mit demselben Namen neu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Timers. |\n| `callback` | `Function` | yes |  | Die Funktion. |\n| `timeout` | `Number` | yes |  | Die Verzögerung in Millisekunden. |\n| `limit` | `Number` | no |  | Die maximale Anzahl der Aufrufe in einer Wartezeit. |\n| `param` | `Object` | no |  | Das Argument der Funktion. |\n\nReturns: `String` Der Name des Timers. Ein durch `limit` ignorierter Aufruf gibt nichts zurück.\n\nMit `limit` wird die Verzögerung höchstens `limit`-mal neu gestartet. Weitere Aufrufe werden ignoriert, bis die Funktion läuft, sodass sie nicht endlos aufgeschoben werden kann.\n\nExample: Nach dem letzten Aufruf einmal ausführen\n```js\nvar count = 0;\nvar run = function() {\n\tcount++;\n\tconsole.log(count); // 1\n};\n\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\n```\n\n### STRINGIFY(value, [compress], [fields], [encrypt])\n\nType: `method`\n\nSerialisiert einen Wert zu JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der Wert. |\n| `compress` | `Boolean` | no | `false` | Entfernt leere Werte. |\n| `fields` | `Array|Object|Function` | no |  | Die beizubehaltenden Schlüssel. |\n| `encrypt` | `Boolean|String` | no |  | `true` kodiert das JSON mit [ENCRYPT()](../globals/). Ein String macht dasselbe und ist der Schlüssel. |\n\nReturns: `String` Das JSON.\n\nIst `compress` auf `true` gesetzt, werden Strings getrimmt und leere Strings, `false` und `null` weggelassen. Das Argument `fields` wählt die Schlüssel aus: ein Array erlaubter Schlüssel, ein Objekt, in dem `false` einen Schlüssel ausschließt, oder eine Funktion `(key, value)`, die für die beizubehaltenden Schlüssel `true` zurückgibt.\n\nExample: Komprimieren und filtern\n```js\nvar data = { name: ' Peter ', note: '', age: 30 };\n\nconsole.log(STRINGIFY(data, true)); // {\"name\":\"Peter\",\"age\":30}\nconsole.log(STRINGIFY(data, false, ['age'])); // {\"age\":30}\n```\n\nExample: Das JSON kodieren\n```js\nvar text = STRINGIFY({ id: 5 }, false, null, 'secret');\nconsole.log(DECRYPT(text, 'secret')); // {\"id\":5}\n```\n\n### STYLE(value, [id], [selector])\n\nType: `method`\n\nFügt der Seite CSS hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Das CSS. |\n| `id` | `String` | no |  | Die Kennung des Style-Elements. |\n| `selector` | `String` | no |  | Ein Selektor, der jeder Regel vorangestellt wird. |\n\nEin Element mit derselben `id` wird ersetzt. Das Element hat als Kennung `css` gefolgt von `id`. Mit `selector` wird jeder Regel dieser Selektor vorangestellt.\n\nExample: Styles mit Scope hinzufügen\n```js\nSTYLE('b { color: red }', 'theme', '.panel');\nconsole.log($('#csstheme').html()); // .panel b{ color: red }\n```\n\n### TAPI(name, [data], callback, [scope])\n\nType: `method`\n\nRuft eine Total.js-API-Operation an der Adresse aus `DEF.api` auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Operation, optional gefolgt von Schlüsselwörtern. |\n| `data` | `Object` | no |  | Die Daten der Operation. |\n| `callback` | `Function|String` | yes |  | Eine Funktion oder ein Path, die bzw. der die Antwort erhält. |\n| `scope` | `Object` | no | `window` | Das Objekt, in dem ein `callback`-Path aufgelöst wird. |\n\nFunktioniert wie [API()](../globals/), wobei die Adresse aus [DEF.api](../def/) stammt.\n\nExample: Eine Antwort in einem Path speichern\n```js\nDEF.api = '/admin/api/';\n\nTAPI('users_list', { page: 1 }, 'users.items');\n\nWATCH('users.items', function(value) {\n\tconsole.log(value.length); // 2\n});\n```\n\n### TEMP\n\nType: `property`\n\nEin Objekt für kurzlebige Daten.\n\nReturns: `Object` Der Container.\n\nDie Bibliothek ersetzt es jede Minute durch ein leeres Objekt.\n\nExample: Einen Wert speichern\n```js\nTEMP.result = 5;\nconsole.log(TEMP.result); // 5\n```\n\n### TOGGLE(path)\n\nType: `method`\n\nKehrt den booleschen Wert eines Paths um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nExample: Einen Wert umschalten\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### Total\n\nType: `property`\n\nDas Hauptobjekt der Bibliothek.\n\nReturns: `Object` Das Hauptobjekt.\n\nDasselbe Objekt wie [MAIN](../main/).\n\n### TRANSLATE(text)\n\nType: `method`\n\nErsetzt das `@(text)`-Markup durch Übersetzungen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Der Text mit dem Markup. |\n\nReturns: `String` Der übersetzte Text.\n\nText ohne Übersetzung bleibt in seiner Originalsprache. Übersetzungen werden mit [LOCALIZE()](../globals/) geladen.\n\nExample: Einen Text übersetzen\n```js\nLOCALIZE('T' + HASH('Yes').toString(36) + ' : Ano');\nconsole.log(TRANSLATE('@(Yes) / @(No)')); // Ano / No\n```\n\n### UNAUTHORIZED(...permissions)\n\nType: `method`\n\nPrüft die Berechtigungen des angemeldeten Benutzers.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `permissions` | `String` | yes |  | Eine oder mehrere Berechtigungen. |\n\nReturns: `Boolean` `true`, wenn der Zugriff verweigert wird.\n\nDie Methode liest die globale Variable `user`. Ein Benutzer, bei dem `sa` oder `su` gesetzt ist, hat alle Berechtigungen. Andernfalls stammen die Berechtigungen aus `user.permissions` oder `user.roles`, als Array oder Objekt. Das Ergebnis ist `true`, wenn der Benutzer keine der angegebenen Berechtigungen hat oder wenn `user` nicht existiert.\n\nExample: Eine Berechtigung prüfen\n```js\nwindow.user = { roles: ['editor'] };\n\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [callback])\n\nType: `method`\n\nEntfernt Watcher von einem Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. Mehrere Paths lassen sich mit `+` verbinden. |\n| `callback` | `Function` | no |  | Der zu entfernende Watcher. |\n\nOhne `callback` werden alle Watcher des Paths entfernt.\n\nExample: Die Beobachtung beenden\n```js\nvar count = 0;\nvar watcher = function() {\n\tcount++;\n};\n\nWATCH('form.name', watcher);\nSET('form.name', 'A');\nUNWATCH('form.name', watcher);\nSET('form.name', 'B');\nconsole.log(count); // 1\n```\n\n### UPD(path)\n\nType: `method`\n\nBenachrichtigt einen Path, nachdem sein Wert direkt geändert wurde.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit Flags. |\n\n`UPDATE()` ist dieselbe Funktion unter einem anderen Namen.\n\nExample: Nach einer direkten Änderung benachrichtigen\n```js\nwindow.form = { name: 'A' };\n\nWATCH('form.name', function(value) {\n\tconsole.log(value); // B\n});\n\nform.name = 'B';\nUPD('form.name');\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nPrüft die vertikale Position eines Elements relativ zum Viewport.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Das Element. |\n| `threshold` | `Number` | no | `0` | Die Anzahl der Pixel des Elements, die im Viewport liegen müssen. |\n| `mode` | `String` | no | `visible` | `visible`, `above` oder `below`. |\n\nReturns: `Boolean` Das Ergebnis der Prüfung.\n\nDer `mode` wählt die Prüfung aus: `visible` prüft, ob das Element im Viewport liegt, `above`, ob es darüber liegt, und `below`, ob es darunter liegt. Ein ausgeblendetes Element ergibt `false`.\n\nExample: Ein Element prüfen\n```html\n<div id=\"top\">Top</div>\n<div style=\"height:5000px\"></div>\n<div id=\"far\">Far</div>\n\n<script>\nconsole.log(VISIBLE($('#top'))); // true\nconsole.log(VISIBLE($('#far'))); // false\nconsole.log(VISIBLE($('#far'), 0, 'below')); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nEin kurzer Name für das Objekt `window`.\n\nReturns: `Object` Das Objekt `window`.\n\nExample: Die Objekte vergleichen\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback)\n\nType: `method`\n\nFührt eine Funktion aus, sobald eine Bedingung erfüllt ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | Eine Funktion oder ein Path. |\n| `callback` | `Function` | yes |  | Die auszuführende Funktion. |\n\nDie Bedingung wird sofort und dann alle 500 Millisekunden geprüft. Eine Funktion muss einen truthy Wert zurückgeben. Bei einem Path endet das Warten, sobald der Path einen truthy Wert enthält.\n\nExample: Auf einen Wert warten\n```js\nWAIT('app.config', function() {\n\tconsole.log(GET('app.config.name')); // Demo\n});\n\nsetTimeout(function() {\n\tSET('app.config', { name: 'Demo' });\n}, 100);\n```\n\n### WARN(...values)\n\nType: `method`\n\nGibt eine Warnung in der Browserkonsole aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `values` | `Object` | yes |  | Die auszugebenden Werte. |\n\n### WATCH(path, callback, [init])\n\nType: `method`\n\nBeobachtet Änderungen eines Paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `callback` | `Function` | yes |  | Eine Funktion, die `(value, flags, path)` erhält: den beobachteten Wert, die Flags und den geänderten Path. |\n| `init` | `Boolean` | no | `false` | Ruft den Watcher nach der Registrierung zusätzlich einmal auf. |\n\nEin Watcher läuft, wenn sich sein eigener Path, ein übergeordneter Path oder ein darunter verschachtelter Path ändert. Mehrere Paths lassen sich mit `+` verbinden.\n\nExample: Einen Path beobachten\n```js\nWATCH('user.name', function(value, flags, path) {\n\tconsole.log(value, path); // Peter user.name\n});\n\nSET('user.name', 'Peter');\n```\n\n### WH\n\nType: `property`\n\nDie Höhe des Fensters in Pixeln.\n\nReturns: `Number` Die Höhe.\n\nDer Wert wird beim Start der Bibliothek gesetzt und aktualisiert, wenn sich die Fenstergröße ändert.\n\nExample: Die Höhe lesen\n```js\nON('ready', function() {\n\tconsole.log(typeof(WH)); // number\n});\n```\n\n### WIDTH([element])\n\nType: `method`\n\nGibt den Namen der Gerätegröße für die Breite eines Elements zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | Das gemessene Element. |\n\nReturns: `String` Der Name der Größe.\n\nDie Größen `xs`, `sm`, `md` und `lg` sind in [DEF.devices](../def/) definiert.\n\nExample: Ein Element messen\n```html\n<div id=\"box\" style=\"width:800px\"></div>\n\n<script>\nconsole.log(WIDTH($('#box'))); // sm\n</script>\n```\n\n### WW\n\nType: `property`\n\nDie Breite des Fensters in Pixeln.\n\nReturns: `Number` Die Breite.\n\nDer Wert wird beim Start der Bibliothek gesetzt und aktualisiert, wenn sich die Fenstergröße ändert.\n\nExample: Die Breite lesen\n```js\nON('ready', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n","entries":[{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], callback, [onprogress], [scope], [id])","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(key, timeout, [callback])","since":"","deprecated":false},{"type":"method","name":"CACHE()","signature":"CACHE(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"CACHEPATH()","signature":"CACHEPATH(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, [callback])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [raw])","since":"","deprecated":false},{"type":"method","name":"CLRELOAD()","signature":"CLRELOAD(name, [callback])","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], callback, [dependencies], [css])","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"COMPONENTS(path)","since":"","deprecated":false},{"type":"method","name":"CONFIG()","signature":"CONFIG(selector, config)","since":"","deprecated":false},{"type":"property","name":"COOKIES","signature":"COOKIES","since":"","deprecated":false},{"type":"method","name":"COPY()","signature":"COPY(source, target)","since":"","deprecated":false},{"type":"method","name":"CSS()","signature":"CSS(value, [id], [selector])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(text, [key], [type])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"EMPTYARRAY","signature":"EMPTYARRAY","since":"","deprecated":false},{"type":"property","name":"EMPTYOBJECT","signature":"EMPTYOBJECT","since":"","deprecated":false},{"type":"method","name":"ENCRYPT()","signature":"ENCRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"method","name":"ENV()","signature":"ENV(name, [value])","since":"","deprecated":false},{"type":"method","name":"ENVIRONMENT()","signature":"ENVIRONMENT(name, [version], [language], [env])","since":"","deprecated":false},{"type":"method","name":"ERROR()","signature":"ERROR(response, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, callback)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], callback)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [all])","since":"","deprecated":false},{"type":"method","name":"FLAGS()","signature":"FLAGS(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(code)","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE()","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [noflags])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([length])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value)","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value])","since":"","deprecated":false},{"type":"method","name":"inDOM()","signature":"inDOM(element)","since":"","deprecated":false},{"type":"property","name":"isIE","signature":"isIE","since":"","deprecated":false},{"type":"property","name":"isMOBILE","signature":"isMOBILE","since":"","deprecated":false},{"type":"property","name":"isPRIVATEMODE","signature":"isPRIVATEMODE","since":"","deprecated":false},{"type":"property","name":"isROBOT","signature":"isROBOT","since":"","deprecated":false},{"type":"property","name":"isSTANDALONE","signature":"isSTANDALONE","since":"","deprecated":false},{"type":"property","name":"isTOUCH","signature":"isTOUCH","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"method","name":"LOCALIZE()","signature":"LOCALIZE(text)","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"method","name":"NEWUIBIND()","signature":"NEWUIBIND(element, [path], [config])","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, reference, [before])","since":"","deprecated":false},{"type":"method","name":"NODEMOVE()","signature":"NODEMOVE(element, [up])","since":"","deprecated":false},{"type":"method","name":"NOOP()","signature":"NOOP()","since":"","deprecated":false},{"type":"method","name":"NOTFOCUSED()","signature":"NOTFOCUSED()","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path)","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [callback])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value)","since":"","deprecated":false},{"type":"method","name":"PIPE()","signature":"PIPE(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [config], callback, [dependencies])","since":"","deprecated":false},{"type":"property","name":"PLUGINS","signature":"PLUGINS","since":"","deprecated":false},{"type":"property","name":"PREF","signature":"PREF","since":"","deprecated":false},{"type":"method","name":"PUSH()","signature":"PUSH(path, value)","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], data)","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path)","since":"","deprecated":false},{"type":"method","name":"SCROLLBAR()","signature":"SCROLLBAR(element, [options])","since":"","deprecated":false},{"type":"method","name":"SCROLLBARWIDTH()","signature":"SCROLLBARWIDTH()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, callback, timeout, [limit], [param])","since":"","deprecated":false},{"type":"method","name":"STRINGIFY()","signature":"STRINGIFY(value, [compress], [fields], [encrypt])","since":"","deprecated":false},{"type":"method","name":"STYLE()","signature":"STYLE(value, [id], [selector])","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path)","since":"","deprecated":false},{"type":"property","name":"Total","signature":"Total","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...permissions)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [callback])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path)","since":"","deprecated":false},{"type":"method","name":"VISIBLE()","signature":"VISIBLE(element, [threshold], [mode])","since":"","deprecated":false},{"type":"property","name":"W","signature":"W","since":"","deprecated":false},{"type":"method","name":"WAIT()","signature":"WAIT(condition, callback)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...values)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcS61wo61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/globals/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Funciones globales","summary":"Las funciones y variables que la biblioteca añade al objeto window.","markdown":"---\ntitle: Funciones globales\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/globals/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Funciones globales\n\n> Las funciones y variables que la biblioteca añade al objeto window.\n\nLa biblioteca añade estas funciones y variables a `window`, así que están disponibles en todo tu código. Empieza por [Paths](../../guides/paths/) y [Enlace de datos](../../guides/data-binding/) para ver cómo funcionan en conjunto.\n\n## API\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nPrepara un fragmento de HTML para un path y un identificador concretos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El valor de `~PATH~` y `CLASS`. Usa `null` para omitir estas sustituciones. |\n| `id` | `String` | yes |  | El valor de `~ID~`. Usa `null` para omitir esta sustitución. |\n| `text` | `String` | yes |  | El texto que se va a preparar. |\n\nReturns: `String` El texto preparado.\n\nEl método traduce el marcado `@(text)`, aplica las variables `--name--` y sustituye `~CDN~` por [DEF.cdn](../def/). Cuando se indica `path`, `~PATH~` y `CLASS` pasan a ser el path, los elementos `<ui-plugin>` sin atributo `path` lo reciben y el primer `PLUGIN(function(` se convierte en `PLUGIN('path', function(`. Cuando se indica `id`, `~ID~` pasa a ser el identificador. Un `text` vacío o que no sea una cadena se devuelve sin cambios.\n\nExample: Sustituir las palabras clave\n```js\nvar html = '<div class=\"CLASS\" data-id=\"~ID~\">~PATH~</div>';\nconsole.log(ADAPT('users', 'u1', html)); // <div class=\"users\" data-id=\"u1\">users</div>\n```\n\n### AJAX(url, [data], callback, [onprogress], [scope], [id])\n\nType: `method`\n\nEnvía una petición HTTP y entrega la respuesta a una función o a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | El método, la dirección y las palabras clave opcionales, por ejemplo `POST /api/users/ ERROR`. |\n| `data` | `Object` | no |  | El cuerpo de la petición: un objeto enviado como JSON, una cadena enviada como datos de formulario, o `FormData`. |\n| `callback` | `Function|String` | yes |  | Una función que recibe la respuesta, o un path que la recibe. |\n| `onprogress` | `Function|String` | no |  | Una función o un path que recibe el porcentaje de subida. |\n| `scope` | `Object` | no | `window` | El objeto en el que se resuelve un path de `callback`. |\n| `id` | `String` | no | `url` | La clave que usan `SYNC` y la caché. |\n\nLa `url` empieza por el método HTTP, seguido de la dirección y de palabras clave opcionales separadas por espacios:\n\n| Palabra clave | Significado |\n| --- | --- |\n| `ERROR` | Pasa la respuesta por [ERROR()](../globals/). Si contiene un error, se emite el evento `ERROR` y `callback` no se ejecuta. Un estado de error sin cuerpo de respuesta emite el evento `ERROR` con el código de estado. |\n| `SYNC` | Pone en cola las peticiones con el mismo `id`, para que se ejecuten una tras otra. |\n| `<1 minute>` | Guarda la respuesta en caché durante el tiempo indicado con [CACHE()](../globals/), salvo que sea un error. Mientras la petición está pendiente, las demás llamadas con el mismo `id` esperan a su respuesta, así que solo se envía una petición. |\n| `#name` | Carga primero la lista de códigos `name`. Consulta [CL()](../globals/). |\n| `@flag` | Emite el flag cuando se envía la petición. Consulta [Flags y modificadores de path](../../guides/flags/). |\n\nUn objeto en `data` se envía como JSON, una cadena se envía tal cual con el tipo de contenido `application/x-www-form-urlencoded` y `FormData` se envía como formulario.\n\nUn código de estado de 400 o superior cuenta como error. Una petición que no llega al servidor, se cancela o se queda sin tiempo tiene el código de estado `0`, y `callback` recibe una respuesta vacía. Una respuesta con un tipo de contenido JSON se analiza con [PARSE()](../globals/). Cada petición añade las cabeceras de [DEF.headers](../def/). Si [DEF.language](../def/) está definido, se añade a la cadena de consulta. Si [DEF.version](../def/) está definido, se añade a la cadena de consulta de las direcciones `.html`.\n\nLos [eventos](../events/) `request` y `response` te permiten inspeccionar o cambiar cada llamada. Una vez enviada la petición, `options.xhr` en el evento `request` contiene su `XMLHttpRequest`, así que `options.xhr.abort()` la detiene. `UPLOAD()` es la misma función con otro nombre.\n\nExample: Leer una respuesta\n```js\nAJAX('GET /api/users/', function(response) {\n\tconsole.log(response.length); // 2\n});\n```\n\nExample: Guardar una respuesta en un path\n```js\nAJAX('POST /api/orders/', { amount: 10 }, 'orders.last');\n\nWATCH('orders.last', function(value) {\n\tconsole.log(value.id); // 100\n});\n```\n\nExample: Enviar datos de formulario\n```js\nAJAX('POST /api/login/', 'name=Ann&remember=1', function(response) {\n\tconsole.log(response.ok); // true\n});\n```\n\nExample: Detener una petición\n```js\nvar request;\n\nON('request', options => request = options);\nON('ERROR', status => console.log('failed', status)); // failed 0\n\nAJAX('GET /api/report/ ERROR', NOOP);\nrequest.xhr.abort();\n```\n\n### API(url, name, [data], callback, [scope])\n\nType: `method`\n\nLlama a un endpoint de la API de Total.js en una dirección concreta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La dirección del endpoint. |\n| `name` | `String` | yes |  | El nombre de la operación, seguido opcionalmente de palabras clave. |\n| `data` | `Object` | no |  | Los datos de la operación. |\n| `callback` | `Function|String` | yes |  | Una función o un path que recibe la respuesta. |\n| `scope` | `Object` | no | `window` | El objeto en el que se resuelve un path de `callback`. |\n\nEl método envía `POST url` con el cuerpo JSON `{ schema: name, data: data }`. Detrás del nombre pueden ir las palabras clave que acepta [AJAX()](../globals/), por ejemplo `users_list ERROR`. Para usar una dirección fija, consulta [TAPI()](../globals/) y [PIPE()](../globals/).\n\nExample: Llamar a una operación\n```js\nAPI('/admin/api/', 'users_read', { id: 5 }, function(response) {\n\tconsole.log(response.name); // Peter\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nEstablece el esquema de colores de la página mediante variables CSS y clases del body.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Los interruptores y las variables CSS. |\n\nCada clave se convierte en una variable CSS de `:root`, salvo los cuatro interruptores siguientes. La clave `color` también actualiza [DEF.color](../def/) y añade la variable `--rgb` con los valores de rojo, verde y azul de un color hexadecimal de tres o seis dígitos.\n\n| Clave | Significado |\n| --- | --- |\n| `dark` o `darkmode` | Alterna la clase `ui-dark` en el body. |\n| `large` o `largemode` | Alterna la clase `ui-large` en el body. |\n\nEl prefijo de la clase viene de [DEF.prefixcsslibrary](../def/).\n\nExample: Tema oscuro con un color de acento\n```js\nAPPEARANCE({ dark: true, color: '#4285F4' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#4285F4;--rgb:66,133,244}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\nExample: Un color corto\n```js\nAPPEARANCE({ color: '#abc' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#abc;--rgb:170,187,204}\n```\n\n### ASETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nCrea una función que llama más tarde a un método de un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El selector y el método, con la misma forma que en `SETTER()`. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nReturns: `Function` Una función sin argumentos.\n\nCada llamada a la función devuelta ejecuta [SETTER()](../globals/) con los argumentos indicados aquí.\n\nExample: Preparar una llamada\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log('added', value); // added 5\n\t};\n});\n\nON('ready', function() {\n\tvar add = ASETTER('counter/add', 5);\n\tadd();\n});\n</script>\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nLee un atributo `data-*` de un elemento o de su padre más cercano que lo tenga.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Event|Element|Object` | yes |  | El punto de partida. |\n| `name` | `String` | no | `id` | El nombre del atributo sin el prefijo `data-`. |\n\nReturns: `String` El valor del atributo.\n\nEl `element` puede ser un objeto jQuery, un evento jQuery (se usa su `currentTarget`) o un elemento DOM. Si es un objeto normal, el método devuelve la propiedad `name`. Cualquier otro valor se devuelve tal cual.\n\nExample: Leer el identificador más cercano\n```html\n<div data-id=\"15\" data-type=\"user\"><button id=\"save\">Save</button></div>\n\n<script>\nvar button = $('#save');\nconsole.log(ATTRD(button)); // 15\nconsole.log(ATTRD(button, 'type')); // user\nconsole.log(ATTRD({ id: 20 })); // 20\n</script>\n```\n\n### BLOCKED(key, timeout, [callback])\n\nType: `method`\n\nLimita la frecuencia con la que puede ejecutarse una operación.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | El nombre de la operación. |\n| `timeout` | `Number|String` | yes |  | El tiempo en milisegundos, o un texto como `5 minutes`. |\n| `callback` | `Function` | no |  | Una función que se ejecuta cuando la operación no está bloqueada. |\n\nReturns: `Boolean` `true` cuando la operación está bloqueada.\n\nLa primera llamada bloquea `key` durante el tiempo indicado y devuelve `false`. Las llamadas siguientes devuelven `true` hasta que pasa ese tiempo. Un bloqueo de 10 segundos o más se guarda en `localStorage`, así que sobrevive a una recarga de la página.\n\nExample: Permitir un clic por segundo\n```js\nON('ready', function() {\n\tconsole.log(BLOCKED('save', 1000)); // false\n\tconsole.log(BLOCKED('save', 1000)); // true\n});\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nLee o escribe un valor en la caché persistente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clave. |\n| `value` | `Object` | no |  | El valor que se va a guardar. |\n| `expire` | `String` | no |  | La duración del valor, o `session`. |\n\nReturns: `Object` El valor guardado al leer; en otro caso, nada.\n\nCon `expire`, el método guarda el valor. Sin él, devuelve el valor guardado, o `null` si no existe o ha caducado. El valor `session` mantiene los datos en memoria hasta que se cierra la página. Cualquier otro valor es un tiempo como `10 minutes`, `2 hours`, `1 day`, `1 week`, `1 month` o `1 year`, y los datos se guardan mediante [DEF.onstoragesave](../def/).\n\nLa caché se carga cuando arranca la biblioteca, así que úsala a partir del [evento](../events/) `ready`.\n\nExample: Escribir y leer\n```js\nON('ready', function() {\n\tCACHE('filter', { page: 2 }, '1 day');\n\tconsole.log(CACHE('filter')); // {\"page\":2}\n\tconsole.log(CACHE('missing')); // null\n});\n```\n\n### CACHEPATH(path, expire, [def])\n\nType: `method`\n\nConserva el valor de un path en la caché entre visitas.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `expire` | `String` | yes |  | La duración del valor guardado, por ejemplo `1 day`. |\n| `def` | `Object|Function` | no |  | El valor que se usa cuando no hay nada guardado. Si es una función, se llama para obtenerlo. |\n\nEl método guarda cada cambio del path con [CACHE()](../globals/) durante el tiempo indicado en `expire`. Cuando el path está vacío, se escribe en él el valor guardado y, si no hay nada guardado, se escribe `def`. Un path que ya contiene un valor lo conserva.\n\nSi lo llamas antes de que la biblioteca haya cargado la caché, el método la espera y después restaura el valor. Los plugins tienen el mismo método con un path relativo: [plugin.cachepath()](../plugin/).\n\nExample: Recordar un filtro\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n\nSET('filter.q', 'lamp');\n// After a reload of the page, GET('filter.q') returns lamp\n```\n\n### CL(name, [callback])\n\nType: `method`\n\nCarga las listas de códigos registradas con `CLINIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Un nombre, o varios nombres separados por comas. |\n| `callback` | `Function` | no |  | Una función que se ejecuta cuando se han cargado las listas. |\n\nUna lista de códigos son datos compartidos, como una lista de países, guardados en [DEF.cl](../def/). Una lista se carga una sola vez. El `callback` se ejecuta cuando todas las listas están disponibles. Un nombre que aún no está registrado se vuelve a comprobar cada 500 milisegundos hasta que aparece.\n\nExample: Cargar una lista bajo demanda\n```js\nCLINIT('countries', function(next) {\n\tnext([{ id: 'SK', name: 'Slovakia' }]);\n});\n\nON('ready', function() {\n\tCL('countries', function() {\n\t\tconsole.log(DEF.cl.countries.length); // 1\n\t});\n});\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nCancela un temporizador creado con `setTimeout2()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del temporizador. |\n\nReturns: `Boolean` `true` cuando el temporizador existe.\n\nExample: Cancelar un temporizador\n```js\nsetTimeout2('search', NOOP, 1000);\nconsole.log(clearTimeout2('search')); // true\nconsole.log(clearTimeout2('unknown')); // false\n```\n\n### CLINIT(name, source, [init])\n\nType: `method`\n\nRegistra el origen de una lista de códigos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la lista de códigos. |\n| `source` | `Function|String` | yes |  | Una función, una petición o una operación. |\n| `init` | `Boolean` | no | `false` | Carga la lista de inmediato. |\n\nCuando `source` es una función, recibe `next(value, [extend])`. Pasa la lista a `next()`. Con `extend` a `true`, `value` es un objeto cuyas claves se guardan como listas de códigos independientes.\n\nCuando `source` es una cadena, un valor que empieza por un método HTTP se carga con [AJAX()](../globals/). Cualquier otro valor es una operación para [TAPI()](../globals/).\n\nExample: Cargar varias listas a la vez\n```js\nCLINIT('all', function(next) {\n\tnext({ colors: ['red'], sizes: ['XL'] }, true);\n}, true);\n\nON('ready', function() {\n\tsetTimeout(function() {\n\t\tconsole.log(DEF.cl.colors, DEF.cl.sizes); // [\"red\"] [\"XL\"]\n\t}, 100);\n});\n```\n\n### CLONE(value, [raw])\n\nType: `method`\n\nCrea una copia profunda de un valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|String` | yes |  | El valor que se va a copiar, o un path. |\n| `raw` | `Boolean` | no | `false` | Trata una cadena como un valor normal. |\n\nReturns: `Object` La copia.\n\nUna cadena se trata como un path a un objeto o un array, y se copia el valor que haya allí. Con `raw` a `true`, la cadena se devuelve tal cual. Los objetos se copian mediante JSON, y las fechas que contienen siguen siendo fechas.\n\nExample: Copiar un objeto\n```js\nvar a = { user: { name: 'Peter' } };\nvar b = CLONE(a);\nb.user.name = 'Lucia';\nconsole.log(a.user.name); // Peter\n```\n\nExample: Copiar el valor de un path\n```js\nSET('form', { name: 'Peter' });\nvar copy = CLONE('form');\nconsole.log(copy); // {\"name\":\"Peter\"}\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nVuelve a cargar las listas de códigos desde sus orígenes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Un nombre, o varios nombres separados por comas. |\n| `callback` | `Function` | no |  | Una función que se ejecuta cuando se han recargado las listas. |\n\nSolo se recargan las listas que ya están cargadas. Los demás nombres se omiten.\n\nExample: Actualizar una lista\n```js\nvar counter = 0;\n\nCLINIT('stats', function(next) {\n\tnext([++counter]);\n});\n\nON('ready', function() {\n\tCL('stats', function() {\n\t\tCLRELOAD('stats', function() {\n\t\t\tconsole.log(DEF.cl.stats); // [2]\n\t\t});\n\t});\n});\n```\n\n### CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nEjecuta un comando en todos los componentes que lo registran.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El comando, opcionalmente seguido de flags. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nLos componentes registran comandos con [command()](../component/). Después del nombre pueden ir flags separados por un espacio, por ejemplo `CMD('refresh @saved')`: se emiten primero, como con [SET()](../globals/). Para ejecutar un comando solo en una parte de la página, usa [$(selector).CMD()](../jquery/) o [plugin.cmd()](../plugin/).\n\nExample: Vaciar todas las listas\n```html\n<ui-component name=\"list\"></ui-component>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nvar count = 0;\n\nCOMPONENT('list', function(self) {\n\tself.command('clear', value => count += value);\n});\n\nON('ready', function() {\n\tCMD('clear', 1);\n\tconsole.log(count); // 2\n});\n</script>\n```\n\n### COMPONENT(name, [config], callback, [dependencies], [css])\n\nType: `method`\n\nRegistra la declaración de un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del componente. |\n| `config` | `String` | no |  | La configuración predeterminada con la forma `key:value;key:value`. |\n| `callback` | `Function` | yes |  | La declaración: `function(self, config, cls)`. |\n| `dependencies` | `String|Array` | no |  | Direcciones que se importan primero, separadas por comas. Un array también puede contener funciones que reciben `next`. |\n| `css` | `String` | no |  | Los estilos del componente. |\n\nEl `callback` se ejecuta una vez por cada instancia y recibe la instancia, su configuración y su clase CSS. En el argumento `css`, la palabra `CLASS` se convierte en `ui-` seguido del nombre del componente. Consulta [Crear componentes](../../guides/creating-components/) y el objeto [Component](../component/).\n\nExample: Declarar un componente\n```html\n<ui-component name=\"hello\"></ui-component>\n\n<script>\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.element.aclass(cls).html('Hello ' + config.name);\n\t\tconsole.log(self.element.html()); // Hello World\n\t};\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nDevuelve los componentes enlazados a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con flags. |\n\nReturns: `Array` Las instancias de [componente](../component/) que coinciden.\n\nEl path incluye todo lo que hay por debajo, así que `form` también devuelve un componente enlazado a `form.name`. Los flags del path acotan el resultado: `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` y `@enabled`.\n\nExample: Encontrar los campos obligatorios\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.setter = NOOP;\n});\n\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tconsole.log(COMPONENTS('form @required').length); // 1\n});\n</script>\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nCambia la configuración de los componentes existentes y futuros.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | Los componentes que se van a configurar. |\n| `config` | `String|Object` | yes |  | La configuración, como objeto o con la forma `key:value;key:value`. |\n\nEl `selector` puede ser:\n\n| Selector | Coincide con |\n| --- | --- |\n| `name` | Los componentes con este nombre. |\n| `#id` | El componente con este identificador. |\n| `.path` | Los componentes cuyo path contiene `path`. |\n| `*` | Todos los componentes. |\n| `a, b` | Varios selectores separados por comas. |\n| `function(instance)` | Los componentes para los que la función devuelve `true`. |\n\nExample: Configurar por nombre\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tCONFIG('box', 'color:red;size:10');\n\tconsole.log(FIND('box').config.size); // 10\n});\n</script>\n```\n\n### COOKIES\n\nType: `property`\n\nLee y escribe cookies del navegador.\n\nReturns: `Object` El objeto con los métodos.\n\nEl objeto tiene tres métodos:\n\n| Método | Descripción |\n| --- | --- |\n| `COOKIES.get(name)` | Devuelve el valor, o una cadena vacía. |\n| `COOKIES.set(name, value, [expire], [samesite])` | Escribe una cookie para la ruta `/`. `expire` es un número de días, un `Date` o un texto como `1 day`. Sin `expire`, la cookie se conserva hasta que se cierra el navegador. `samesite` es, por ejemplo, `lax`. |\n| `COOKIES.rem(name)` | Elimina la cookie. |\n\nExample: Escribir y leer una cookie\n```js\nCOOKIES.set('theme', 'dark', '1 month', 'lax');\nconsole.log(COOKIES.get('theme')); // dark\n```\n\nExample: Conservar una cookie durante una semana\n```js\nCOOKIES.set('token', 'a=1', 7);\nconsole.log(COOKIES.get('token')); // a=1\n```\n\n### COPY(source, target)\n\nType: `method`\n\nCopia las propiedades de un objeto en otro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | El objeto del que se lee. |\n| `target` | `Object` | yes |  | El objeto en el que se escribe. |\n\nReturns: `Object` El objeto `target`.\n\nLos objetos anidados se clonan, así que los cambios posteriores en `source` no afectan a `target`.\n\nExample: Combinar dos objetos\n```js\nvar target = { a: 1 };\nCOPY({ b: { c: 2 } }, target);\nconsole.log(target); // {\"a\":1,\"b\":{\"c\":2}}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nOtro nombre de `STYLE()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | El CSS. |\n| `id` | `String` | no |  | El identificador del elemento de estilo. |\n| `selector` | `String` | no |  | Un selector que se antepone a cada regla. |\n\nConsulta [STYLE()](../globals/). Si estableces `window.jc_globals = { CSS: false }` antes del script de la biblioteca, esta variable global queda sin definir.\n\n### DAYS\n\nType: `property`\n\nLos nombres en inglés de los días de la semana, empezando por el domingo.\n\nReturns: `Array` Siete cadenas.\n\nExample: Leer un día\n```js\nconsole.log(DAYS[1]); // Monday\n```\n\n### DEF\n\nType: `property`\n\nLa configuración predeterminada de la biblioteca.\n\nReturns: `Object` La configuración.\n\nSe describe en su propia página: [DEF](../def/).\n\n### DECRYPT(text, [key], [type])\n\nType: `method`\n\nLee un valor escrito por `ENCRYPT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | El texto de `ENCRYPT()`. |\n| `key` | `String` | no |  | La clave. |\n| `type` | `String` | no |  | El prefijo del texto. |\n\nReturns: `Object` El valor, o `undefined`.\n\nLa `key` y el `type` deben ser los que se pasaron a [ENCRYPT()](../globals/). El método devuelve `undefined` cuando la suma de comprobación no coincide con ellos, que es lo que pasa con un texto modificado. Un valor que empieza por `[`, `{` o `\"` se analiza como JSON.\n\nExample: Volver a leer un objeto\n```js\nvar text = ENCRYPT({ id: 5 }, 'secret', 'U');\n\nconsole.log(text.charAt(0)); // U\nconsole.log(DECRYPT(text, 'secret', 'U')); // {\"id\":5}\nconsole.log(DECRYPT(text, 'secret')); // undefined\n```\n\n### DIFFDOM(element, selector, html, [attribute])\n\nType: `method`\n\nActualiza los hijos de un elemento para que coincidan con un HTML nuevo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | El elemento padre. |\n| `selector` | `String` | yes |  | Un selector de los hijos que se comparan. |\n| `html` | `String` | yes |  | El contenido nuevo. |\n| `attribute` | `String` | no |  | El atributo que se usa para la comparación. |\n\nReturns: `Object` El número de elementos añadidos, conservados y eliminados: `{ add, upd, rem }`.\n\nLos hijos que no han cambiado permanecen en el DOM, así que conservan su estado. Los hijos se comparan por todo su HTML, o por el valor de `attribute` cuando se indica.\n\nExample: Actualizar una lista\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n\n<script>\nvar list = $('#list');\nvar result = DIFFDOM(list, 'li', '<li>A</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log(list.html()); // <li>A</li><li>C</li>\n</script>\n```\n\n### EMIT(name, [a], [b], [c], [d])\n\nType: `method`\n\nEmite un evento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nLos manejadores registrados con [ON()](../globals/), y los registrados en [componentes](../component/) y [plugins](../plugin/), reciben los argumentos. Detrás del nombre pueden ir flags, por ejemplo `refresh @loading`. Los eventos de la biblioteca aparecen en [Eventos](../events/).\n\nExample: Emitir un evento personalizado\n```js\nON('saved', function(id, name) {\n\tconsole.log(id, name); // 5 Peter\n});\n\nEMIT('saved', 5, 'Peter');\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nUn array vacío congelado.\n\nReturns: `Array` Un array que no se puede cambiar.\n\nExample: Un valor predeterminado compartido\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nUn objeto vacío congelado.\n\nReturns: `Object` Un objeto que no se puede cambiar.\n\nExample: Un valor predeterminado compartido\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nCodifica un valor como texto con una suma de comprobación.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | El valor. |\n| `key` | `String` | no |  | La clave de la suma de comprobación. |\n| `type` | `String` | no |  | Un prefijo que se escribe al principio del texto. |\n\nReturns: `String` El texto codificado.\n\nUn objeto o un array se serializa primero con [STRINGIFY()](../globals/). El resultado tiene el `type` como prefijo, el valor en dígitos hexadecimales, la letra `x` y una suma de comprobación creada con [HASH()](../globals/) a partir del valor, la `key` y el `type`.\n\nCualquiera puede volver a leer el valor, así que no uses el método para ocultar datos: la clave solo permite a [DECRYPT()](../globals/) saber si el texto se ha modificado.\n\nExample: Codificar y decodificar\n```js\nvar text = ENCRYPT('hello', 'secret');\n\nconsole.log(text); // 68656c6c6fxds46dr\nconsole.log(DECRYPT(text, 'secret')); // hello\nconsole.log(DECRYPT(text, 'other')); // undefined\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nLee o escribe variables de entorno.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | El nombre, o un objeto con nombres y valores. |\n| `value` | `Object` | no |  | El valor que se va a escribir. |\n\nReturns: `Object` El valor de la variable.\n\nLas variables se guardan en [DEF.env](../def/). Un texto puede referirse a ellas como `[name]`: los paths, las direcciones y los valores de configuración sustituyen esta notación por el valor. Pasa un objeto para escribir varias variables. Cada escritura emite el [evento](../events/) `env`.\n\nExample: Usar una variable en un texto\n```js\nENV('api', '/api/v1/');\nconsole.log(ENV('api')); // /api/v1/\nconsole.log('[api]users/'.env()); // /api/v1/users/\n```\n\n### ENVIRONMENT(name, [version], [language], [env])\n\nType: `method`\n\nEstablece la clave de almacenamiento, la versión, el idioma y las variables de entorno de la aplicación.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La clave que se usa en `localStorage`. |\n| `version` | `String` | no |  | La versión de la aplicación. |\n| `language` | `String` | no |  | El idioma de la aplicación. |\n| `env` | `Object` | no |  | Variables de entorno. |\n\nEl método asigna [DEF.localstorage](../def/), [DEF.version](../def/) y [DEF.language](../def/), y pasa `env` a [ENV()](../globals/). Llámalo justo después del script de la biblioteca, para que la aplicación lea su propio almacenamiento.\n\nExample: Configurar una aplicación\n```js\nENVIRONMENT('myapp', '1.0', 'en', { title: 'My app' });\n\nconsole.log(DEF.localstorage, DEF.version, DEF.language); // myapp 1.0 en\nconsole.log(ENV('title')); // My app\n```\n\n### ERROR(response, [success], [error])\n\nType: `method`\n\nComprueba si una respuesta contiene errores y ejecuta el manejador correspondiente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | La respuesta que se va a comprobar. |\n| `success` | `Function|String` | no |  | Se ejecuta cuando no hay ningún error. |\n| `error` | `Function|String` | no |  | Se ejecuta cuando hay un error. |\n\nReturns: `Boolean` `true` cuando la respuesta contiene un error.\n\nUna respuesta es un error cuando es un objeto `Error`, tiene una propiedad `error` o es un array cuyo primer elemento la tiene. Un error emite el [evento](../events/) `ERROR`.\n\n`success` y `error` pueden ser funciones, o nombres para [SEEX()](../globals/).\n\nLlama a `ERROR(success, [error])` sin una respuesta para crear una función que puedas pasar como callback.\n\nExample: Comprobar una respuesta\n```js\nconsole.log(ERROR({ id: 1 })); // false\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\n```\n\nExample: Crear un callback\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 1\n});\n\ncallback({ id: 1 });\n```\n\n### ERRORS(path, callback)\n\nType: `method`\n\nDevuelve los componentes no válidos de un path o de un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|jQuery` | yes |  | Un path, o un elemento que contiene los componentes. |\n| `callback` | `Function` | yes |  | Una función que recibe un array de [componentes](../component/). |\n\nExample: Validar un formulario\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.validate = function(value) {\n\t\treturn !!value;\n\t};\n});\n\nON('ready', function() {\n\tERRORS('form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a una función por su nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El destino de la llamada. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nLa forma de `name` decide a qué se llama:\n\n| Nombre | Llama a |\n| --- | --- |\n| `name` | Una función global. |\n| `FUNC.name` | Una función situada en un path. |\n| `plugin/method` | Un método de un [plugin](../plugin/). |\n| `*/method` | Un método del plugin common. |\n| `-component/method` | Un método de un componente, mediante [SETTER()](../globals/). |\n| `#event` | Un evento, mediante [EMIT()](../globals/). |\n\nAñade el flag `@important` para reintentarlo cada 500 milisegundos hasta que exista la función, por ejemplo `EXEC('app/refresh @important')`. `EXE()` es la misma función con otro nombre.\n\nExample: Llamar a una función por su path\n```js\nFUNC.sum = function(a, b) {\n\tconsole.log(a + b); // 5\n};\n\nEXEC('FUNC.sum', 2, 3);\n```\n\nExample: Esperar a una función\n```js\nEXEC('app.start @important', 'now');\n\nsetTimeout(function() {\n\twindow.app = {};\n\tapp.start = function(value) {\n\t\tconsole.log(value); // now\n\t};\n}, 100);\n```\n\n### EXTENSION(name, [config], callback)\n\nType: `method`\n\nAmplía un componente o un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del componente, o `@` seguido del nombre del plugin. |\n| `config` | `String|Object` | no |  | Configuración que se añade a cada instancia. |\n| `callback` | `Function` | yes |  | Una función `(instance, config, cls)`, donde `cls` es la clase CSS de la instancia. `this` es la instancia. |\n\nEl `callback` se ejecuta para cada instancia existente y para cada instancia nueva, justo después de la declaración, siempre con los mismos argumentos. En el caso de un plugin, escribe `@` delante de su nombre.\n\nExample: Añadir un método a un componente\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nEXTENSION('box', 'color:red', function(self, config) {\n\tself.describe = function() {\n\t\treturn config.color;\n\t};\n});\n\nON('ready', function() {\n\tconsole.log(FIND('box').describe()); // red\n});\n</script>\n```\n\n### FIND(selector, [all])\n\nType: `method`\n\nEncuentra un componente que esté listo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | El nombre, el identificador o el path. |\n| `all` | `Boolean` | no | `false` | Devuelve todas las coincidencias en un array. |\n\nReturns: `Component|Array` El primer [componente](../component/), o un array cuando `all` es `true`.\n\nEl `selector` es un nombre de componente, `#id` para un identificador o `.path` para un path.\n\nExample: Buscar por nombre y por path\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('field').name); // field\n\tconsole.log(FIND('.form.name').path.path); // form.name\n\tconsole.log(FIND('field', true).length); // 1\n});\n</script>\n```\n\n### FLAGS(flags, [callback])\n\nType: `method`\n\nEmite flags y después ejecuta una función.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Los flags, por ejemplo `@loading @save`. |\n| `callback` | `Function` | no |  | Una función que se ejecuta después. |\n\nCada flag emite el evento `@flag name`, que puedes capturar con [ON()](../globals/). Consulta [Flags y modificadores de path](../../guides/flags/).\n\nExample: Capturar un flag\n```js\nON('@flag loading', function() {\n\tconsole.log('flag captured'); // flag captured\n});\n\nFLAGS('@loading', function() {\n\tconsole.log('done'); // done\n});\n```\n\n### FN(code)\n\nType: `method`\n\nCompila una función flecha a partir de una cadena.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | yes |  | El código de la función. |\n\nReturns: `Function` La función compilada.\n\nEl código puede tener hasta cuatro argumentos. El código sin flecha se convierte en una función con el argumento `value`. Las funciones compiladas se guardan en caché.\n\nExample: Compilar funciones\n```js\nconsole.log(FN('n => n * 2')(4)); // 8\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value + 1')(1)); // 2\n```\n\n### FREE()\n\nType: `method`\n\nElimina los componentes, enlaces y plugins cuyos elementos han salido del DOM.\n\nLa biblioteca ejecuta esta limpieza cada minuto. Llámala cuando necesites que las instancias se eliminen de inmediato.\n\nExample: Eliminar un componente desconectado\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\t$('ui-component').remove();\n\tFREE();\n\tconsole.log(COMPONENTS('form').length); // 0\n});\n</script>\n```\n\n### FUNC\n\nType: `property`\n\nUn objeto vacío para las funciones de tu aplicación.\n\nReturns: `Object` El contenedor.\n\nLas funciones guardadas aquí se pueden llamar por su path con [EXEC()](../globals/).\n\nExample: Guardar una función\n```js\nFUNC.hello = function() {\n\treturn 'Hello';\n};\n\nconsole.log(FUNC.hello()); // Hello\n```\n\n### GET(path, [noflags])\n\nType: `method`\n\nLee el valor de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con flags. |\n| `noflags` | `Boolean` | no | `false` | Lee el valor sin aplicar los flags. |\n\nReturns: `Object` El valor.\n\nCuando el path contiene flags, se aplican a los componentes del path: `GET('form @reset')` devuelve el valor y restablece su estado. Consulta [Paths](../../guides/paths/).\n\nExample: Leer valores\n```js\nSET('user.name', 'Peter');\n\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\n### GUID([length])\n\nType: `method`\n\nGenera un identificador aleatorio.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | no |  | La longitud del identificador. |\n\nReturns: `String` El identificador.\n\nSin `length`, el resultado tiene la forma de un UUID de 36 caracteres. Con `length`, es una cadena de letras minúsculas y dígitos.\n\nExample: Generar identificadores\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value)\n\nType: `method`\n\nCrea un hash numérico de un valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Number|Boolean|Object|Date` | yes |  | El valor. |\n\nReturns: `Number` El hash.\n\nUn número se devuelve tal cual, `true` da `1`, una fecha da su tiempo en milisegundos y un valor vacío da `0`. Los objetos se serializan primero.\n\nExample: Calcular el hash de una cadena\n```js\nconsole.log(HASH('hello')); // 99162322\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nComprueba si un elemento anidado en la página está oculto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Un elemento situado dentro de otro elemento del body. |\n\nReturns: `Boolean` `true` cuando el elemento está oculto.\n\nEl elemento se considera oculto cuando no tiene un padre de desplazamiento (offset parent), como ocurre con `display:none`. Un elemento que no existe también se considera oculto. Para comprobar la posición en el viewport, usa [VISIBLE()](../globals/).\n\nExample: Comprobar un elemento\n```html\n<main><div id=\"a\" style=\"display:none\"></div><div id=\"b\"></div></main>\n\n<script>\nconsole.log(HIDDEN($('#a'))); // true\nconsole.log(HIDDEN($('#b'))); // false\n</script>\n```\n\n### IMPORT(url, [target], [callback], [prepare])\n\nType: `method`\n\nCarga un script, una hoja de estilos o un fragmento de HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La dirección y las palabras clave opcionales. |\n| `target` | `String|jQuery|Element` | no | `body` | El elemento que recibe el contenido HTML. |\n| `callback` | `Function` | no |  | Una función que se ejecuta cuando se ha cargado el contenido. |\n| `prepare` | `Function` | no |  | Una función que recibe el HTML y devuelve el texto que se va a insertar. |\n\nLas direcciones que terminan en `.js` o `.css` se añaden al head de la página. Cualquier otra dirección se descarga y se inserta en `target`. La dirección se puede combinar con palabras clave:\n\n| Palabra clave | Significado |\n| --- | --- |\n| `<name>` | Omite la importación cuando existe la variable global `name`. |\n| `.js`, `.css`, `.html` | Establece el tipo del contenido cuando la dirección no lo indica. |\n| `@singleton` | Importa la dirección una sola vez. |\n| `@prepend` | Inserta el contenido al principio de `target`. |\n\nSi un script o una hoja de estilos no se pueden cargar, la biblioteca escribe un aviso en la consola y `callback` se ejecuta igualmente.\n\nConsulta [Importar contenido](../../guides/importing/).\n\nExample: Insertar un fragmento de HTML\n```html\n<div id=\"menu\"></div>\n\n<script>\nIMPORT('/parts/menu.html', '#menu', function() {\n\tconsole.log($('#menu').html()); // <b>Menu</b>\n});\n</script>\n```\n\nExample: Omitir una biblioteca que ya existe\n```js\nIMPORT('<jQuery> /js/jquery.min.js', function() {\n\tconsole.log('jQuery is available'); // jQuery is available\n});\n```\n\n### INC(path, [value])\n\nType: `method`\n\nAumenta el número guardado en un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `value` | `Number` | no | `1` | La cantidad que se va a sumar. |\n\nUn path vacío empieza en `0`. Una cadena se convierte en número. Usa un `value` negativo para reducir el número.\n\nExample: Aumentar un contador\n```js\nSET('stats.visits', 10);\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 16\n```\n\n### inDOM(element)\n\nType: `method`\n\nComprueba si un elemento está conectado al body del documento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | Un elemento DOM. |\n\nReturns: `Boolean` `true` cuando el elemento está conectado; en otro caso, nada.\n\nExample: Comprobar un elemento\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(!!inDOM(document.createElement('div'))); // false\n```\n\n### isIE\n\nType: `property`\n\nIndica si el navegador es Internet Explorer.\n\nReturns: `Boolean` El resultado de la detección.\n\n### isMOBILE\n\nType: `property`\n\nIndica si el agente de usuario pertenece a un dispositivo móvil.\n\nReturns: `Boolean` El resultado de la detección.\n\n### isPRIVATEMODE\n\nType: `property`\n\nIndica si `localStorage` no está disponible, como ocurre en algunas ventanas privadas. El valor se establece mientras arranca la biblioteca, así que léelo a partir del evento `ready`.\n\nReturns: `Boolean` El resultado de la detección.\n\n### isROBOT\n\nType: `property`\n\nIndica si el agente de usuario pertenece a un motor de búsqueda o a un rastreador.\n\nReturns: `Boolean` El resultado de la detección.\n\n### isSTANDALONE\n\nType: `property`\n\nIndica si la página se ejecuta como una aplicación web instalada.\n\nReturns: `Boolean` El resultado de la detección.\n\n### isTOUCH\n\nType: `property`\n\nIndica si el dispositivo admite la entrada táctil.\n\nReturns: `Boolean` El resultado de la detección.\n\n### jComponent\n\nType: `property`\n\nEl objeto principal de la biblioteca.\n\nReturns: `Object` El objeto principal.\n\nEl mismo objeto que [MAIN](../main/).\n\n### LOCALIZE(text)\n\nType: `method`\n\nCarga traducciones en el diccionario.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Las líneas con las traducciones. |\n\nCada línea tiene la forma `key : translation`, y las líneas que empiezan por `//` se omiten. La clave es el hash del texto original, en base 36, con el prefijo `T`. Las traducciones se guardan en [DEF.dictionary](../def/) y las usa [TRANSLATE()](../globals/). Consulta [Localización](../../guides/localization/).\n\nExample: Cargar una traducción\n```js\nvar key = 'T' + HASH('Hello').toString(36);\n\nLOCALIZE(key + ' : Hola');\nconsole.log(TRANSLATE('@(Hello)')); // Hola\n```\n\n### M\n\nType: `property`\n\nUn nombre corto del objeto principal.\n\nReturns: `Object` El objeto principal.\n\nEl mismo objeto que [MAIN](../main/).\n\n### MAIN\n\nType: `property`\n\nEl objeto principal de la biblioteca.\n\nReturns: `Object` El objeto principal.\n\nSe describe en su propia página: [MAIN](../main/).\n\n### MONTHS\n\nType: `property`\n\nLos nombres en inglés de los meses, empezando por enero.\n\nReturns: `Array` Doce cadenas.\n\nExample: Leer un mes\n```js\nconsole.log(MONTHS[0]); // January\n```\n\n### NEWUIBIND(element, [path], [config])\n\nType: `method`\n\nCrea un enlace de datos en un elemento desde el código.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | El elemento. |\n| `path` | `String` | no |  | El path que se va a observar. |\n| `config` | `String` | no |  | Los comandos del enlace. |\n\nEl enlace funciona como el elemento [ui-bind](../ui-bind/). Sin `path` ni `config`, los valores se leen de los atributos del elemento.\n\nExample: Enlazar un elemento a un path\n```html\n<div id=\"name\"></div>\n\n<script>\nSET('user.name', 'Peter');\nNEWUIBIND($('#name'), 'user.name', 'text:value');\n\nsetTimeout(function() {\n\tconsole.log($('#name').html()); // Peter\n}, 200);\n</script>\n```\n\n### NODEINDEXOF(element)\n\nType: `method`\n\nDevuelve la posición de un elemento entre sus hermanos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | El elemento. |\n\nReturns: `Number` La posición, empezando por cero.\n\nExample: Leer una posición\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li></ul>\n\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, reference, [before])\n\nType: `method`\n\nInserta un elemento junto a otro elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | El elemento que se va a insertar. |\n| `reference` | `jQuery|Element` | yes |  | El elemento de referencia. |\n| `before` | `Boolean` | no | `false` | Inserta el elemento delante del de referencia. |\n\nExample: Mover un elemento\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEINSERT($('#c'), $('#a'), true);\nconsole.log($('ul').text()); // CAB\n</script>\n```\n\n### NODEMOVE(element, [up])\n\nType: `method`\n\nMueve un elemento una posición entre sus hermanos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | El elemento. |\n| `up` | `Boolean` | no | `false` | Mueve el elemento hacia el principio. En caso contrario, lo mueve hacia el final. |\n\nExample: Reordenar una lista\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BAC\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nUna función que no hace nada.\n\nÚsala como callback predeterminado.\n\nExample: Un callback predeterminado\n```js\nvar callback = NOOP;\nconsole.log(typeof(callback)); // function\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nComprueba si la página está en segundo plano.\n\nReturns: `Boolean` `true` cuando el documento está oculto.\n\nExample: Comprobar la página\n```js\nconsole.log(NOTFOCUSED()); // false\n```\n\n### NOW\n\nType: `property`\n\nLa fecha actual, que se actualiza una vez por minuto.\n\nReturns: `Date` La fecha.\n\nÚsala cuando te baste una precisión de un minuto. Evita crear un objeto `Date` nuevo en cada uso.\n\nExample: Leer la fecha\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path)\n\nType: `method`\n\nEstablece un path a `null`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\n`NULL()` es la misma función con otro nombre.\n\nExample: Borrar un valor\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### OFF(name, [callback])\n\nType: `method`\n\nElimina manejadores de eventos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `callback` | `Function` | no |  | El manejador que se va a eliminar. |\n\nSin `callback`, se eliminan todos los manejadores del evento. Se pueden unir varios eventos con `+`.\n\nExample: Eliminar un manejador\n```js\nvar count = 0;\nvar handler = function() {\n\tcount++;\n};\n\nON('refresh', handler);\nEMIT('refresh');\nOFF('refresh', handler);\nEMIT('refresh');\nconsole.log(count); // 1\n```\n\n### ON(name, callback, [init])\n\nType: `method`\n\nRegistra un manejador de eventos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `callback` | `Function` | yes |  | El manejador. Recibe los argumentos del evento. |\n| `init` | `Boolean` | no | `false` | Además llama al manejador una vez, sin argumentos. |\n\nSe pueden unir varios eventos con `+`, por ejemplo `saved + removed`. Un manejador de `ready` o `init` se ejecuta de inmediato si la biblioteca ya ha arrancado. Los eventos de la biblioteca aparecen en [Eventos](../events/).\n\nExample: Capturar dos eventos\n```js\nvar count = 0;\n\nON('saved + removed', function() {\n\tcount++;\n});\n\nEMIT('saved');\nEMIT('removed');\nconsole.log(count); // 2\n```\n\n### PARSE(value)\n\nType: `method`\n\nAnaliza JSON y convierte las cadenas de fecha en objetos `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | El JSON, un selector o un objeto. |\n\nReturns: `Object` El valor analizado, o `null`.\n\nUn valor que empieza por `#` o `.` es un selector: el JSON se lee del contenido de ese elemento. Un objeto se devuelve tal cual. Un JSON no válido devuelve `null`.\n\nExample: Analizar JSON\n```js\nvar data = PARSE('{\"created\":\"2024-05-01T10:00:00.000Z\"}');\nconsole.log(data.created instanceof Date); // true\nconsole.log(PARSE('invalid')); // null\n```\n\n### PIPE(name, [data], callback, [scope])\n\nType: `method`\n\nLlama a una operación en la dirección de `DEF.pipe`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la operación, seguido opcionalmente de palabras clave. |\n| `data` | `Object` | no |  | Los datos de la operación. |\n| `callback` | `Function|String` | yes |  | Una función o un path que recibe la respuesta. |\n| `scope` | `Object` | no | `window` | El objeto en el que se resuelve un path de `callback`. |\n\nFunciona como [API()](../globals/), con la dirección tomada de [DEF.pipe](../def/).\n\nExample: Llamar a una operación\n```js\nDEF.pipe = '/pipe/';\n\nPIPE('orders_list', function(response) {\n\tconsole.log(response.length); // 1\n});\n```\n\n### PLUGIN(name, [config], callback, [dependencies])\n\nType: `method`\n\nRegistra la declaración de un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del plugin. |\n| `config` | `String` | no |  | La configuración predeterminada con la forma `key:value;key:value`. |\n| `callback` | `Function` | yes |  | La declaración: `function(self, config)`. |\n| `dependencies` | `String|Array` | no |  | Direcciones que se importan primero. |\n\nEl `callback` se ejecuta cuando se crea un elemento [ui-plugin](../ui-plugin/) con este path. El nombre `*` registra el plugin common. Consulta [Plugins](../../guides/plugins/) y el objeto [Plugin](../plugin/).\n\nExample: Declarar un plugin\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('Hello ' + name); // Hello Peter\n\t};\n});\n\nON('ready', function() {\n\tEXEC('users/hello', 'Peter');\n});\n</script>\n```\n\n### PLUGINS\n\nType: `property`\n\nLas instancias de plugin en ejecución, por nombre.\n\nReturns: `Object` Las instancias de [plugin](../plugin/).\n\nExample: Leer un plugin\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('ready', function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n});\n</script>\n```\n\n### PREF\n\nType: `property`\n\nPreferencias persistentes del usuario.\n\nReturns: `Object` Las preferencias.\n\nSe describe en su propia página: [PREF](../pref/).\n\n### PUSH(path, value)\n\nType: `method`\n\nAñade un elemento al array guardado en un path y avisa al path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path de un array existente. |\n| `value` | `Object` | yes |  | El elemento. |\n\nEscribe `^` delante del path para añadir el elemento al principio del array.\n\nExample: Añadir elementos\n```js\nSET('tags', ['b']);\nPUSH('tags', 'c');\nPUSH('^tags', 'a');\nconsole.log(GET('tags')); // [\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], data)\n\nType: `method`\n\nAñade datos a una dirección como cadena de consulta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | La dirección. |\n| `data` | `Object` | yes |  | Los valores. |\n\nReturns: `String` La dirección con la cadena de consulta.\n\nLos valores vacíos se omiten, las fechas se convierten en cadenas ISO y los arrays se unen con comas. La `url` puede empezar por un método HTTP.\n\nExample: Crear direcciones\n```js\nconsole.log(QUERIFY('/users/', { page: 2, q: 'a b' })); // /users/?page=2&q=a%20b\nconsole.log(QUERIFY('GET /users/', { page: 2 })); // GET /users/?page=2\nconsole.log(QUERIFY({ page: 2 })); // ?page=2\n```\n\n### REPO\n\nType: `property`\n\nUn objeto vacío para los datos compartidos de tu aplicación.\n\nReturns: `Object` El contenedor.\n\nExample: Guardar un valor\n```js\nREPO.title = 'My app';\nconsole.log(REPO.title); // My app\n```\n\n### RESET(path)\n\nType: `method`\n\nRestablece el estado de los componentes enlazados a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nLos estados `touched` y `modified` vuelven a sus valores predeterminados. El valor del path no cambia.\n\nExample: Restablecer un formulario\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tSET('form.name @change', 'Peter');\n\tconsole.log(FIND('field').config.modified); // 1\n\tRESET('form');\n\tconsole.log(FIND('field').config.modified); // 0\n\tconsole.log(GET('form.name')); // Peter\n});\n</script>\n```\n\n### SCROLLBAR(element, [options])\n\nType: `method`\n\nAñade una barra de desplazamiento personalizada a un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | El elemento. |\n| `options` | `Object` | no |  | Las opciones. |\n\nReturns: `Object` La barra de desplazamiento.\n\nOpciones:\n\n| Opción | Tipo | Descripción |\n| --- | --- | --- |\n| `native` | Boolean | Conserva la barra de desplazamiento del navegador y solo establece el overflow. |\n| `orientation` | String | `x` o `y`. De forma predeterminada, ambas direcciones están activas. |\n| `visibleX`, `visibleY` | Boolean | Mantiene visible la pista cuando no hay nada que desplazar. |\n| `wrap` | Boolean | `false` usa el contenido existente como área de desplazamiento. |\n| `controls` | jQuery | El elemento que recibe las pistas de la barra de desplazamiento. |\n| `shadow` | Boolean | Añade sombras en los bordes desplazables. |\n| `padding` | Number | La distancia de las pistas al borde. Valor predeterminado: `5`. |\n| `minsize` | Number | El tamaño mínimo de la barra. Valor predeterminado: `50`. |\n| `thickness` | Number | El grosor que se usa cuando el CSS no lo define. Valor predeterminado: `10`. |\n| `margin`, `marginX`, `marginY` | Number | Ajustan el tamaño del área de desplazamiento. |\n| `offsetX`, `offsetY` | Number | Ajustan el tamaño medido del elemento. |\n| `floating` | Boolean | `false` reserva espacio para las barras. |\n| `parent` | String\\|jQuery | El elemento cuyo tamaño se usa. |\n| `interval` | Number | El tiempo entre comprobaciones del tamaño, en milisegundos. Valor predeterminado: `54321`. |\n| `autoresize` | Boolean | `false` deja de volver a medir el elemento cuando cambia el tamaño de la ventana. Valor predeterminado: `true`. |\n| `onscroll`, `onidle`, `onresize` | Function | Manejadores que reciben la barra de desplazamiento. |\n\nEl objeto devuelto ofrece:\n\n| Miembro | Descripción |\n| --- | --- |\n| `area` | El elemento que se desplaza. |\n| `body` | El elemento con el contenido. |\n| `element` | El elemento original. |\n| `resize()` | Vuelve a medir el elemento. |\n| `scrollTop([value])` | Lee o establece la posición vertical. Una cadena como `'+20'` se mueve de forma relativa a la posición actual. |\n| `scrollLeft([value])` | Lee o establece la posición horizontal, con las mismas reglas. |\n| `scrollBottom(offset)` | Se desplaza hasta el final, menos `offset`. |\n| `scrollRight(offset)` | Se desplaza hasta el borde derecho, menos `offset`. |\n| `scroll(x, y)` | Se desplaza a una posición. |\n| `sync(element, [direction])` | Sincroniza el desplazamiento con otro elemento. `direction` es `x` o `y`. |\n| `destroy()` | Detiene la barra de desplazamiento. |\n\nLos [eventos](../events/) `scroll` y `scrollidle` informan del desplazamiento.\n\nExample: Desplazar desde el código\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nvar scrollbar = SCROLLBAR($('#panel'));\n\nscrollbar.area.css('overflow', 'auto');\nscrollbar.resize(false, true);\nscrollbar.scrollTop(30);\nconsole.log(scrollbar.scrollTop()); // 30\nscrollbar.scrollTop('+20');\nconsole.log(scrollbar.scrollTop()); // 50\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nDevuelve el ancho de la barra de desplazamiento del navegador.\n\nReturns: `Number` El ancho en píxeles.\n\nExample: Leer el ancho\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a una función o escribe un valor, según el nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El destino. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nLa forma `plugin/method` llama a un método de un plugin, y el nombre de una función global llama a esa función. Cualquier otro nombre es un path, y `a` se escribe en él con [SET()](../globals/).\n\nExample: Escribir en un path\n```js\nSEEX('form.name', 'Peter');\nconsole.log(GET('form.name')); // Peter\n```\n\nExample: Llamar a una función global\n```js\nwindow.notify = function(text) {\n\tconsole.log(text); // Saved\n};\n\nSEEX('notify', 'Saved');\n```\n\n### SET(path, value)\n\nType: `method`\n\nEscribe un valor en un path y avisa a todo lo que lo observa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con flags. |\n| `value` | `Object` | yes |  | El valor, o una función `(current)` que lo devuelve. |\n\nSe crean los objetos que falten a lo largo del path. Los flags forman parte del path, por ejemplo `form.name @change`. La forma `path[]` añade el valor al final de un array. Una función como `value` recibe el valor actual, y se escribe su resultado. Consulta [Paths](../../guides/paths/) y [Flags y modificadores de path](../../guides/flags/).\n\nExample: Escribir valores\n```js\nSET('user.name', 'Peter');\nSET('user.tags[]', 'admin');\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"tags\":[\"admin\"]}\n```\n\nExample: Escribir un valor a partir del actual\n```js\nSET('cart.count', 1);\nSET('cart.count', value => value + 1);\nconsole.log(GET('cart.count')); // 2\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a un método de los componentes que coinciden con un selector.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El selector y el método. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nEl `name` tiene la forma `selector/method`:\n\n| Selector | Coincide con |\n| --- | --- |\n| `name` | Los componentes con este nombre. |\n| `#id` | El componente con este identificador. |\n| `*` | Todos los componentes que tienen el método. |\n\nEl flag `@important` lo reintenta cada 500 milisegundos hasta que exista un componente coincidente con el método. Un componente declarado como diferido se crea en la primera llamada, salvo que el nombre empiece por `!`.\n\nExample: Llamar a un método de un componente\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log(value); // 5\n\t};\n});\n\nON('ready', function() {\n\tSETTER('counter/add', 5);\n});\n</script>\n```\n\n### setTimeout2(name, callback, timeout, [limit], [param])\n\nType: `method`\n\nEjecuta una función tras un retardo, que se reinicia en cada llamada con el mismo nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del temporizador. |\n| `callback` | `Function` | yes |  | La función. |\n| `timeout` | `Number` | yes |  | El retardo en milisegundos. |\n| `limit` | `Number` | no |  | El número máximo de llamadas en un periodo de espera. |\n| `param` | `Object` | no |  | El argumento de la función. |\n\nReturns: `String` El nombre del temporizador. Una llamada ignorada por `limit` no devuelve nada.\n\nCon `limit`, el retardo se reinicia como máximo `limit` veces. Las llamadas siguientes se ignoran hasta que se ejecuta la función, de modo que no se puede posponer para siempre.\n\nExample: Ejecutar una vez tras la última llamada\n```js\nvar count = 0;\nvar run = function() {\n\tcount++;\n\tconsole.log(count); // 1\n};\n\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\n```\n\n### STRINGIFY(value, [compress], [fields], [encrypt])\n\nType: `method`\n\nSerializa un valor a JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor. |\n| `compress` | `Boolean` | no | `false` | Elimina los valores vacíos. |\n| `fields` | `Array|Object|Function` | no |  | Las claves que se conservan. |\n| `encrypt` | `Boolean|String` | no |  | `true` codifica el JSON con [ENCRYPT()](../globals/). Una cadena hace lo mismo y es la clave. |\n\nReturns: `String` El JSON.\n\nCon `compress` a `true`, se recortan los espacios de las cadenas y se omiten las cadenas vacías, `false` y `null`. El argumento `fields` selecciona las claves: un array de claves permitidas, un objeto en el que `false` excluye una clave o una función `(key, value)` que devuelve `true` para las claves que se conservan.\n\nExample: Comprimir y filtrar\n```js\nvar data = { name: ' Peter ', note: '', age: 30 };\n\nconsole.log(STRINGIFY(data, true)); // {\"name\":\"Peter\",\"age\":30}\nconsole.log(STRINGIFY(data, false, ['age'])); // {\"age\":30}\n```\n\nExample: Codificar el JSON\n```js\nvar text = STRINGIFY({ id: 5 }, false, null, 'secret');\nconsole.log(DECRYPT(text, 'secret')); // {\"id\":5}\n```\n\n### STYLE(value, [id], [selector])\n\nType: `method`\n\nAñade CSS a la página.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | El CSS. |\n| `id` | `String` | no |  | El identificador del elemento de estilo. |\n| `selector` | `String` | no |  | Un selector que se antepone a cada regla. |\n\nUn elemento con el mismo `id` se sustituye. El elemento tiene el identificador `css` seguido de `id`. Con `selector`, este selector se antepone a cada regla.\n\nExample: Añadir estilos con scope\n```js\nSTYLE('b { color: red }', 'theme', '.panel');\nconsole.log($('#csstheme').html()); // .panel b{ color: red }\n```\n\n### TAPI(name, [data], callback, [scope])\n\nType: `method`\n\nLlama a una operación de la API de Total.js en la dirección de `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la operación, seguido opcionalmente de palabras clave. |\n| `data` | `Object` | no |  | Los datos de la operación. |\n| `callback` | `Function|String` | yes |  | Una función o un path que recibe la respuesta. |\n| `scope` | `Object` | no | `window` | El objeto en el que se resuelve un path de `callback`. |\n\nFunciona como [API()](../globals/), con la dirección tomada de [DEF.api](../def/).\n\nExample: Guardar una respuesta en un path\n```js\nDEF.api = '/admin/api/';\n\nTAPI('users_list', { page: 1 }, 'users.items');\n\nWATCH('users.items', function(value) {\n\tconsole.log(value.length); // 2\n});\n```\n\n### TEMP\n\nType: `property`\n\nUn objeto para datos de corta duración.\n\nReturns: `Object` El contenedor.\n\nLa biblioteca lo sustituye por un objeto vacío cada minuto.\n\nExample: Guardar un valor\n```js\nTEMP.result = 5;\nconsole.log(TEMP.result); // 5\n```\n\n### TOGGLE(path)\n\nType: `method`\n\nInvierte el valor booleano de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nExample: Alternar un valor\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### Total\n\nType: `property`\n\nEl objeto principal de la biblioteca.\n\nReturns: `Object` El objeto principal.\n\nEl mismo objeto que [MAIN](../main/).\n\n### TRANSLATE(text)\n\nType: `method`\n\nSustituye el marcado `@(text)` por las traducciones.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | El texto con el marcado. |\n\nReturns: `String` El texto traducido.\n\nEl texto sin traducción se queda en su idioma original. Las traducciones se cargan con [LOCALIZE()](../globals/).\n\nExample: Traducir un texto\n```js\nLOCALIZE('T' + HASH('Yes').toString(36) + ' : Ano');\nconsole.log(TRANSLATE('@(Yes) / @(No)')); // Ano / No\n```\n\n### UNAUTHORIZED(...permissions)\n\nType: `method`\n\nComprueba los permisos del usuario que ha iniciado sesión.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `permissions` | `String` | yes |  | Uno o varios permisos. |\n\nReturns: `Boolean` `true` cuando se deniega el acceso.\n\nEl método lee la variable global `user`. Un usuario con `sa` o `su` activado tiene todos los permisos. En otro caso, los permisos vienen de `user.permissions` o `user.roles`, como array u objeto. El resultado es `true` cuando el usuario no tiene ninguno de los permisos indicados o cuando `user` no existe.\n\nExample: Comprobar un permiso\n```js\nwindow.user = { roles: ['editor'] };\n\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [callback])\n\nType: `method`\n\nElimina observadores de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. Se pueden unir varios paths con `+`. |\n| `callback` | `Function` | no |  | El observador que se va a eliminar. |\n\nSin `callback`, se eliminan todos los observadores del path.\n\nExample: Dejar de observar\n```js\nvar count = 0;\nvar watcher = function() {\n\tcount++;\n};\n\nWATCH('form.name', watcher);\nSET('form.name', 'A');\nUNWATCH('form.name', watcher);\nSET('form.name', 'B');\nconsole.log(count); // 1\n```\n\n### UPD(path)\n\nType: `method`\n\nAvisa a un path después de cambiar su valor directamente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con flags. |\n\n`UPDATE()` es la misma función con otro nombre.\n\nExample: Avisar tras un cambio directo\n```js\nwindow.form = { name: 'A' };\n\nWATCH('form.name', function(value) {\n\tconsole.log(value); // B\n});\n\nform.name = 'B';\nUPD('form.name');\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nComprueba la posición vertical de un elemento respecto al viewport.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | El elemento. |\n| `threshold` | `Number` | no | `0` | El número de píxeles del elemento que deben estar dentro del viewport. |\n| `mode` | `String` | no | `visible` | `visible`, `above` o `below`. |\n\nReturns: `Boolean` El resultado de la comprobación.\n\n`mode` selecciona la comprobación: `visible` comprueba si el elemento está en el viewport, `above` si está por encima y `below` si está por debajo. Un elemento oculto devuelve `false`.\n\nExample: Comprobar un elemento\n```html\n<div id=\"top\">Top</div>\n<div style=\"height:5000px\"></div>\n<div id=\"far\">Far</div>\n\n<script>\nconsole.log(VISIBLE($('#top'))); // true\nconsole.log(VISIBLE($('#far'))); // false\nconsole.log(VISIBLE($('#far'), 0, 'below')); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nUn nombre corto del objeto `window`.\n\nReturns: `Object` El objeto `window`.\n\nExample: Comparar los objetos\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback)\n\nType: `method`\n\nEjecuta una función cuando se cumple una condición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | Una función o un path. |\n| `callback` | `Function` | yes |  | La función que se va a ejecutar. |\n\nLa condición se comprueba de inmediato y después cada 500 milisegundos. Una función debe devolver un valor verdadero. En el caso de un path, la espera termina cuando el path contiene un valor verdadero.\n\nExample: Esperar a un valor\n```js\nWAIT('app.config', function() {\n\tconsole.log(GET('app.config.name')); // Demo\n});\n\nsetTimeout(function() {\n\tSET('app.config', { name: 'Demo' });\n}, 100);\n```\n\n### WARN(...values)\n\nType: `method`\n\nImprime una advertencia en la consola del navegador.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `values` | `Object` | yes |  | Los valores que se van a imprimir. |\n\n### WATCH(path, callback, [init])\n\nType: `method`\n\nObserva los cambios de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `callback` | `Function` | yes |  | Una función que recibe `(value, flags, path)`: el valor observado, los flags y el path que ha cambiado. |\n| `init` | `Boolean` | no | `false` | Además llama al observador una vez tras registrarlo. |\n\nUn observador se ejecuta cuando cambia su propio path, cuando cambia un path padre y cuando cambia un path anidado por debajo. Se pueden unir varios paths con `+`.\n\nExample: Observar un path\n```js\nWATCH('user.name', function(value, flags, path) {\n\tconsole.log(value, path); // Peter user.name\n});\n\nSET('user.name', 'Peter');\n```\n\n### WH\n\nType: `property`\n\nLa altura de la ventana en píxeles.\n\nReturns: `Number` La altura.\n\nEl valor se establece mientras arranca la biblioteca y se actualiza cuando se redimensiona la ventana.\n\nExample: Leer la altura\n```js\nON('ready', function() {\n\tconsole.log(typeof(WH)); // number\n});\n```\n\n### WIDTH([element])\n\nType: `method`\n\nDevuelve el nombre del tamaño de dispositivo según el ancho de un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | El elemento medido. |\n\nReturns: `String` El nombre del tamaño.\n\nLos tamaños `xs`, `sm`, `md` y `lg` se definen en [DEF.devices](../def/).\n\nExample: Medir un elemento\n```html\n<div id=\"box\" style=\"width:800px\"></div>\n\n<script>\nconsole.log(WIDTH($('#box'))); // sm\n</script>\n```\n\n### WW\n\nType: `property`\n\nEl ancho de la ventana en píxeles.\n\nReturns: `Number` El ancho.\n\nEl valor se establece mientras arranca la biblioteca y se actualiza cuando se redimensiona la ventana.\n\nExample: Leer el ancho\n```js\nON('ready', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n","entries":[{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], callback, [onprogress], [scope], [id])","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(key, timeout, [callback])","since":"","deprecated":false},{"type":"method","name":"CACHE()","signature":"CACHE(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"CACHEPATH()","signature":"CACHEPATH(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, [callback])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [raw])","since":"","deprecated":false},{"type":"method","name":"CLRELOAD()","signature":"CLRELOAD(name, [callback])","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], callback, [dependencies], [css])","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"COMPONENTS(path)","since":"","deprecated":false},{"type":"method","name":"CONFIG()","signature":"CONFIG(selector, config)","since":"","deprecated":false},{"type":"property","name":"COOKIES","signature":"COOKIES","since":"","deprecated":false},{"type":"method","name":"COPY()","signature":"COPY(source, target)","since":"","deprecated":false},{"type":"method","name":"CSS()","signature":"CSS(value, [id], [selector])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(text, [key], [type])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"EMPTYARRAY","signature":"EMPTYARRAY","since":"","deprecated":false},{"type":"property","name":"EMPTYOBJECT","signature":"EMPTYOBJECT","since":"","deprecated":false},{"type":"method","name":"ENCRYPT()","signature":"ENCRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"method","name":"ENV()","signature":"ENV(name, [value])","since":"","deprecated":false},{"type":"method","name":"ENVIRONMENT()","signature":"ENVIRONMENT(name, [version], [language], [env])","since":"","deprecated":false},{"type":"method","name":"ERROR()","signature":"ERROR(response, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, callback)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], callback)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [all])","since":"","deprecated":false},{"type":"method","name":"FLAGS()","signature":"FLAGS(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(code)","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE()","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [noflags])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([length])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value)","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value])","since":"","deprecated":false},{"type":"method","name":"inDOM()","signature":"inDOM(element)","since":"","deprecated":false},{"type":"property","name":"isIE","signature":"isIE","since":"","deprecated":false},{"type":"property","name":"isMOBILE","signature":"isMOBILE","since":"","deprecated":false},{"type":"property","name":"isPRIVATEMODE","signature":"isPRIVATEMODE","since":"","deprecated":false},{"type":"property","name":"isROBOT","signature":"isROBOT","since":"","deprecated":false},{"type":"property","name":"isSTANDALONE","signature":"isSTANDALONE","since":"","deprecated":false},{"type":"property","name":"isTOUCH","signature":"isTOUCH","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"method","name":"LOCALIZE()","signature":"LOCALIZE(text)","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"method","name":"NEWUIBIND()","signature":"NEWUIBIND(element, [path], [config])","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, reference, [before])","since":"","deprecated":false},{"type":"method","name":"NODEMOVE()","signature":"NODEMOVE(element, [up])","since":"","deprecated":false},{"type":"method","name":"NOOP()","signature":"NOOP()","since":"","deprecated":false},{"type":"method","name":"NOTFOCUSED()","signature":"NOTFOCUSED()","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path)","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [callback])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value)","since":"","deprecated":false},{"type":"method","name":"PIPE()","signature":"PIPE(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [config], callback, [dependencies])","since":"","deprecated":false},{"type":"property","name":"PLUGINS","signature":"PLUGINS","since":"","deprecated":false},{"type":"property","name":"PREF","signature":"PREF","since":"","deprecated":false},{"type":"method","name":"PUSH()","signature":"PUSH(path, value)","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], data)","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path)","since":"","deprecated":false},{"type":"method","name":"SCROLLBAR()","signature":"SCROLLBAR(element, [options])","since":"","deprecated":false},{"type":"method","name":"SCROLLBARWIDTH()","signature":"SCROLLBARWIDTH()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, callback, timeout, [limit], [param])","since":"","deprecated":false},{"type":"method","name":"STRINGIFY()","signature":"STRINGIFY(value, [compress], [fields], [encrypt])","since":"","deprecated":false},{"type":"method","name":"STYLE()","signature":"STYLE(value, [id], [selector])","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path)","since":"","deprecated":false},{"type":"property","name":"Total","signature":"Total","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...permissions)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [callback])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path)","since":"","deprecated":false},{"type":"method","name":"VISIBLE()","signature":"VISIBLE(element, [threshold], [mode])","since":"","deprecated":false},{"type":"property","name":"W","signature":"W","since":"","deprecated":false},{"type":"method","name":"WAIT()","signature":"WAIT(condition, callback)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...values)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcS61wo61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/globals/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Fonctions globales","summary":"Les fonctions et les variables que la bibliothèque ajoute à l'objet window.","markdown":"---\ntitle: Fonctions globales\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/globals/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Fonctions globales\n\n> Les fonctions et les variables que la bibliothèque ajoute à l'objet window.\n\nLa bibliothèque ajoute ces fonctions et ces variables à `window` : elles sont donc disponibles partout dans ton code. Commence par [Paths](../../guides/paths/) et [Liaison de données](../../guides/data-binding/) pour voir comment elles fonctionnent ensemble.\n\n## API\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nPrépare un morceau de HTML pour un path et un identifiant précis.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | La valeur de `~PATH~` et `CLASS`. Utilise `null` pour ignorer ces remplacements. |\n| `id` | `String` | yes |  | La valeur de `~ID~`. Utilise `null` pour ignorer ce remplacement. |\n| `text` | `String` | yes |  | Le texte à préparer. |\n\nReturns: `String` Le texte préparé.\n\nLa méthode traduit le balisage `@(text)`, applique les variables `--name--` et remplace `~CDN~` par [DEF.cdn](../def/). Quand `path` est défini, `~PATH~` et `CLASS` deviennent le path, les éléments `<ui-plugin>` sans attribut `path` le reçoivent et le premier `PLUGIN(function(` devient `PLUGIN('path', function(`. Quand `id` est défini, `~ID~` devient l'identifiant. Un `text` vide ou qui n'est pas une chaîne est renvoyé sans modification.\n\nExample: Remplacer les mots-clés\n```js\nvar html = '<div class=\"CLASS\" data-id=\"~ID~\">~PATH~</div>';\nconsole.log(ADAPT('users', 'u1', html)); // <div class=\"users\" data-id=\"u1\">users</div>\n```\n\n### AJAX(url, [data], callback, [onprogress], [scope], [id])\n\nType: `method`\n\nEnvoie une requête HTTP et transmet la réponse à une fonction ou à un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La méthode, l'adresse et des mots-clés facultatifs, par exemple `POST /api/users/ ERROR`. |\n| `data` | `Object` | no |  | Le corps de la requête : un objet envoyé en JSON, une chaîne envoyée comme données de formulaire, ou `FormData`. |\n| `callback` | `Function|String` | yes |  | Une fonction qui reçoit la réponse, ou un path qui la reçoit. |\n| `onprogress` | `Function|String` | no |  | Une fonction ou un path qui reçoit le pourcentage de téléversement. |\n| `scope` | `Object` | no | `window` | L'objet dans lequel un path `callback` est résolu. |\n| `id` | `String` | no | `url` | La clé utilisée par `SYNC` et par le cache. |\n\nL'`url` commence par la méthode HTTP, suivie de l'adresse et de mots-clés facultatifs séparés par des espaces :\n\n| Mot-clé | Signification |\n| --- | --- |\n| `ERROR` | Fait passer la réponse par [ERROR()](../globals/). Si elle contient une erreur, l'événement `ERROR` est émis et `callback` ne s'exécute pas. Un statut d'erreur sans corps de réponse émet l'événement `ERROR` avec le code de statut. |\n| `SYNC` | Met en file d'attente les requêtes ayant le même `id`, pour qu'elles s'exécutent l'une après l'autre. |\n| `<1 minute>` | Met en cache la réponse pendant la durée indiquée avec [CACHE()](../globals/), sauf si c'est une erreur. Tant que la requête est en cours, les autres appels avec le même `id` attendent sa réponse : une seule requête est donc envoyée. |\n| `#name` | Charge d'abord la liste de codes `name`. Consulte [CL()](../globals/). |\n| `@flag` | Émet le flag à l'envoi de la requête. Consulte [Flags et modificateurs de path](../../guides/flags/). |\n\nUn objet dans `data` est envoyé en JSON, une chaîne est envoyée telle quelle avec le type de contenu `application/x-www-form-urlencoded`, et `FormData` est envoyé comme formulaire.\n\nUn code de statut de 400 ou plus compte comme une erreur. Une requête qui ne peut pas joindre le serveur, qui est interrompue ou qui dépasse le délai a le code de statut `0`, et `callback` reçoit une réponse vide. Une réponse dont le type de contenu est JSON est analysée avec [PARSE()](../globals/). Chaque requête ajoute les en-têtes de [DEF.headers](../def/). Quand [DEF.language](../def/) est défini, il est ajouté à la chaîne de requête. Quand [DEF.version](../def/) est défini, il est ajouté à la chaîne de requête des adresses `.html`.\n\nLes [événements](../events/) `request` et `response` te permettent d'inspecter ou de modifier chaque appel. Une fois la requête envoyée, `options.xhr` dans l'événement `request` contient son `XMLHttpRequest` : `options.xhr.abort()` l'arrête donc. `UPLOAD()` est la même fonction sous un autre nom.\n\nExample: Lire une réponse\n```js\nAJAX('GET /api/users/', function(response) {\n\tconsole.log(response.length); // 2\n});\n```\n\nExample: Stocker une réponse dans un path\n```js\nAJAX('POST /api/orders/', { amount: 10 }, 'orders.last');\n\nWATCH('orders.last', function(value) {\n\tconsole.log(value.id); // 100\n});\n```\n\nExample: Envoyer des données de formulaire\n```js\nAJAX('POST /api/login/', 'name=Ann&remember=1', function(response) {\n\tconsole.log(response.ok); // true\n});\n```\n\nExample: Arrêter une requête\n```js\nvar request;\n\nON('request', options => request = options);\nON('ERROR', status => console.log('failed', status)); // failed 0\n\nAJAX('GET /api/report/ ERROR', NOOP);\nrequest.xhr.abort();\n```\n\n### API(url, name, [data], callback, [scope])\n\nType: `method`\n\nAppelle un point de terminaison d'API Total.js à une adresse précise.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'adresse du point de terminaison. |\n| `name` | `String` | yes |  | Le nom de l'opération, éventuellement suivi de mots-clés. |\n| `data` | `Object` | no |  | Les données de l'opération. |\n| `callback` | `Function|String` | yes |  | Une fonction ou un path qui reçoit la réponse. |\n| `scope` | `Object` | no | `window` | L'objet dans lequel un path `callback` est résolu. |\n\nLa méthode envoie `POST url` avec le corps JSON `{ schema: name, data: data }`. Les mots-clés acceptés par [AJAX()](../globals/) peuvent suivre le nom, par exemple `users_list ERROR`. Pour utiliser une adresse fixe, consulte [TAPI()](../globals/) et [PIPE()](../globals/).\n\nExample: Appeler une opération\n```js\nAPI('/admin/api/', 'users_read', { id: 5 }, function(response) {\n\tconsole.log(response.name); // Peter\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nDéfinit le jeu de couleurs de la page à l'aide de variables CSS et de classes sur le body.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Les commutateurs et les variables CSS. |\n\nChaque clé devient une variable CSS sur `:root`, à l'exception des quatre commutateurs ci-dessous. La clé `color` met aussi à jour [DEF.color](../def/) et ajoute la variable `--rgb` avec les valeurs rouge, verte et bleue d'une couleur hexadécimale à trois ou six chiffres.\n\n| Clé | Signification |\n| --- | --- |\n| `dark` ou `darkmode` | Bascule la classe `ui-dark` sur le body. |\n| `large` ou `largemode` | Bascule la classe `ui-large` sur le body. |\n\nLe préfixe de classe provient de [DEF.prefixcsslibrary](../def/).\n\nExample: Thème sombre avec une couleur d'accent\n```js\nAPPEARANCE({ dark: true, color: '#4285F4' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#4285F4;--rgb:66,133,244}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\nExample: Une couleur courte\n```js\nAPPEARANCE({ color: '#abc' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#abc;--rgb:170,187,204}\n```\n\n### ASETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nCrée une fonction qui appelle plus tard une méthode de composant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le sélecteur et la méthode, sous la même forme que dans `SETTER()`. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nReturns: `Function` Une fonction sans arguments.\n\nChaque appel de la fonction renvoyée exécute [SETTER()](../globals/) avec les arguments indiqués ici.\n\nExample: Préparer un appel\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log('added', value); // added 5\n\t};\n});\n\nON('ready', function() {\n\tvar add = ASETTER('counter/add', 5);\n\tadd();\n});\n</script>\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nLit un attribut `data-*` sur un élément ou sur son parent le plus proche qui le possède.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Event|Element|Object` | yes |  | Le point de départ. |\n| `name` | `String` | no | `id` | Le nom de l'attribut sans le préfixe `data-`. |\n\nReturns: `String` La valeur de l'attribut.\n\nL'`element` peut être un objet jQuery, un événement jQuery (son `currentTarget` est utilisé) ou un élément DOM. Pour un objet simple, la méthode renvoie la propriété `name`. Toute autre valeur est renvoyée telle quelle.\n\nExample: Lire l'identifiant le plus proche\n```html\n<div data-id=\"15\" data-type=\"user\"><button id=\"save\">Save</button></div>\n\n<script>\nvar button = $('#save');\nconsole.log(ATTRD(button)); // 15\nconsole.log(ATTRD(button, 'type')); // user\nconsole.log(ATTRD({ id: 20 })); // 20\n</script>\n```\n\n### BLOCKED(key, timeout, [callback])\n\nType: `method`\n\nLimite la fréquence à laquelle une opération peut s'exécuter.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Le nom de l'opération. |\n| `timeout` | `Number|String` | yes |  | La durée en millisecondes, ou un texte comme `5 minutes`. |\n| `callback` | `Function` | no |  | Une fonction qui s'exécute quand l'opération n'est pas bloquée. |\n\nReturns: `Boolean` `true` quand l'opération est bloquée.\n\nLe premier appel bloque `key` pendant la durée indiquée et renvoie `false`. Les appels suivants renvoient `true` jusqu'à la fin de ce délai. Un blocage de 10 secondes ou plus est conservé dans `localStorage` et survit donc au rechargement de la page.\n\nExample: Autoriser un clic par seconde\n```js\nON('ready', function() {\n\tconsole.log(BLOCKED('save', 1000)); // false\n\tconsole.log(BLOCKED('save', 1000)); // true\n});\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nLit ou écrit une valeur dans le cache persistant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clé. |\n| `value` | `Object` | no |  | La valeur à stocker. |\n| `expire` | `String` | no |  | La durée de vie de la valeur, ou `session`. |\n\nReturns: `Object` La valeur stockée lors d'une lecture, sinon rien.\n\nAvec `expire`, la méthode stocke la valeur. Sans cet argument, elle renvoie la valeur stockée, ou `null` quand la valeur est absente ou a expiré. La valeur `session` garde les données en mémoire jusqu'à la fermeture de la page. Toute autre valeur est une durée comme `10 minutes`, `2 hours`, `1 day`, `1 week`, `1 month` ou `1 year`, et les données sont enregistrées via [DEF.onstoragesave](../def/).\n\nLe cache est chargé au démarrage de la bibliothèque : utilise-le donc à partir de l'[événement](../events/) `ready`.\n\nExample: Écrire et lire\n```js\nON('ready', function() {\n\tCACHE('filter', { page: 2 }, '1 day');\n\tconsole.log(CACHE('filter')); // {\"page\":2}\n\tconsole.log(CACHE('missing')); // null\n});\n```\n\n### CACHEPATH(path, expire, [def])\n\nType: `method`\n\nConserve la valeur d'un path dans le cache d'une visite à l'autre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `expire` | `String` | yes |  | La durée de vie de la valeur enregistrée, par exemple `1 day`. |\n| `def` | `Object|Function` | no |  | La valeur utilisée quand rien n'est enregistré. Une fonction est appelée pour l'obtenir. |\n\nLa méthode enregistre chaque modification du path avec [CACHE()](../globals/) pour la durée indiquée dans `expire`. Quand le path est vide, la valeur enregistrée y est écrite, et quand rien n'est enregistré, c'est `def` qui est écrit. Un path qui contient déjà une valeur la conserve.\n\nSi elle est appelée avant que la bibliothèque ait chargé le cache, la méthode l'attend puis restaure la valeur. Les plugins ont la même méthode avec un path relatif : [plugin.cachepath()](../plugin/).\n\nExample: Mémoriser un filtre\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n\nSET('filter.q', 'lamp');\n// After a reload of the page, GET('filter.q') returns lamp\n```\n\n### CL(name, [callback])\n\nType: `method`\n\nCharge les listes de codes enregistrées avec `CLINIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Un nom, ou plusieurs noms séparés par des virgules. |\n| `callback` | `Function` | no |  | Une fonction qui s'exécute quand les listes sont chargées. |\n\nUne liste de codes contient des données partagées, comme une liste de pays, stockées dans [DEF.cl](../def/). Une liste n'est chargée qu'une seule fois. Le `callback` s'exécute quand toutes les listes sont disponibles. Un nom qui n'est pas encore enregistré est revérifié toutes les 500 millisecondes jusqu'à ce qu'il apparaisse.\n\nExample: Charger une liste à la demande\n```js\nCLINIT('countries', function(next) {\n\tnext([{ id: 'SK', name: 'Slovakia' }]);\n});\n\nON('ready', function() {\n\tCL('countries', function() {\n\t\tconsole.log(DEF.cl.countries.length); // 1\n\t});\n});\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nAnnule un minuteur créé avec `setTimeout2()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du minuteur. |\n\nReturns: `Boolean` `true` quand le minuteur existe.\n\nExample: Annuler un minuteur\n```js\nsetTimeout2('search', NOOP, 1000);\nconsole.log(clearTimeout2('search')); // true\nconsole.log(clearTimeout2('unknown')); // false\n```\n\n### CLINIT(name, source, [init])\n\nType: `method`\n\nEnregistre la source d'une liste de codes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la liste de codes. |\n| `source` | `Function|String` | yes |  | Une fonction, une requête ou une opération. |\n| `init` | `Boolean` | no | `false` | Charge la liste immédiatement. |\n\nQuand `source` est une fonction, elle reçoit `next(value, [extend])`. Passe la liste à `next()`. Avec `extend` à `true`, `value` est un objet dont les clés sont stockées comme des listes de codes distinctes.\n\nQuand `source` est une chaîne, une valeur qui commence par une méthode HTTP est chargée avec [AJAX()](../globals/). Toute autre valeur est une opération pour [TAPI()](../globals/).\n\nExample: Charger plusieurs listes à la fois\n```js\nCLINIT('all', function(next) {\n\tnext({ colors: ['red'], sizes: ['XL'] }, true);\n}, true);\n\nON('ready', function() {\n\tsetTimeout(function() {\n\t\tconsole.log(DEF.cl.colors, DEF.cl.sizes); // [\"red\"] [\"XL\"]\n\t}, 100);\n});\n```\n\n### CLONE(value, [raw])\n\nType: `method`\n\nCrée une copie profonde d'une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|String` | yes |  | La valeur à copier, ou un path. |\n| `raw` | `Boolean` | no | `false` | Traite une chaîne comme une valeur simple. |\n\nReturns: `Object` La copie.\n\nUne chaîne est traitée comme un path vers un objet ou un tableau, et la valeur qui s'y trouve est copiée. Avec `raw` à `true`, une chaîne est renvoyée telle quelle. Les objets sont copiés via JSON, et les dates qu'ils contiennent restent des dates.\n\nExample: Copier un objet\n```js\nvar a = { user: { name: 'Peter' } };\nvar b = CLONE(a);\nb.user.name = 'Lucia';\nconsole.log(a.user.name); // Peter\n```\n\nExample: Copier la valeur d'un path\n```js\nSET('form', { name: 'Peter' });\nvar copy = CLONE('form');\nconsole.log(copy); // {\"name\":\"Peter\"}\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nRecharge les listes de codes depuis leurs sources.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Un nom, ou plusieurs noms séparés par des virgules. |\n| `callback` | `Function` | no |  | Une fonction qui s'exécute quand les listes sont rechargées. |\n\nSeules les listes déjà chargées sont rechargées. Les autres noms sont ignorés.\n\nExample: Actualiser une liste\n```js\nvar counter = 0;\n\nCLINIT('stats', function(next) {\n\tnext([++counter]);\n});\n\nON('ready', function() {\n\tCL('stats', function() {\n\t\tCLRELOAD('stats', function() {\n\t\t\tconsole.log(DEF.cl.stats); // [2]\n\t\t});\n\t});\n});\n```\n\n### CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nExécute une commande sur tous les composants qui l'enregistrent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La commande, éventuellement suivie de flags. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nLes composants enregistrent des commandes avec [command()](../component/). Des flags peuvent suivre le nom après une espace, par exemple `CMD('refresh @saved')` : ils sont émis en premier, comme avec [SET()](../globals/). Pour exécuter une commande seulement dans une partie de la page, utilise [$(selector).CMD()](../jquery/) ou [plugin.cmd()](../plugin/).\n\nExample: Vider toutes les listes\n```html\n<ui-component name=\"list\"></ui-component>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nvar count = 0;\n\nCOMPONENT('list', function(self) {\n\tself.command('clear', value => count += value);\n});\n\nON('ready', function() {\n\tCMD('clear', 1);\n\tconsole.log(count); // 2\n});\n</script>\n```\n\n### COMPONENT(name, [config], callback, [dependencies], [css])\n\nType: `method`\n\nEnregistre une déclaration de composant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du composant. |\n| `config` | `String` | no |  | La configuration par défaut sous la forme `key:value;key:value`. |\n| `callback` | `Function` | yes |  | La déclaration : `function(self, config, cls)`. |\n| `dependencies` | `String|Array` | no |  | Les adresses à importer d'abord, séparées par des virgules. Un tableau peut aussi contenir des fonctions qui reçoivent `next`. |\n| `css` | `String` | no |  | Les styles du composant. |\n\nLe `callback` s'exécute une fois pour chaque instance et reçoit l'instance, sa configuration et sa classe CSS. Dans l'argument `css`, le mot `CLASS` devient `ui-` suivi du nom du composant. Consulte [Créer des composants](../../guides/creating-components/) et l'objet [Component](../component/).\n\nExample: Déclarer un composant\n```html\n<ui-component name=\"hello\"></ui-component>\n\n<script>\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.element.aclass(cls).html('Hello ' + config.name);\n\t\tconsole.log(self.element.html()); // Hello World\n\t};\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nRenvoie les composants liés à un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec des flags. |\n\nReturns: `Array` Les instances de [composant](../component/) correspondantes.\n\nLe path inclut tout ce qui se trouve en dessous : `form` renvoie donc aussi un composant lié à `form.name`. Les flags du path affinent le résultat : `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` et `@enabled`.\n\nExample: Trouver les champs obligatoires\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.setter = NOOP;\n});\n\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tconsole.log(COMPONENTS('form @required').length); // 1\n});\n</script>\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nModifie la configuration des composants existants et futurs.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | Les composants à configurer. |\n| `config` | `String|Object` | yes |  | La configuration, sous forme d'objet ou sous la forme `key:value;key:value`. |\n\nLe `selector` peut être :\n\n| Sélecteur | Correspond à |\n| --- | --- |\n| `name` | Les composants portant ce nom. |\n| `#id` | Le composant ayant cet identifiant. |\n| `.path` | Les composants dont le path contient `path`. |\n| `*` | Tous les composants. |\n| `a, b` | Plusieurs sélecteurs séparés par des virgules. |\n| `function(instance)` | Les composants pour lesquels la fonction renvoie `true`. |\n\nExample: Configurer par nom\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tCONFIG('box', 'color:red;size:10');\n\tconsole.log(FIND('box').config.size); // 10\n});\n</script>\n```\n\n### COOKIES\n\nType: `property`\n\nLit et écrit les cookies du navigateur.\n\nReturns: `Object` L'objet contenant les méthodes.\n\nL'objet possède trois méthodes :\n\n| Méthode | Description |\n| --- | --- |\n| `COOKIES.get(name)` | Renvoie la valeur, ou une chaîne vide. |\n| `COOKIES.set(name, value, [expire], [samesite])` | Écrit un cookie pour le chemin `/`. `expire` est un nombre de jours, un `Date` ou un texte comme `1 day`. Sans `expire`, le cookie est conservé jusqu'à la fermeture du navigateur. `samesite` vaut par exemple `lax`. |\n| `COOKIES.rem(name)` | Supprime le cookie. |\n\nExample: Écrire et lire un cookie\n```js\nCOOKIES.set('theme', 'dark', '1 month', 'lax');\nconsole.log(COOKIES.get('theme')); // dark\n```\n\nExample: Conserver un cookie pendant une semaine\n```js\nCOOKIES.set('token', 'a=1', 7);\nconsole.log(COOKIES.get('token')); // a=1\n```\n\n### COPY(source, target)\n\nType: `method`\n\nCopie les propriétés d'un objet vers un autre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | L'objet à lire. |\n| `target` | `Object` | yes |  | L'objet dans lequel écrire. |\n\nReturns: `Object` L'objet `target`.\n\nLes objets imbriqués sont clonés : les modifications ultérieures de `source` n'affectent donc pas `target`.\n\nExample: Fusionner deux objets\n```js\nvar target = { a: 1 };\nCOPY({ b: { c: 2 } }, target);\nconsole.log(target); // {\"a\":1,\"b\":{\"c\":2}}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nUn autre nom pour `STYLE()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Le CSS. |\n| `id` | `String` | no |  | L'identifiant de l'élément style. |\n| `selector` | `String` | no |  | Un sélecteur qui préfixe chaque règle. |\n\nConsulte [STYLE()](../globals/). Définir `window.jc_globals = { CSS: false }` avant le script de la bibliothèque laisse cette variable globale non définie.\n\n### DAYS\n\nType: `property`\n\nLes noms anglais des jours de la semaine, en commençant par le dimanche.\n\nReturns: `Array` Sept chaînes.\n\nExample: Lire un jour\n```js\nconsole.log(DAYS[1]); // Monday\n```\n\n### DEF\n\nType: `property`\n\nLes paramètres par défaut de la bibliothèque.\n\nReturns: `Object` Les paramètres.\n\nDécrit sur sa propre page : [DEF](../def/).\n\n### DECRYPT(text, [key], [type])\n\nType: `method`\n\nLit une valeur écrite par `ENCRYPT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Le texte produit par `ENCRYPT()`. |\n| `key` | `String` | no |  | La clé. |\n| `type` | `String` | no |  | Le préfixe du texte. |\n\nReturns: `Object` La valeur, ou `undefined`.\n\nLa `key` et le `type` doivent être ceux donnés à [ENCRYPT()](../globals/). La méthode renvoie `undefined` quand la somme de contrôle ne leur correspond pas, ce qui est le cas pour un texte modifié. Une valeur qui commence par `[`, `{` ou `\"` est analysée comme du JSON.\n\nExample: Relire un objet\n```js\nvar text = ENCRYPT({ id: 5 }, 'secret', 'U');\n\nconsole.log(text.charAt(0)); // U\nconsole.log(DECRYPT(text, 'secret', 'U')); // {\"id\":5}\nconsole.log(DECRYPT(text, 'secret')); // undefined\n```\n\n### DIFFDOM(element, selector, html, [attribute])\n\nType: `method`\n\nMet à jour les enfants d'un élément pour qu'ils correspondent à un nouveau HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'élément parent. |\n| `selector` | `String` | yes |  | Un sélecteur des enfants comparés. |\n| `html` | `String` | yes |  | Le nouveau contenu. |\n| `attribute` | `String` | no |  | L'attribut utilisé pour la comparaison. |\n\nReturns: `Object` Le nombre d'éléments ajoutés, conservés et supprimés : `{ add, upd, rem }`.\n\nLes enfants qui n'ont pas changé restent dans le DOM et conservent donc leur état. Les enfants sont comparés sur la totalité de leur HTML, ou sur la valeur de `attribute` quand il est défini.\n\nExample: Mettre à jour une liste\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n\n<script>\nvar list = $('#list');\nvar result = DIFFDOM(list, 'li', '<li>A</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log(list.html()); // <li>A</li><li>C</li>\n</script>\n```\n\n### EMIT(name, [a], [b], [c], [d])\n\nType: `method`\n\nÉmet un événement.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nLes gestionnaires enregistrés avec [ON()](../globals/), ainsi que ceux enregistrés sur les [composants](../component/) et les [plugins](../plugin/), reçoivent les arguments. Des flags peuvent suivre le nom, par exemple `refresh @loading`. Les événements de la bibliothèque sont répertoriés dans [Événements](../events/).\n\nExample: Émettre un événement personnalisé\n```js\nON('saved', function(id, name) {\n\tconsole.log(id, name); // 5 Peter\n});\n\nEMIT('saved', 5, 'Peter');\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nUn tableau vide figé.\n\nReturns: `Array` Un tableau qui ne peut pas être modifié.\n\nExample: Une valeur par défaut partagée\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nUn objet vide figé.\n\nReturns: `Object` Un objet qui ne peut pas être modifié.\n\nExample: Une valeur par défaut partagée\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nEncode une valeur sous forme de texte avec une somme de contrôle.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | La valeur. |\n| `key` | `String` | no |  | La clé de la somme de contrôle. |\n| `type` | `String` | no |  | Un préfixe écrit au début du texte. |\n\nReturns: `String` Le texte encodé.\n\nUn objet ou un tableau est d'abord sérialisé avec [STRINGIFY()](../globals/). Le résultat a le `type` comme préfixe, puis la valeur en chiffres hexadécimaux, la lettre `x` et une somme de contrôle calculée avec [HASH()](../globals/) à partir de la valeur, de la `key` et du `type`.\n\nN'importe qui peut relire la valeur : n'utilise donc pas la méthode pour cacher des données. La clé permet seulement à [DECRYPT()](../globals/) de savoir si le texte a été modifié.\n\nExample: Encoder et décoder\n```js\nvar text = ENCRYPT('hello', 'secret');\n\nconsole.log(text); // 68656c6c6fxds46dr\nconsole.log(DECRYPT(text, 'secret')); // hello\nconsole.log(DECRYPT(text, 'other')); // undefined\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nLit ou écrit des variables d'environnement.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | Le nom, ou un objet contenant des noms et des valeurs. |\n| `value` | `Object` | no |  | La valeur à écrire. |\n\nReturns: `Object` La valeur de la variable.\n\nLes variables sont stockées dans [DEF.env](../def/). Un texte peut y faire référence sous la forme `[name]` : les paths, les adresses et les valeurs de configuration remplacent cette notation par la valeur. Passe un objet pour écrire plusieurs variables. Chaque écriture émet l'[événement](../events/) `env`.\n\nExample: Utiliser une variable dans un texte\n```js\nENV('api', '/api/v1/');\nconsole.log(ENV('api')); // /api/v1/\nconsole.log('[api]users/'.env()); // /api/v1/users/\n```\n\n### ENVIRONMENT(name, [version], [language], [env])\n\nType: `method`\n\nDéfinit la clé de stockage, la version, la langue et les variables d'environnement de l'application.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La clé utilisée dans `localStorage`. |\n| `version` | `String` | no |  | La version de l'application. |\n| `language` | `String` | no |  | La langue de l'application. |\n| `env` | `Object` | no |  | Les variables d'environnement. |\n\nLa méthode assigne [DEF.localstorage](../def/), [DEF.version](../def/) et [DEF.language](../def/), et passe `env` à [ENV()](../globals/). Appelle-la juste après le script de la bibliothèque, pour que l'application lise son propre stockage.\n\nExample: Configurer une application\n```js\nENVIRONMENT('myapp', '1.0', 'en', { title: 'My app' });\n\nconsole.log(DEF.localstorage, DEF.version, DEF.language); // myapp 1.0 en\nconsole.log(ENV('title')); // My app\n```\n\n### ERROR(response, [success], [error])\n\nType: `method`\n\nVérifie si une réponse contient des erreurs et exécute le gestionnaire correspondant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | La réponse à vérifier. |\n| `success` | `Function|String` | no |  | S'exécute quand il n'y a pas d'erreur. |\n| `error` | `Function|String` | no |  | S'exécute quand il y a une erreur. |\n\nReturns: `Boolean` `true` quand la réponse contient une erreur.\n\nUne réponse est une erreur quand c'est un objet `Error`, quand elle possède une propriété `error` ou quand c'est un tableau dont le premier élément en possède une. Une erreur émet l'[événement](../events/) `ERROR`.\n\n`success` et `error` peuvent être des fonctions, ou des noms pour [SEEX()](../globals/).\n\nAppelle `ERROR(success, [error])` sans réponse pour créer une fonction que tu peux passer comme callback.\n\nExample: Vérifier une réponse\n```js\nconsole.log(ERROR({ id: 1 })); // false\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\n```\n\nExample: Créer un callback\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 1\n});\n\ncallback({ id: 1 });\n```\n\n### ERRORS(path, callback)\n\nType: `method`\n\nRenvoie les composants invalides d'un path ou d'un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|jQuery` | yes |  | Un path, ou un élément qui contient les composants. |\n| `callback` | `Function` | yes |  | Une fonction qui reçoit un tableau de [composants](../component/). |\n\nExample: Valider un formulaire\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.validate = function(value) {\n\t\treturn !!value;\n\t};\n});\n\nON('ready', function() {\n\tERRORS('form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une fonction par son nom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La cible de l'appel. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nLa forme de `name` détermine ce qui est appelé :\n\n| Nom | Appelle |\n| --- | --- |\n| `name` | Une fonction globale. |\n| `FUNC.name` | Une fonction située à un path. |\n| `plugin/method` | Une méthode d'un [plugin](../plugin/). |\n| `*/method` | Une méthode du plugin common. |\n| `-component/method` | Une méthode de composant, via [SETTER()](../globals/). |\n| `#event` | Un événement, via [EMIT()](../globals/). |\n\nAjoute le flag `@important` pour réessayer toutes les 500 millisecondes jusqu'à ce que la fonction existe, par exemple `EXEC('app/refresh @important')`. `EXE()` est la même fonction sous un autre nom.\n\nExample: Appeler une fonction par son path\n```js\nFUNC.sum = function(a, b) {\n\tconsole.log(a + b); // 5\n};\n\nEXEC('FUNC.sum', 2, 3);\n```\n\nExample: Attendre une fonction\n```js\nEXEC('app.start @important', 'now');\n\nsetTimeout(function() {\n\twindow.app = {};\n\tapp.start = function(value) {\n\t\tconsole.log(value); // now\n\t};\n}, 100);\n```\n\n### EXTENSION(name, [config], callback)\n\nType: `method`\n\nÉtend un composant ou un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du composant, ou `@` suivi du nom du plugin. |\n| `config` | `String|Object` | no |  | La configuration ajoutée à chaque instance. |\n| `callback` | `Function` | yes |  | Une fonction `(instance, config, cls)`, où `cls` est la classe CSS de l'instance. `this` est l'instance. |\n\nLe `callback` s'exécute pour chaque instance existante et pour chaque nouvelle instance, juste après la déclaration, toujours avec les mêmes arguments. Pour un plugin, écris `@` devant son nom.\n\nExample: Ajouter une méthode à un composant\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nEXTENSION('box', 'color:red', function(self, config) {\n\tself.describe = function() {\n\t\treturn config.color;\n\t};\n});\n\nON('ready', function() {\n\tconsole.log(FIND('box').describe()); // red\n});\n</script>\n```\n\n### FIND(selector, [all])\n\nType: `method`\n\nTrouve un composant prêt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Le nom, l'identifiant ou le path. |\n| `all` | `Boolean` | no | `false` | Renvoie toutes les correspondances dans un tableau. |\n\nReturns: `Component|Array` Le premier [composant](../component/), ou un tableau quand `all` vaut `true`.\n\nLe `selector` est un nom de composant, `#id` pour un identifiant, ou `.path` pour un path.\n\nExample: Trouver par nom et par path\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('field').name); // field\n\tconsole.log(FIND('.form.name').path.path); // form.name\n\tconsole.log(FIND('field', true).length); // 1\n});\n</script>\n```\n\n### FLAGS(flags, [callback])\n\nType: `method`\n\nÉmet des flags puis exécute une fonction.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Les flags, par exemple `@loading @save`. |\n| `callback` | `Function` | no |  | Une fonction qui s'exécute ensuite. |\n\nChaque flag émet l'événement `@flag name`, que tu peux capturer avec [ON()](../globals/). Consulte [Flags et modificateurs de path](../../guides/flags/).\n\nExample: Capturer un flag\n```js\nON('@flag loading', function() {\n\tconsole.log('flag captured'); // flag captured\n});\n\nFLAGS('@loading', function() {\n\tconsole.log('done'); // done\n});\n```\n\n### FN(code)\n\nType: `method`\n\nCompile une fonction fléchée à partir d'une chaîne.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | yes |  | Le code de la fonction. |\n\nReturns: `Function` La fonction compilée.\n\nLe code peut avoir jusqu'à quatre arguments. Un code sans flèche devient une fonction avec l'argument `value`. Les fonctions compilées sont mises en cache.\n\nExample: Compiler des fonctions\n```js\nconsole.log(FN('n => n * 2')(4)); // 8\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value + 1')(1)); // 2\n```\n\n### FREE()\n\nType: `method`\n\nSupprime les composants, les liaisons et les plugins dont les éléments ont quitté le DOM.\n\nLa bibliothèque effectue ce nettoyage toutes les minutes. Appelle cette fonction quand tu as besoin que les instances soient supprimées immédiatement.\n\nExample: Supprimer un composant détaché\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\t$('ui-component').remove();\n\tFREE();\n\tconsole.log(COMPONENTS('form').length); // 0\n});\n</script>\n```\n\n### FUNC\n\nType: `property`\n\nUn objet vide pour les fonctions de ton application.\n\nReturns: `Object` Le conteneur.\n\nLes fonctions stockées ici peuvent être appelées par leur path avec [EXEC()](../globals/).\n\nExample: Stocker une fonction\n```js\nFUNC.hello = function() {\n\treturn 'Hello';\n};\n\nconsole.log(FUNC.hello()); // Hello\n```\n\n### GET(path, [noflags])\n\nType: `method`\n\nLit la valeur d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec des flags. |\n| `noflags` | `Boolean` | no | `false` | Lit la valeur sans appliquer les flags. |\n\nReturns: `Object` La valeur.\n\nQuand le path contient des flags, ils sont appliqués aux composants du path : `GET('form @reset')` renvoie la valeur et réinitialise leur état. Consulte [Paths](../../guides/paths/).\n\nExample: Lire des valeurs\n```js\nSET('user.name', 'Peter');\n\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\n### GUID([length])\n\nType: `method`\n\nGénère un identifiant aléatoire.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | no |  | La longueur de l'identifiant. |\n\nReturns: `String` L'identifiant.\n\nSans `length`, le résultat a la forme d'un UUID de 36 caractères. Avec `length`, c'est une chaîne de lettres minuscules et de chiffres.\n\nExample: Générer des identifiants\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value)\n\nType: `method`\n\nCrée un hachage numérique d'une valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Number|Boolean|Object|Date` | yes |  | La valeur. |\n\nReturns: `Number` Le hachage.\n\nUn nombre est renvoyé tel quel, `true` donne `1`, une date donne son temps en millisecondes et une valeur vide donne `0`. Les objets sont d'abord sérialisés.\n\nExample: Hacher une chaîne\n```js\nconsole.log(HASH('hello')); // 99162322\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nVérifie si un élément imbriqué dans la page est masqué.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Un élément placé à l'intérieur d'un autre élément du body. |\n\nReturns: `Boolean` `true` quand l'élément est masqué.\n\nL'élément est considéré comme masqué quand il n'a pas de parent de décalage, ce qui est le cas avec `display:none`. Un élément absent est aussi considéré comme masqué. Pour vérifier la position dans la zone d'affichage, utilise [VISIBLE()](../globals/).\n\nExample: Vérifier un élément\n```html\n<main><div id=\"a\" style=\"display:none\"></div><div id=\"b\"></div></main>\n\n<script>\nconsole.log(HIDDEN($('#a'))); // true\nconsole.log(HIDDEN($('#b'))); // false\n</script>\n```\n\n### IMPORT(url, [target], [callback], [prepare])\n\nType: `method`\n\nCharge un script, une feuille de style ou un morceau de HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'adresse et des mots-clés facultatifs. |\n| `target` | `String|jQuery|Element` | no | `body` | L'élément qui reçoit le contenu HTML. |\n| `callback` | `Function` | no |  | Une fonction qui s'exécute quand le contenu est chargé. |\n| `prepare` | `Function` | no |  | Une fonction qui reçoit le HTML et renvoie le texte à insérer. |\n\nLes adresses se terminant par `.js` ou `.css` sont ajoutées à l'en-tête de la page. Toute autre adresse est téléchargée et insérée dans `target`. Des mots-clés peuvent être combinés avec l'adresse :\n\n| Mot-clé | Signification |\n| --- | --- |\n| `<name>` | Ignore l'importation quand la variable globale `name` existe. |\n| `.js`, `.css`, `.html` | Définit le type du contenu quand l'adresse ne l'indique pas. |\n| `@singleton` | N'importe l'adresse qu'une seule fois. |\n| `@prepend` | Insère le contenu au début de `target`. |\n\nQuand un script ou une feuille de style ne peut pas être chargé, la bibliothèque écrit un avertissement dans la console et `callback` s'exécute quand même.\n\nConsulte [Importer du contenu](../../guides/importing/).\n\nExample: Insérer un morceau de HTML\n```html\n<div id=\"menu\"></div>\n\n<script>\nIMPORT('/parts/menu.html', '#menu', function() {\n\tconsole.log($('#menu').html()); // <b>Menu</b>\n});\n</script>\n```\n\nExample: Ignorer une bibliothèque déjà présente\n```js\nIMPORT('<jQuery> /js/jquery.min.js', function() {\n\tconsole.log('jQuery is available'); // jQuery is available\n});\n```\n\n### INC(path, [value])\n\nType: `method`\n\nAugmente le nombre stocké dans un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `value` | `Number` | no | `1` | La quantité à ajouter. |\n\nUn path vide démarre à `0`. Une chaîne est convertie en nombre. Utilise une `value` négative pour diminuer le nombre.\n\nExample: Augmenter un compteur\n```js\nSET('stats.visits', 10);\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 16\n```\n\n### inDOM(element)\n\nType: `method`\n\nVérifie si un élément est attaché au body du document.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | Un élément DOM. |\n\nReturns: `Boolean` `true` quand l'élément est attaché, sinon rien.\n\nExample: Vérifier un élément\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(!!inDOM(document.createElement('div'))); // false\n```\n\n### isIE\n\nType: `property`\n\nIndique si le navigateur est Internet Explorer.\n\nReturns: `Boolean` Le résultat de la détection.\n\n### isMOBILE\n\nType: `property`\n\nIndique si l'agent utilisateur appartient à un appareil mobile.\n\nReturns: `Boolean` Le résultat de la détection.\n\n### isPRIVATEMODE\n\nType: `property`\n\nIndique si `localStorage` est indisponible, comme dans certaines fenêtres privées. La valeur est définie au démarrage de la bibliothèque : lis-la donc à partir de l'événement `ready`.\n\nReturns: `Boolean` Le résultat de la détection.\n\n### isROBOT\n\nType: `property`\n\nIndique si l'agent utilisateur appartient à un moteur de recherche ou à un robot d'exploration.\n\nReturns: `Boolean` Le résultat de la détection.\n\n### isSTANDALONE\n\nType: `property`\n\nIndique si la page s'exécute comme une application web installée.\n\nReturns: `Boolean` Le résultat de la détection.\n\n### isTOUCH\n\nType: `property`\n\nIndique si l'appareil prend en charge la saisie tactile.\n\nReturns: `Boolean` Le résultat de la détection.\n\n### jComponent\n\nType: `property`\n\nL'objet principal de la bibliothèque.\n\nReturns: `Object` L'objet principal.\n\nLe même objet que [MAIN](../main/).\n\n### LOCALIZE(text)\n\nType: `method`\n\nCharge des traductions dans le dictionnaire.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Les lignes contenant les traductions. |\n\nChaque ligne a la forme `key : translation`, et les lignes commençant par `//` sont ignorées. La clé est le hachage du texte d'origine, en base 36, avec le préfixe `T`. Les traductions sont stockées dans [DEF.dictionary](../def/) et utilisées par [TRANSLATE()](../globals/). Consulte [Localisation](../../guides/localization/).\n\nExample: Charger une traduction\n```js\nvar key = 'T' + HASH('Hello').toString(36);\n\nLOCALIZE(key + ' : Hola');\nconsole.log(TRANSLATE('@(Hello)')); // Hola\n```\n\n### M\n\nType: `property`\n\nUn nom court de l'objet principal.\n\nReturns: `Object` L'objet principal.\n\nLe même objet que [MAIN](../main/).\n\n### MAIN\n\nType: `property`\n\nL'objet principal de la bibliothèque.\n\nReturns: `Object` L'objet principal.\n\nDécrit sur sa propre page : [MAIN](../main/).\n\n### MONTHS\n\nType: `property`\n\nLes noms anglais des mois, en commençant par janvier.\n\nReturns: `Array` Douze chaînes.\n\nExample: Lire un mois\n```js\nconsole.log(MONTHS[0]); // January\n```\n\n### NEWUIBIND(element, [path], [config])\n\nType: `method`\n\nCrée une liaison de données sur un élément depuis le code.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | L'élément. |\n| `path` | `String` | no |  | Le path à observer. |\n| `config` | `String` | no |  | Les commandes de liaison. |\n\nLa liaison fonctionne comme l'élément [ui-bind](../ui-bind/). Sans `path` ni `config`, les valeurs sont lues dans les attributs de l'élément.\n\nExample: Lier un élément à un path\n```html\n<div id=\"name\"></div>\n\n<script>\nSET('user.name', 'Peter');\nNEWUIBIND($('#name'), 'user.name', 'text:value');\n\nsetTimeout(function() {\n\tconsole.log($('#name').html()); // Peter\n}, 200);\n</script>\n```\n\n### NODEINDEXOF(element)\n\nType: `method`\n\nRenvoie la position d'un élément parmi ses frères.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | L'élément. |\n\nReturns: `Number` La position, à partir de zéro.\n\nExample: Lire une position\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li></ul>\n\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, reference, [before])\n\nType: `method`\n\nInsère un élément à côté d'un autre élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | L'élément à insérer. |\n| `reference` | `jQuery|Element` | yes |  | L'élément de référence. |\n| `before` | `Boolean` | no | `false` | Insère l'élément devant la référence. |\n\nExample: Déplacer un élément\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEINSERT($('#c'), $('#a'), true);\nconsole.log($('ul').text()); // CAB\n</script>\n```\n\n### NODEMOVE(element, [up])\n\nType: `method`\n\nDéplace un élément d'une position parmi ses frères.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | L'élément. |\n| `up` | `Boolean` | no | `false` | Déplace l'élément vers le début. Sinon, il se déplace vers la fin. |\n\nExample: Réorganiser une liste\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BAC\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nUne fonction qui ne fait rien.\n\nUtilise-la comme callback par défaut.\n\nExample: Un callback par défaut\n```js\nvar callback = NOOP;\nconsole.log(typeof(callback)); // function\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nVérifie si la page est en arrière-plan.\n\nReturns: `Boolean` `true` quand le document est masqué.\n\nExample: Vérifier la page\n```js\nconsole.log(NOTFOCUSED()); // false\n```\n\n### NOW\n\nType: `property`\n\nLa date actuelle, actualisée une fois par minute.\n\nReturns: `Date` La date.\n\nUtilise-la quand une précision d'une minute suffit. Elle évite de créer un nouvel objet `Date` à chaque utilisation.\n\nExample: Lire la date\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path)\n\nType: `method`\n\nDéfinit un path à `null`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\n`NULL()` est la même fonction sous un autre nom.\n\nExample: Effacer une valeur\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### OFF(name, [callback])\n\nType: `method`\n\nSupprime des gestionnaires d'événements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `callback` | `Function` | no |  | Le gestionnaire à supprimer. |\n\nSans `callback`, tous les gestionnaires de l'événement sont supprimés. Plusieurs événements peuvent être combinés avec `+`.\n\nExample: Supprimer un gestionnaire\n```js\nvar count = 0;\nvar handler = function() {\n\tcount++;\n};\n\nON('refresh', handler);\nEMIT('refresh');\nOFF('refresh', handler);\nEMIT('refresh');\nconsole.log(count); // 1\n```\n\n### ON(name, callback, [init])\n\nType: `method`\n\nEnregistre un gestionnaire d'événements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `callback` | `Function` | yes |  | Le gestionnaire. Il reçoit les arguments de l'événement. |\n| `init` | `Boolean` | no | `false` | Appelle aussi le gestionnaire une fois, sans arguments. |\n\nPlusieurs événements peuvent être combinés avec `+`, par exemple `saved + removed`. Un gestionnaire pour `ready` ou `init` s'exécute immédiatement quand la bibliothèque a démarré. Les événements de la bibliothèque sont répertoriés dans [Événements](../events/).\n\nExample: Capturer deux événements\n```js\nvar count = 0;\n\nON('saved + removed', function() {\n\tcount++;\n});\n\nEMIT('saved');\nEMIT('removed');\nconsole.log(count); // 2\n```\n\n### PARSE(value)\n\nType: `method`\n\nAnalyse du JSON et convertit les chaînes de date en objets `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Le JSON, un sélecteur ou un objet. |\n\nReturns: `Object` La valeur analysée, ou `null`.\n\nUne valeur commençant par `#` ou `.` est un sélecteur : le JSON est lu dans le contenu de cet élément. Un objet est renvoyé tel quel. Un JSON invalide renvoie `null`.\n\nExample: Analyser du JSON\n```js\nvar data = PARSE('{\"created\":\"2024-05-01T10:00:00.000Z\"}');\nconsole.log(data.created instanceof Date); // true\nconsole.log(PARSE('invalid')); // null\n```\n\n### PIPE(name, [data], callback, [scope])\n\nType: `method`\n\nAppelle une opération à l'adresse indiquée dans `DEF.pipe`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'opération, éventuellement suivi de mots-clés. |\n| `data` | `Object` | no |  | Les données de l'opération. |\n| `callback` | `Function|String` | yes |  | Une fonction ou un path qui reçoit la réponse. |\n| `scope` | `Object` | no | `window` | L'objet dans lequel un path `callback` est résolu. |\n\nFonctionne comme [API()](../globals/), avec l'adresse tirée de [DEF.pipe](../def/).\n\nExample: Appeler une opération\n```js\nDEF.pipe = '/pipe/';\n\nPIPE('orders_list', function(response) {\n\tconsole.log(response.length); // 1\n});\n```\n\n### PLUGIN(name, [config], callback, [dependencies])\n\nType: `method`\n\nEnregistre une déclaration de plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du plugin. |\n| `config` | `String` | no |  | La configuration par défaut sous la forme `key:value;key:value`. |\n| `callback` | `Function` | yes |  | La déclaration : `function(self, config)`. |\n| `dependencies` | `String|Array` | no |  | Les adresses à importer d'abord. |\n\nLe `callback` s'exécute quand un élément [ui-plugin](../ui-plugin/) ayant ce path est créé. Le nom `*` enregistre le plugin common. Consulte [Plugins](../../guides/plugins/) et l'objet [Plugin](../plugin/).\n\nExample: Déclarer un plugin\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('Hello ' + name); // Hello Peter\n\t};\n});\n\nON('ready', function() {\n\tEXEC('users/hello', 'Peter');\n});\n</script>\n```\n\n### PLUGINS\n\nType: `property`\n\nLes instances de plugin en cours d'exécution, par nom.\n\nReturns: `Object` Les instances de [plugin](../plugin/).\n\nExample: Lire un plugin\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('ready', function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n});\n</script>\n```\n\n### PREF\n\nType: `property`\n\nLes préférences persistantes de l'utilisateur.\n\nReturns: `Object` Les préférences.\n\nDécrit sur sa propre page : [PREF](../pref/).\n\n### PUSH(path, value)\n\nType: `method`\n\nAjoute un élément au tableau stocké dans un path et prévient le path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path d'un tableau existant. |\n| `value` | `Object` | yes |  | L'élément. |\n\nÉcris `^` devant le path pour ajouter l'élément au début du tableau.\n\nExample: Ajouter des éléments\n```js\nSET('tags', ['b']);\nPUSH('tags', 'c');\nPUSH('^tags', 'a');\nconsole.log(GET('tags')); // [\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], data)\n\nType: `method`\n\nAjoute des données à une adresse sous forme de chaîne de requête.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | L'adresse. |\n| `data` | `Object` | yes |  | Les valeurs. |\n\nReturns: `String` L'adresse avec la chaîne de requête.\n\nLes valeurs vides sont ignorées, les dates sont converties en chaînes ISO et les tableaux sont joints par des virgules. L'`url` peut commencer par une méthode HTTP.\n\nExample: Construire des adresses\n```js\nconsole.log(QUERIFY('/users/', { page: 2, q: 'a b' })); // /users/?page=2&q=a%20b\nconsole.log(QUERIFY('GET /users/', { page: 2 })); // GET /users/?page=2\nconsole.log(QUERIFY({ page: 2 })); // ?page=2\n```\n\n### REPO\n\nType: `property`\n\nUn objet vide pour les données partagées de ton application.\n\nReturns: `Object` Le conteneur.\n\nExample: Stocker une valeur\n```js\nREPO.title = 'My app';\nconsole.log(REPO.title); // My app\n```\n\n### RESET(path)\n\nType: `method`\n\nRéinitialise l'état des composants liés à un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nLes états `touched` et `modified` reviennent à leurs valeurs par défaut. La valeur du path ne change pas.\n\nExample: Réinitialiser un formulaire\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tSET('form.name @change', 'Peter');\n\tconsole.log(FIND('field').config.modified); // 1\n\tRESET('form');\n\tconsole.log(FIND('field').config.modified); // 0\n\tconsole.log(GET('form.name')); // Peter\n});\n</script>\n```\n\n### SCROLLBAR(element, [options])\n\nType: `method`\n\nAjoute une barre de défilement personnalisée à un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'élément. |\n| `options` | `Object` | no |  | Les options. |\n\nReturns: `Object` La barre de défilement.\n\nOptions :\n\n| Option | Type | Description |\n| --- | --- | --- |\n| `native` | Boolean | Conserve la barre de défilement du navigateur et définit uniquement le débordement. |\n| `orientation` | String | `x` ou `y`. Par défaut, les deux directions sont actives. |\n| `visibleX`, `visibleY` | Boolean | Garde la piste visible quand il n'y a rien à faire défiler. |\n| `wrap` | Boolean | `false` utilise le contenu existant comme zone de défilement. |\n| `controls` | jQuery | L'élément qui reçoit les pistes de la barre de défilement. |\n| `shadow` | Boolean | Ajoute des ombres sur les bords défilants. |\n| `padding` | Number | La distance entre les pistes et le bord. Valeur par défaut : `5`. |\n| `minsize` | Number | La taille minimale de la barre. Valeur par défaut : `50`. |\n| `thickness` | Number | L'épaisseur utilisée quand le CSS ne la définit pas. Valeur par défaut : `10`. |\n| `margin`, `marginX`, `marginY` | Number | Ajustent la taille de la zone de défilement. |\n| `offsetX`, `offsetY` | Number | Ajustent la taille mesurée de l'élément. |\n| `floating` | Boolean | `false` réserve de l'espace pour les barres. |\n| `parent` | String\\|jQuery | L'élément dont la taille est utilisée. |\n| `interval` | Number | Le temps entre les vérifications de taille, en millisecondes. Valeur par défaut : `54321`. |\n| `autoresize` | Boolean | `false` arrête de mesurer à nouveau l'élément quand la fenêtre est redimensionnée. Valeur par défaut : `true`. |\n| `onscroll`, `onidle`, `onresize` | Function | Des gestionnaires qui reçoivent la barre de défilement. |\n\nL'objet renvoyé fournit :\n\n| Membre | Description |\n| --- | --- |\n| `area` | L'élément qui défile. |\n| `body` | L'élément contenant le contenu. |\n| `element` | L'élément d'origine. |\n| `resize()` | Mesure de nouveau l'élément. |\n| `scrollTop([value])` | Lit ou définit la position verticale. Une chaîne comme `'+20'` déplace par rapport à la position actuelle. |\n| `scrollLeft([value])` | Lit ou définit la position horizontale, selon les mêmes règles. |\n| `scrollBottom(offset)` | Fait défiler jusqu'en bas, moins `offset`. |\n| `scrollRight(offset)` | Fait défiler jusqu'au bord droit, moins `offset`. |\n| `scroll(x, y)` | Fait défiler jusqu'à une position. |\n| `sync(element, [direction])` | Synchronise le défilement avec un autre élément. `direction` vaut `x` ou `y`. |\n| `destroy()` | Arrête la barre de défilement. |\n\nLes [événements](../events/) `scroll` et `scrollidle` signalent le défilement.\n\nExample: Faire défiler depuis le code\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nvar scrollbar = SCROLLBAR($('#panel'));\n\nscrollbar.area.css('overflow', 'auto');\nscrollbar.resize(false, true);\nscrollbar.scrollTop(30);\nconsole.log(scrollbar.scrollTop()); // 30\nscrollbar.scrollTop('+20');\nconsole.log(scrollbar.scrollTop()); // 50\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nRenvoie la largeur de la barre de défilement du navigateur.\n\nReturns: `Number` La largeur en pixels.\n\nExample: Lire la largeur\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une fonction ou écrit une valeur, selon le nom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La cible. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nLa forme `plugin/method` appelle une méthode de plugin, et le nom d'une fonction globale appelle cette fonction. Tout autre nom est un path, dans lequel `a` est écrit avec [SET()](../globals/).\n\nExample: Écrire dans un path\n```js\nSEEX('form.name', 'Peter');\nconsole.log(GET('form.name')); // Peter\n```\n\nExample: Appeler une fonction globale\n```js\nwindow.notify = function(text) {\n\tconsole.log(text); // Saved\n};\n\nSEEX('notify', 'Saved');\n```\n\n### SET(path, value)\n\nType: `method`\n\nÉcrit une valeur dans un path et prévient tout ce qui l'observe.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec des flags. |\n| `value` | `Object` | yes |  | La valeur, ou une fonction `(current)` qui la renvoie. |\n\nLes objets manquants le long du path sont créés. Les flags font partie du path, par exemple `form.name @change`. La forme `path[]` ajoute la valeur à la fin d'un tableau. Une fonction passée comme `value` reçoit la valeur actuelle, et son résultat est écrit. Consulte [Paths](../../guides/paths/) et [Flags et modificateurs de path](../../guides/flags/).\n\nExample: Écrire des valeurs\n```js\nSET('user.name', 'Peter');\nSET('user.tags[]', 'admin');\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"tags\":[\"admin\"]}\n```\n\nExample: Écrire une valeur à partir de la valeur actuelle\n```js\nSET('cart.count', 1);\nSET('cart.count', value => value + 1);\nconsole.log(GET('cart.count')); // 2\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une méthode sur les composants qui correspondent à un sélecteur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le sélecteur et la méthode. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nLe `name` a la forme `selector/method` :\n\n| Sélecteur | Correspond à |\n| --- | --- |\n| `name` | Les composants portant ce nom. |\n| `#id` | Le composant ayant cet identifiant. |\n| `*` | Tous les composants qui possèdent la méthode. |\n\nLe flag `@important` réessaie toutes les 500 millisecondes jusqu'à ce qu'un composant correspondant possédant la méthode existe. Un composant déclaré comme différé est créé par le premier appel, sauf si le nom commence par `!`.\n\nExample: Appeler une méthode de composant\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log(value); // 5\n\t};\n});\n\nON('ready', function() {\n\tSETTER('counter/add', 5);\n});\n</script>\n```\n\n### setTimeout2(name, callback, timeout, [limit], [param])\n\nType: `method`\n\nExécute une fonction après un délai, en relançant le délai à chaque appel portant le même nom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du minuteur. |\n| `callback` | `Function` | yes |  | La fonction. |\n| `timeout` | `Number` | yes |  | Le délai en millisecondes. |\n| `limit` | `Number` | no |  | Le nombre maximal d'appels pendant une période d'attente. |\n| `param` | `Object` | no |  | L'argument de la fonction. |\n\nReturns: `String` Le nom du minuteur. Un appel ignoré à cause de `limit` ne renvoie rien.\n\nAvec `limit`, le délai est relancé au maximum `limit` fois. Les appels suivants sont ignorés jusqu'à l'exécution de la fonction, qui ne peut donc pas être reportée indéfiniment.\n\nExample: Exécuter une fois après le dernier appel\n```js\nvar count = 0;\nvar run = function() {\n\tcount++;\n\tconsole.log(count); // 1\n};\n\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\n```\n\n### STRINGIFY(value, [compress], [fields], [encrypt])\n\nType: `method`\n\nSérialise une valeur en JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur. |\n| `compress` | `Boolean` | no | `false` | Supprime les valeurs vides. |\n| `fields` | `Array|Object|Function` | no |  | Les clés à conserver. |\n| `encrypt` | `Boolean|String` | no |  | `true` encode le JSON avec [ENCRYPT()](../globals/). Une chaîne fait de même et sert de clé. |\n\nReturns: `String` Le JSON.\n\nAvec `compress` à `true`, les chaînes sont épurées de leurs espaces de début et de fin, et les chaînes vides, `false` et `null` sont omis. L'argument `fields` sélectionne les clés : un tableau de clés autorisées, un objet dans lequel `false` exclut une clé, ou une fonction `(key, value)` qui renvoie `true` pour les clés à conserver.\n\nExample: Compresser et filtrer\n```js\nvar data = { name: ' Peter ', note: '', age: 30 };\n\nconsole.log(STRINGIFY(data, true)); // {\"name\":\"Peter\",\"age\":30}\nconsole.log(STRINGIFY(data, false, ['age'])); // {\"age\":30}\n```\n\nExample: Encoder le JSON\n```js\nvar text = STRINGIFY({ id: 5 }, false, null, 'secret');\nconsole.log(DECRYPT(text, 'secret')); // {\"id\":5}\n```\n\n### STYLE(value, [id], [selector])\n\nType: `method`\n\nAjoute du CSS à la page.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Le CSS. |\n| `id` | `String` | no |  | L'identifiant de l'élément style. |\n| `selector` | `String` | no |  | Un sélecteur qui préfixe chaque règle. |\n\nUn élément ayant le même `id` est remplacé. L'élément a pour identifiant `css` suivi de `id`. Avec `selector`, chaque règle est préfixée par ce sélecteur.\n\nExample: Ajouter des styles à portée limitée\n```js\nSTYLE('b { color: red }', 'theme', '.panel');\nconsole.log($('#csstheme').html()); // .panel b{ color: red }\n```\n\n### TAPI(name, [data], callback, [scope])\n\nType: `method`\n\nAppelle une opération d'API Total.js à l'adresse indiquée dans `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'opération, éventuellement suivi de mots-clés. |\n| `data` | `Object` | no |  | Les données de l'opération. |\n| `callback` | `Function|String` | yes |  | Une fonction ou un path qui reçoit la réponse. |\n| `scope` | `Object` | no | `window` | L'objet dans lequel un path `callback` est résolu. |\n\nFonctionne comme [API()](../globals/), avec l'adresse tirée de [DEF.api](../def/).\n\nExample: Stocker une réponse dans un path\n```js\nDEF.api = '/admin/api/';\n\nTAPI('users_list', { page: 1 }, 'users.items');\n\nWATCH('users.items', function(value) {\n\tconsole.log(value.length); // 2\n});\n```\n\n### TEMP\n\nType: `property`\n\nUn objet pour les données de courte durée.\n\nReturns: `Object` Le conteneur.\n\nLa bibliothèque le remplace par un objet vide toutes les minutes.\n\nExample: Stocker une valeur\n```js\nTEMP.result = 5;\nconsole.log(TEMP.result); // 5\n```\n\n### TOGGLE(path)\n\nType: `method`\n\nInverse la valeur booléenne d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nExample: Inverser une valeur\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### Total\n\nType: `property`\n\nL'objet principal de la bibliothèque.\n\nReturns: `Object` L'objet principal.\n\nLe même objet que [MAIN](../main/).\n\n### TRANSLATE(text)\n\nType: `method`\n\nRemplace le balisage `@(text)` par des traductions.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Le texte contenant le balisage. |\n\nReturns: `String` Le texte traduit.\n\nUn texte sans traduction reste dans sa langue d'origine. Les traductions sont chargées avec [LOCALIZE()](../globals/).\n\nExample: Traduire un texte\n```js\nLOCALIZE('T' + HASH('Yes').toString(36) + ' : Ano');\nconsole.log(TRANSLATE('@(Yes) / @(No)')); // Ano / No\n```\n\n### UNAUTHORIZED(...permissions)\n\nType: `method`\n\nVérifie les permissions de l'utilisateur connecté.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `permissions` | `String` | yes |  | Une ou plusieurs permissions. |\n\nReturns: `Boolean` `true` quand l'accès est refusé.\n\nLa méthode lit la variable globale `user`. Un utilisateur pour lequel `sa` ou `su` est défini possède toutes les permissions. Sinon, les permissions proviennent de `user.permissions` ou `user.roles`, sous forme de tableau ou d'objet. Le résultat est `true` quand l'utilisateur ne possède aucune des permissions indiquées, ou quand `user` n'existe pas.\n\nExample: Vérifier une permission\n```js\nwindow.user = { roles: ['editor'] };\n\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [callback])\n\nType: `method`\n\nRetire des observateurs d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. Plusieurs paths peuvent être combinés avec `+`. |\n| `callback` | `Function` | no |  | L'observateur à retirer. |\n\nSans `callback`, tous les observateurs du path sont retirés.\n\nExample: Arrêter l'observation\n```js\nvar count = 0;\nvar watcher = function() {\n\tcount++;\n};\n\nWATCH('form.name', watcher);\nSET('form.name', 'A');\nUNWATCH('form.name', watcher);\nSET('form.name', 'B');\nconsole.log(count); // 1\n```\n\n### UPD(path)\n\nType: `method`\n\nPrévient un path après une modification directe de sa valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec des flags. |\n\n`UPDATE()` est la même fonction sous un autre nom.\n\nExample: Prévenir après une modification directe\n```js\nwindow.form = { name: 'A' };\n\nWATCH('form.name', function(value) {\n\tconsole.log(value); // B\n});\n\nform.name = 'B';\nUPD('form.name');\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nVérifie la position verticale d'un élément par rapport à la zone d'affichage.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | L'élément. |\n| `threshold` | `Number` | no | `0` | Le nombre de pixels de l'élément qui doivent se trouver dans la zone d'affichage. |\n| `mode` | `String` | no | `visible` | `visible`, `above` ou `below`. |\n\nReturns: `Boolean` Le résultat de la vérification.\n\nLe `mode` sélectionne la vérification : `visible` teste si l'élément se trouve dans la zone d'affichage, `above` s'il est au-dessus et `below` s'il est en dessous. Un élément masqué renvoie `false`.\n\nExample: Vérifier un élément\n```html\n<div id=\"top\">Top</div>\n<div style=\"height:5000px\"></div>\n<div id=\"far\">Far</div>\n\n<script>\nconsole.log(VISIBLE($('#top'))); // true\nconsole.log(VISIBLE($('#far'))); // false\nconsole.log(VISIBLE($('#far'), 0, 'below')); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nUn nom court de l'objet `window`.\n\nReturns: `Object` L'objet `window`.\n\nExample: Comparer les objets\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback)\n\nType: `method`\n\nExécute une fonction quand une condition est remplie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | Une fonction ou un path. |\n| `callback` | `Function` | yes |  | La fonction à exécuter. |\n\nLa condition est vérifiée immédiatement, puis toutes les 500 millisecondes. Une fonction doit renvoyer une valeur truthy. Pour un path, l'attente se termine quand le path contient une valeur truthy.\n\nExample: Attendre une valeur\n```js\nWAIT('app.config', function() {\n\tconsole.log(GET('app.config.name')); // Demo\n});\n\nsetTimeout(function() {\n\tSET('app.config', { name: 'Demo' });\n}, 100);\n```\n\n### WARN(...values)\n\nType: `method`\n\nAffiche un avertissement dans la console du navigateur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `values` | `Object` | yes |  | Les valeurs à afficher. |\n\n### WATCH(path, callback, [init])\n\nType: `method`\n\nObserve les changements d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `callback` | `Function` | yes |  | Une fonction qui reçoit `(value, flags, path)` : la valeur observée, les flags et le path modifié. |\n| `init` | `Boolean` | no | `false` | Appelle aussi l'observateur une fois après l'enregistrement. |\n\nUn observateur s'exécute quand son propre path change, quand un path parent change et quand un path imbriqué en dessous change. Plusieurs paths peuvent être combinés avec `+`.\n\nExample: Observer un path\n```js\nWATCH('user.name', function(value, flags, path) {\n\tconsole.log(value, path); // Peter user.name\n});\n\nSET('user.name', 'Peter');\n```\n\n### WH\n\nType: `property`\n\nLa hauteur de la fenêtre en pixels.\n\nReturns: `Number` La hauteur.\n\nLa valeur est définie au démarrage de la bibliothèque et actualisée quand la fenêtre est redimensionnée.\n\nExample: Lire la hauteur\n```js\nON('ready', function() {\n\tconsole.log(typeof(WH)); // number\n});\n```\n\n### WIDTH([element])\n\nType: `method`\n\nRenvoie le nom de la taille d'appareil correspondant à la largeur d'un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | L'élément mesuré. |\n\nReturns: `String` Le nom de la taille.\n\nLes tailles `xs`, `sm`, `md` et `lg` sont définies dans [DEF.devices](../def/).\n\nExample: Mesurer un élément\n```html\n<div id=\"box\" style=\"width:800px\"></div>\n\n<script>\nconsole.log(WIDTH($('#box'))); // sm\n</script>\n```\n\n### WW\n\nType: `property`\n\nLa largeur de la fenêtre en pixels.\n\nReturns: `Number` La largeur.\n\nLa valeur est définie au démarrage de la bibliothèque et actualisée quand la fenêtre est redimensionnée.\n\nExample: Lire la largeur\n```js\nON('ready', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n","entries":[{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], callback, [onprogress], [scope], [id])","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(key, timeout, [callback])","since":"","deprecated":false},{"type":"method","name":"CACHE()","signature":"CACHE(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"CACHEPATH()","signature":"CACHEPATH(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, [callback])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [raw])","since":"","deprecated":false},{"type":"method","name":"CLRELOAD()","signature":"CLRELOAD(name, [callback])","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], callback, [dependencies], [css])","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"COMPONENTS(path)","since":"","deprecated":false},{"type":"method","name":"CONFIG()","signature":"CONFIG(selector, config)","since":"","deprecated":false},{"type":"property","name":"COOKIES","signature":"COOKIES","since":"","deprecated":false},{"type":"method","name":"COPY()","signature":"COPY(source, target)","since":"","deprecated":false},{"type":"method","name":"CSS()","signature":"CSS(value, [id], [selector])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(text, [key], [type])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"EMPTYARRAY","signature":"EMPTYARRAY","since":"","deprecated":false},{"type":"property","name":"EMPTYOBJECT","signature":"EMPTYOBJECT","since":"","deprecated":false},{"type":"method","name":"ENCRYPT()","signature":"ENCRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"method","name":"ENV()","signature":"ENV(name, [value])","since":"","deprecated":false},{"type":"method","name":"ENVIRONMENT()","signature":"ENVIRONMENT(name, [version], [language], [env])","since":"","deprecated":false},{"type":"method","name":"ERROR()","signature":"ERROR(response, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, callback)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], callback)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [all])","since":"","deprecated":false},{"type":"method","name":"FLAGS()","signature":"FLAGS(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(code)","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE()","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [noflags])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([length])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value)","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value])","since":"","deprecated":false},{"type":"method","name":"inDOM()","signature":"inDOM(element)","since":"","deprecated":false},{"type":"property","name":"isIE","signature":"isIE","since":"","deprecated":false},{"type":"property","name":"isMOBILE","signature":"isMOBILE","since":"","deprecated":false},{"type":"property","name":"isPRIVATEMODE","signature":"isPRIVATEMODE","since":"","deprecated":false},{"type":"property","name":"isROBOT","signature":"isROBOT","since":"","deprecated":false},{"type":"property","name":"isSTANDALONE","signature":"isSTANDALONE","since":"","deprecated":false},{"type":"property","name":"isTOUCH","signature":"isTOUCH","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"method","name":"LOCALIZE()","signature":"LOCALIZE(text)","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"method","name":"NEWUIBIND()","signature":"NEWUIBIND(element, [path], [config])","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, reference, [before])","since":"","deprecated":false},{"type":"method","name":"NODEMOVE()","signature":"NODEMOVE(element, [up])","since":"","deprecated":false},{"type":"method","name":"NOOP()","signature":"NOOP()","since":"","deprecated":false},{"type":"method","name":"NOTFOCUSED()","signature":"NOTFOCUSED()","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path)","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [callback])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value)","since":"","deprecated":false},{"type":"method","name":"PIPE()","signature":"PIPE(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [config], callback, [dependencies])","since":"","deprecated":false},{"type":"property","name":"PLUGINS","signature":"PLUGINS","since":"","deprecated":false},{"type":"property","name":"PREF","signature":"PREF","since":"","deprecated":false},{"type":"method","name":"PUSH()","signature":"PUSH(path, value)","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], data)","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path)","since":"","deprecated":false},{"type":"method","name":"SCROLLBAR()","signature":"SCROLLBAR(element, [options])","since":"","deprecated":false},{"type":"method","name":"SCROLLBARWIDTH()","signature":"SCROLLBARWIDTH()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, callback, timeout, [limit], [param])","since":"","deprecated":false},{"type":"method","name":"STRINGIFY()","signature":"STRINGIFY(value, [compress], [fields], [encrypt])","since":"","deprecated":false},{"type":"method","name":"STYLE()","signature":"STYLE(value, [id], [selector])","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path)","since":"","deprecated":false},{"type":"property","name":"Total","signature":"Total","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...permissions)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [callback])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path)","since":"","deprecated":false},{"type":"method","name":"VISIBLE()","signature":"VISIBLE(element, [threshold], [mode])","since":"","deprecated":false},{"type":"property","name":"W","signature":"W","since":"","deprecated":false},{"type":"method","name":"WAIT()","signature":"WAIT(condition, callback)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...values)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcS61wo61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/globals/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Funzioni globali","summary":"Le funzioni e le variabili che la libreria aggiunge all'oggetto window.","markdown":"---\ntitle: Funzioni globali\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/globals/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Funzioni globali\n\n> Le funzioni e le variabili che la libreria aggiunge all'oggetto window.\n\nLa libreria aggiunge queste funzioni e variabili a `window`, quindi sono disponibili ovunque nel tuo codice. Inizia da [Path](../../guides/paths/) e [Associazione dei dati](../../guides/data-binding/) per vedere come funzionano insieme.\n\n## API\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nPrepara un frammento di HTML per un path e un identificatore specifici.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il valore per `~PATH~` e `CLASS`. Usa `null` per saltare queste sostituzioni. |\n| `id` | `String` | yes |  | Il valore per `~ID~`. Usa `null` per saltare questa sostituzione. |\n| `text` | `String` | yes |  | Il testo da preparare. |\n\nReturns: `String` Il testo preparato.\n\nIl metodo traduce il markup `@(text)`, applica le variabili `--name--` e sostituisce `~CDN~` con [DEF.cdn](../def/). Quando `path` è impostato, `~PATH~` e `CLASS` diventano il path, gli elementi `<ui-plugin>` senza attributo `path` lo ricevono e il primo `PLUGIN(function(` diventa `PLUGIN('path', function(`. Quando `id` è impostato, `~ID~` diventa l'identificatore. Un `text` vuoto o che non è una stringa viene restituito invariato.\n\nExample: Sostituisci le parole chiave\n```js\nvar html = '<div class=\"CLASS\" data-id=\"~ID~\">~PATH~</div>';\nconsole.log(ADAPT('users', 'u1', html)); // <div class=\"users\" data-id=\"u1\">users</div>\n```\n\n### AJAX(url, [data], callback, [onprogress], [scope], [id])\n\nType: `method`\n\nInvia una richiesta HTTP e consegna la risposta a una funzione o a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Il metodo, l'indirizzo e le parole chiave facoltative, ad esempio `POST /api/users/ ERROR`. |\n| `data` | `Object` | no |  | Il corpo della richiesta: un oggetto inviato come JSON, una stringa inviata come dati di un modulo, oppure `FormData`. |\n| `callback` | `Function|String` | yes |  | Una funzione o un path che riceve la risposta. |\n| `onprogress` | `Function|String` | no |  | Una funzione o un path che riceve la percentuale di caricamento. |\n| `scope` | `Object` | no | `window` | L'oggetto in cui viene risolto un path `callback`. |\n| `id` | `String` | no | `url` | La chiave usata da `SYNC` e dalla cache. |\n\n`url` inizia con il metodo HTTP, seguito dall'indirizzo e da parole chiave facoltative separate da spazi:\n\n| Parola chiave | Significato |\n| --- | --- |\n| `ERROR` | Fa passare la risposta da [ERROR()](../globals/). Se contiene un errore, viene emesso l'evento `ERROR` e `callback` non viene eseguita. Uno stato di errore senza corpo della risposta emette l'evento `ERROR` con il codice di stato. |\n| `SYNC` | Mette in coda le richieste con lo stesso `id`, così vengono eseguite una dopo l'altra. |\n| `<1 minute>` | Memorizza nella cache la risposta per il tempo indicato con [CACHE()](../globals/), a meno che non sia un errore. Mentre la richiesta è in corso, le altre chiamate con lo stesso `id` attendono la sua risposta, così viene inviata una sola richiesta. |\n| `#name` | Carica prima l'elenco di codici `name`. Consulta [CL()](../globals/). |\n| `@flag` | Emette il flag quando la richiesta viene inviata. Consulta [Flag e modificatori di path](../../guides/flags/). |\n\nUn oggetto in `data` viene inviato come JSON, una stringa viene inviata così com'è con il tipo di contenuto `application/x-www-form-urlencoded` e `FormData` viene inviato come modulo.\n\nUn codice di stato pari o superiore a 400 conta come errore. Una richiesta che non riesce a raggiungere il server, viene interrotta o va in timeout ha il codice di stato `0` e `callback` riceve una risposta vuota. Una risposta con un tipo di contenuto JSON viene analizzata con [PARSE()](../globals/). Ogni richiesta aggiunge le intestazioni di [DEF.headers](../def/). Quando [DEF.language](../def/) è impostato, viene aggiunto alla stringa di query. Quando [DEF.version](../def/) è impostato, viene aggiunto alla stringa di query degli indirizzi `.html`.\n\nGli [eventi](../events/) `request` e `response` ti permettono di ispezionare o modificare ogni chiamata. Una volta inviata la richiesta, `options.xhr` nell'evento `request` contiene il suo `XMLHttpRequest`, quindi `options.xhr.abort()` la interrompe. `UPLOAD()` è la stessa funzione con un altro nome.\n\nExample: Leggi una risposta\n```js\nAJAX('GET /api/users/', function(response) {\n\tconsole.log(response.length); // 2\n});\n```\n\nExample: Salva una risposta in un path\n```js\nAJAX('POST /api/orders/', { amount: 10 }, 'orders.last');\n\nWATCH('orders.last', function(value) {\n\tconsole.log(value.id); // 100\n});\n```\n\nExample: Invia i dati di un modulo\n```js\nAJAX('POST /api/login/', 'name=Ann&remember=1', function(response) {\n\tconsole.log(response.ok); // true\n});\n```\n\nExample: Interrompi una richiesta\n```js\nvar request;\n\nON('request', options => request = options);\nON('ERROR', status => console.log('failed', status)); // failed 0\n\nAJAX('GET /api/report/ ERROR', NOOP);\nrequest.xhr.abort();\n```\n\n### API(url, name, [data], callback, [scope])\n\nType: `method`\n\nChiama un endpoint API di Total.js su un indirizzo specifico.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'indirizzo dell'endpoint. |\n| `name` | `String` | yes |  | Il nome dell'operazione, eventualmente seguito da parole chiave. |\n| `data` | `Object` | no |  | I dati dell'operazione. |\n| `callback` | `Function|String` | yes |  | Una funzione o un path che riceve la risposta. |\n| `scope` | `Object` | no | `window` | L'oggetto in cui viene risolto un path `callback`. |\n\nIl metodo invia `POST url` con il corpo JSON `{ schema: name, data: data }`. Dopo il nome possono seguire le parole chiave accettate da [AJAX()](../globals/), ad esempio `users_list ERROR`. Per usare un unico indirizzo fisso, consulta [TAPI()](../globals/) e [PIPE()](../globals/).\n\nExample: Chiama un'operazione\n```js\nAPI('/admin/api/', 'users_read', { id: 5 }, function(response) {\n\tconsole.log(response.name); // Peter\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nImposta la combinazione di colori della pagina tramite variabili CSS e classi del body.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Gli interruttori e le variabili CSS. |\n\nOgni chiave diventa una variabile CSS su `:root`, tranne i quattro interruttori indicati sotto. La chiave `color` aggiorna anche [DEF.color](../def/) e aggiunge la variabile `--rgb` con i valori di rosso, verde e blu di un colore esadecimale a tre o sei cifre.\n\n| Chiave | Significato |\n| --- | --- |\n| `dark` o `darkmode` | Attiva o disattiva la classe `ui-dark` sul body. |\n| `large` o `largemode` | Attiva o disattiva la classe `ui-large` sul body. |\n\nIl prefisso delle classi proviene da [DEF.prefixcsslibrary](../def/).\n\nExample: Tema scuro con un colore di accento\n```js\nAPPEARANCE({ dark: true, color: '#4285F4' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#4285F4;--rgb:66,133,244}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\nExample: Un colore abbreviato\n```js\nAPPEARANCE({ color: '#abc' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#abc;--rgb:170,187,204}\n```\n\n### ASETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nCrea una funzione che chiama in seguito un metodo di un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il selettore e il metodo, nella stessa forma di `SETTER()`. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nReturns: `Function` Una funzione senza argomenti.\n\nOgni chiamata della funzione restituita esegue [SETTER()](../globals/) con gli argomenti indicati qui.\n\nExample: Prepara una chiamata\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log('added', value); // added 5\n\t};\n});\n\nON('ready', function() {\n\tvar add = ASETTER('counter/add', 5);\n\tadd();\n});\n</script>\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nLegge un attributo `data-*` da un elemento o dal suo genitore più vicino che lo possiede.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Event|Element|Object` | yes |  | Il punto di partenza. |\n| `name` | `String` | no | `id` | Il nome dell'attributo senza il prefisso `data-`. |\n\nReturns: `String` Il valore dell'attributo.\n\n`element` può essere un oggetto jQuery, un evento jQuery (ne viene usato il `currentTarget`) o un elemento DOM. Per un semplice oggetto, il metodo restituisce la proprietà `name`. Qualsiasi altro valore viene restituito così com'è.\n\nExample: Leggi l'identificatore più vicino\n```html\n<div data-id=\"15\" data-type=\"user\"><button id=\"save\">Save</button></div>\n\n<script>\nvar button = $('#save');\nconsole.log(ATTRD(button)); // 15\nconsole.log(ATTRD(button, 'type')); // user\nconsole.log(ATTRD({ id: 20 })); // 20\n</script>\n```\n\n### BLOCKED(key, timeout, [callback])\n\nType: `method`\n\nLimita la frequenza con cui un'operazione può essere eseguita.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Il nome dell'operazione. |\n| `timeout` | `Number|String` | yes |  | Il tempo in millisecondi, oppure un testo come `5 minutes`. |\n| `callback` | `Function` | no |  | Una funzione eseguita quando l'operazione non è bloccata. |\n\nReturns: `Boolean` `true` quando l'operazione è bloccata.\n\nLa prima chiamata blocca `key` per il tempo indicato e restituisce `false`. Le chiamate successive restituiscono `true` finché il tempo non è trascorso. Un blocco di 10 secondi o più viene conservato in `localStorage`, quindi sopravvive al ricaricamento della pagina.\n\nExample: Consenti un clic al secondo\n```js\nON('ready', function() {\n\tconsole.log(BLOCKED('save', 1000)); // false\n\tconsole.log(BLOCKED('save', 1000)); // true\n});\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nLegge o scrive un valore nella cache persistente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La chiave. |\n| `value` | `Object` | no |  | Il valore da salvare. |\n| `expire` | `String` | no |  | La durata del valore, oppure `session`. |\n\nReturns: `Object` Il valore salvato in lettura, altrimenti nulla.\n\nCon `expire`, il metodo salva il valore. Senza, restituisce il valore salvato, oppure `null` quando il valore manca o è scaduto. Il valore `session` conserva i dati in memoria fino alla chiusura della pagina. Qualsiasi altro valore è un tempo come `10 minutes`, `2 hours`, `1 day`, `1 week`, `1 month` o `1 year` e i dati vengono salvati tramite [DEF.onstoragesave](../def/).\n\nLa cache viene caricata all'avvio della libreria, quindi usala a partire dall'[evento](../events/) `ready`.\n\nExample: Scrivi e leggi\n```js\nON('ready', function() {\n\tCACHE('filter', { page: 2 }, '1 day');\n\tconsole.log(CACHE('filter')); // {\"page\":2}\n\tconsole.log(CACHE('missing')); // null\n});\n```\n\n### CACHEPATH(path, expire, [def])\n\nType: `method`\n\nConserva il valore di un path nella cache tra una visita e l'altra.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `expire` | `String` | yes |  | La durata del valore salvato, ad esempio `1 day`. |\n| `def` | `Object|Function` | no |  | Il valore usato quando non c'è nulla di salvato. Una funzione viene chiamata per ottenerlo. |\n\nIl metodo salva ogni modifica del path con [CACHE()](../globals/) per il tempo indicato in `expire`. Quando il path è vuoto, ci scrive il valore salvato e, quando non c'è nulla di salvato, scrive `def`. Un path che contiene già un valore lo mantiene.\n\nSe lo chiami prima che la libreria abbia caricato la cache, il metodo la attende e poi ripristina il valore. I plugin hanno lo stesso metodo con un path relativo: [plugin.cachepath()](../plugin/).\n\nExample: Ricorda un filtro\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n\nSET('filter.q', 'lamp');\n// After a reload of the page, GET('filter.q') returns lamp\n```\n\n### CL(name, [callback])\n\nType: `method`\n\nCarica gli elenchi di codici registrati con `CLINIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Un nome, oppure più nomi separati da virgole. |\n| `callback` | `Function` | no |  | Una funzione eseguita quando gli elenchi sono stati caricati. |\n\nUn elenco di codici è un insieme di dati condivisi, come un elenco di paesi, salvato in [DEF.cl](../def/). Un elenco viene caricato una sola volta. `callback` viene eseguita quando tutti gli elenchi sono disponibili. Un nome non ancora registrato viene ricontrollato ogni 500 millisecondi finché non compare.\n\nExample: Carica un elenco su richiesta\n```js\nCLINIT('countries', function(next) {\n\tnext([{ id: 'SK', name: 'Slovakia' }]);\n});\n\nON('ready', function() {\n\tCL('countries', function() {\n\t\tconsole.log(DEF.cl.countries.length); // 1\n\t});\n});\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nAnnulla un timer creato con `setTimeout2()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del timer. |\n\nReturns: `Boolean` `true` quando il timer esiste.\n\nExample: Annulla un timer\n```js\nsetTimeout2('search', NOOP, 1000);\nconsole.log(clearTimeout2('search')); // true\nconsole.log(clearTimeout2('unknown')); // false\n```\n\n### CLINIT(name, source, [init])\n\nType: `method`\n\nRegistra la sorgente di un elenco di codici.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'elenco di codici. |\n| `source` | `Function|String` | yes |  | Una funzione, una richiesta o un'operazione. |\n| `init` | `Boolean` | no | `false` | Carica subito l'elenco. |\n\nQuando `source` è una funzione, riceve `next(value, [extend])`. Passa l'elenco a `next()`. Con `extend` impostato a `true`, `value` è un oggetto le cui chiavi vengono salvate come elenchi di codici separati.\n\nQuando `source` è una stringa, un valore che inizia con un metodo HTTP viene caricato con [AJAX()](../globals/). Qualsiasi altro valore è un'operazione per [TAPI()](../globals/).\n\nExample: Carica più elenchi insieme\n```js\nCLINIT('all', function(next) {\n\tnext({ colors: ['red'], sizes: ['XL'] }, true);\n}, true);\n\nON('ready', function() {\n\tsetTimeout(function() {\n\t\tconsole.log(DEF.cl.colors, DEF.cl.sizes); // [\"red\"] [\"XL\"]\n\t}, 100);\n});\n```\n\n### CLONE(value, [raw])\n\nType: `method`\n\nCrea una copia profonda di un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|String` | yes |  | Il valore da copiare, oppure un path. |\n| `raw` | `Boolean` | no | `false` | Tratta una stringa come un valore semplice. |\n\nReturns: `Object` La copia.\n\nUna stringa viene trattata come il path di un oggetto o di un array e viene copiato il valore che vi si trova. Con `raw` impostato a `true`, una stringa viene restituita così com'è. Gli oggetti vengono copiati tramite JSON e le date al loro interno restano date.\n\nExample: Copia un oggetto\n```js\nvar a = { user: { name: 'Peter' } };\nvar b = CLONE(a);\nb.user.name = 'Lucia';\nconsole.log(a.user.name); // Peter\n```\n\nExample: Copia il valore di un path\n```js\nSET('form', { name: 'Peter' });\nvar copy = CLONE('form');\nconsole.log(copy); // {\"name\":\"Peter\"}\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nCarica di nuovo gli elenchi di codici dalle loro sorgenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Un nome, oppure più nomi separati da virgole. |\n| `callback` | `Function` | no |  | Una funzione eseguita quando gli elenchi sono stati ricaricati. |\n\nVengono ricaricati solo gli elenchi già caricati. Gli altri nomi vengono saltati.\n\nExample: Aggiorna un elenco\n```js\nvar counter = 0;\n\nCLINIT('stats', function(next) {\n\tnext([++counter]);\n});\n\nON('ready', function() {\n\tCL('stats', function() {\n\t\tCLRELOAD('stats', function() {\n\t\t\tconsole.log(DEF.cl.stats); // [2]\n\t\t});\n\t});\n});\n```\n\n### CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nEsegue un comando su ogni componente che lo registra.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il comando, eventualmente seguito da flag. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nI componenti registrano i comandi con [command()](../component/). Il nome può essere seguito da flag dopo uno spazio, ad esempio `CMD('refresh @saved')`: vengono emessi per primi, come con [SET()](../globals/). Per eseguire un comando solo in una parte della pagina, usa [$(selector).CMD()](../jquery/) o [plugin.cmd()](../plugin/).\n\nExample: Svuota ogni elenco\n```html\n<ui-component name=\"list\"></ui-component>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nvar count = 0;\n\nCOMPONENT('list', function(self) {\n\tself.command('clear', value => count += value);\n});\n\nON('ready', function() {\n\tCMD('clear', 1);\n\tconsole.log(count); // 2\n});\n</script>\n```\n\n### COMPONENT(name, [config], callback, [dependencies], [css])\n\nType: `method`\n\nRegistra la dichiarazione di un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del componente. |\n| `config` | `String` | no |  | La configurazione predefinita nella forma `key:value;key:value`. |\n| `callback` | `Function` | yes |  | La dichiarazione: `function(self, config, cls)`. |\n| `dependencies` | `String|Array` | no |  | Gli indirizzi da importare prima, separati da virgole. Un array può contenere anche funzioni che ricevono `next`. |\n| `css` | `String` | no |  | Gli stili del componente. |\n\n`callback` viene eseguita una volta per ogni istanza e riceve l'istanza, la sua configurazione e la sua classe CSS. Nell'argomento `css`, la parola `CLASS` diventa `ui-` seguito dal nome del componente. Consulta [Creare componenti](../../guides/creating-components/) e l'oggetto [Component](../component/).\n\nExample: Dichiara un componente\n```html\n<ui-component name=\"hello\"></ui-component>\n\n<script>\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.element.aclass(cls).html('Hello ' + config.name);\n\t\tconsole.log(self.element.html()); // Hello World\n\t};\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nRestituisce i componenti associati a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, eventualmente con dei flag. |\n\nReturns: `Array` Le istanze di [componente](../component/) corrispondenti.\n\nIl path include tutto ciò che si trova al di sotto, quindi `form` restituisce anche un componente associato a `form.name`. I flag nel path restringono il risultato: `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` e `@enabled`.\n\nExample: Trova i campi obbligatori\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.setter = NOOP;\n});\n\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tconsole.log(COMPONENTS('form @required').length); // 1\n});\n</script>\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nModifica la configurazione dei componenti esistenti e futuri.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | I componenti da configurare. |\n| `config` | `String|Object` | yes |  | La configurazione, come oggetto o nella forma `key:value;key:value`. |\n\n`selector` può essere:\n\n| Selettore | Corrisponde a |\n| --- | --- |\n| `name` | I componenti con questo nome. |\n| `#id` | Il componente con questo identificatore. |\n| `.path` | I componenti il cui path contiene `path`. |\n| `*` | Tutti i componenti. |\n| `a, b` | Più selettori separati da virgole. |\n| `function(instance)` | I componenti per cui la funzione restituisce `true`. |\n\nExample: Configura per nome\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tCONFIG('box', 'color:red;size:10');\n\tconsole.log(FIND('box').config.size); // 10\n});\n</script>\n```\n\n### COOKIES\n\nType: `property`\n\nLegge e scrive i cookie del browser.\n\nReturns: `Object` L'oggetto con i metodi.\n\nL'oggetto ha tre metodi:\n\n| Metodo | Descrizione |\n| --- | --- |\n| `COOKIES.get(name)` | Restituisce il valore, oppure una stringa vuota. |\n| `COOKIES.set(name, value, [expire], [samesite])` | Scrive un cookie per il path `/`. `expire` è un numero di giorni, un `Date` o un testo come `1 day`. Senza `expire`, il cookie viene conservato fino alla chiusura del browser. `samesite` è ad esempio `lax`. |\n| `COOKIES.rem(name)` | Rimuove il cookie. |\n\nExample: Scrivi e leggi un cookie\n```js\nCOOKIES.set('theme', 'dark', '1 month', 'lax');\nconsole.log(COOKIES.get('theme')); // dark\n```\n\nExample: Conserva un cookie per una settimana\n```js\nCOOKIES.set('token', 'a=1', 7);\nconsole.log(COOKIES.get('token')); // a=1\n```\n\n### COPY(source, target)\n\nType: `method`\n\nCopia le proprietà di un oggetto in un altro.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | L'oggetto da cui leggere. |\n| `target` | `Object` | yes |  | L'oggetto in cui scrivere. |\n\nReturns: `Object` L'oggetto `target`.\n\nGli oggetti annidati vengono clonati, quindi le modifiche successive in `source` non influiscono su `target`.\n\nExample: Unisci due oggetti\n```js\nvar target = { a: 1 };\nCOPY({ b: { c: 2 } }, target);\nconsole.log(target); // {\"a\":1,\"b\":{\"c\":2}}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nUn altro nome di `STYLE()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Il CSS. |\n| `id` | `String` | no |  | L'identificatore dell'elemento di stile. |\n| `selector` | `String` | no |  | Un selettore anteposto a ogni regola. |\n\nConsulta [STYLE()](../globals/). Impostando `window.jc_globals = { CSS: false }` prima dello script della libreria, questa variabile globale resta non definita.\n\n### DAYS\n\nType: `property`\n\nI nomi inglesi dei giorni della settimana, a partire dalla domenica.\n\nReturns: `Array` Sette stringhe.\n\nExample: Leggi un giorno\n```js\nconsole.log(DAYS[1]); // Monday\n```\n\n### DEF\n\nType: `property`\n\nLe impostazioni predefinite della libreria.\n\nReturns: `Object` Le impostazioni.\n\nDescritto nella sua pagina: [DEF](../def/).\n\n### DECRYPT(text, [key], [type])\n\nType: `method`\n\nLegge un valore scritto da `ENCRYPT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Il testo di `ENCRYPT()`. |\n| `key` | `String` | no |  | La chiave. |\n| `type` | `String` | no |  | Il prefisso del testo. |\n\nReturns: `Object` Il valore, oppure `undefined`.\n\n`key` e `type` devono essere quelli passati a [ENCRYPT()](../globals/). Il metodo restituisce `undefined` quando il checksum non corrisponde, come succede con un testo modificato. Un valore che inizia con `[`, `{` o `\"` viene analizzato come JSON.\n\nExample: Rileggi un oggetto\n```js\nvar text = ENCRYPT({ id: 5 }, 'secret', 'U');\n\nconsole.log(text.charAt(0)); // U\nconsole.log(DECRYPT(text, 'secret', 'U')); // {\"id\":5}\nconsole.log(DECRYPT(text, 'secret')); // undefined\n```\n\n### DIFFDOM(element, selector, html, [attribute])\n\nType: `method`\n\nAggiorna i figli di un elemento in modo che corrispondano al nuovo HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'elemento genitore. |\n| `selector` | `String` | yes |  | Un selettore dei figli da confrontare. |\n| `html` | `String` | yes |  | Il nuovo contenuto. |\n| `attribute` | `String` | no |  | L'attributo usato per il confronto. |\n\nReturns: `Object` Il numero di elementi aggiunti, mantenuti e rimossi: `{ add, upd, rem }`.\n\nI figli non modificati restano nel DOM e quindi mantengono il loro stato. I figli vengono confrontati in base all'intero HTML, oppure in base al valore di `attribute` quando è impostato.\n\nExample: Aggiorna un elenco\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n\n<script>\nvar list = $('#list');\nvar result = DIFFDOM(list, 'li', '<li>A</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log(list.html()); // <li>A</li><li>C</li>\n</script>\n```\n\n### EMIT(name, [a], [b], [c], [d])\n\nType: `method`\n\nEmette un evento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nI gestori registrati con [ON()](../globals/) e quelli registrati su [componenti](../component/) e [plugin](../plugin/) ricevono gli argomenti. Dopo il nome possono seguire dei flag, ad esempio `refresh @loading`. Gli eventi della libreria sono elencati in [Eventi](../events/).\n\nExample: Emetti un evento personalizzato\n```js\nON('saved', function(id, name) {\n\tconsole.log(id, name); // 5 Peter\n});\n\nEMIT('saved', 5, 'Peter');\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nUn array vuoto congelato.\n\nReturns: `Array` Un array che non può essere modificato.\n\nExample: Un valore predefinito condiviso\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nUn oggetto vuoto congelato.\n\nReturns: `Object` Un oggetto che non può essere modificato.\n\nExample: Un valore predefinito condiviso\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nCodifica un valore come testo con un checksum.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Il valore. |\n| `key` | `String` | no |  | La chiave del checksum. |\n| `type` | `String` | no |  | Un prefisso scritto all'inizio del testo. |\n\nReturns: `String` Il testo codificato.\n\nUn oggetto o un array viene prima serializzato con [STRINGIFY()](../globals/). Il risultato ha `type` come prefisso, il valore in cifre esadecimali, la lettera `x` e un checksum creato con [HASH()](../globals/) a partire dal valore, da `key` e da `type`.\n\nChiunque può rileggere il valore, quindi non usare il metodo per nascondere dei dati: la chiave permette solo a [DECRYPT()](../globals/) di capire se il testo è stato modificato.\n\nExample: Codifica e decodifica\n```js\nvar text = ENCRYPT('hello', 'secret');\n\nconsole.log(text); // 68656c6c6fxds46dr\nconsole.log(DECRYPT(text, 'secret')); // hello\nconsole.log(DECRYPT(text, 'other')); // undefined\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nLegge o scrive le variabili d'ambiente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | Il nome, oppure un oggetto con nomi e valori. |\n| `value` | `Object` | no |  | Il valore da scrivere. |\n\nReturns: `Object` Il valore della variabile.\n\nLe variabili vengono salvate in [DEF.env](../def/). Un testo può farvi riferimento come `[name]`: path, indirizzi e valori di configurazione sostituiscono questa notazione con il valore. Passa un oggetto per scrivere più variabili. Ogni scrittura emette l'[evento](../events/) `env`.\n\nExample: Usa una variabile in un testo\n```js\nENV('api', '/api/v1/');\nconsole.log(ENV('api')); // /api/v1/\nconsole.log('[api]users/'.env()); // /api/v1/users/\n```\n\n### ENVIRONMENT(name, [version], [language], [env])\n\nType: `method`\n\nImposta la chiave di storage, la versione, la lingua e le variabili d'ambiente dell'app.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La chiave usata in `localStorage`. |\n| `version` | `String` | no |  | La versione dell'app. |\n| `language` | `String` | no |  | La lingua dell'app. |\n| `env` | `Object` | no |  | Le variabili d'ambiente. |\n\nIl metodo assegna [DEF.localstorage](../def/), [DEF.version](../def/) e [DEF.language](../def/) e passa `env` a [ENV()](../globals/). Chiamalo subito dopo lo script della libreria, così l'app legge il proprio storage.\n\nExample: Configura un'app\n```js\nENVIRONMENT('myapp', '1.0', 'en', { title: 'My app' });\n\nconsole.log(DEF.localstorage, DEF.version, DEF.language); // myapp 1.0 en\nconsole.log(ENV('title')); // My app\n```\n\n### ERROR(response, [success], [error])\n\nType: `method`\n\nControlla se una risposta contiene errori ed esegue il gestore corrispondente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | La risposta da controllare. |\n| `success` | `Function|String` | no |  | Viene eseguita quando non ci sono errori. |\n| `error` | `Function|String` | no |  | Viene eseguita quando c'è un errore. |\n\nReturns: `Boolean` `true` quando la risposta contiene un errore.\n\nUna risposta è un errore quando è un oggetto `Error`, ha una proprietà `error` oppure è un array il cui primo elemento ne ha una. Un errore emette l'[evento](../events/) `ERROR`.\n\n`success` ed `error` possono essere funzioni oppure nomi per [SEEX()](../globals/).\n\nChiama `ERROR(success, [error])` senza una risposta per creare una funzione da passare come callback.\n\nExample: Controlla una risposta\n```js\nconsole.log(ERROR({ id: 1 })); // false\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\n```\n\nExample: Crea una callback\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 1\n});\n\ncallback({ id: 1 });\n```\n\n### ERRORS(path, callback)\n\nType: `method`\n\nRestituisce i componenti non validi di un path o di un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|jQuery` | yes |  | Un path, oppure un elemento che contiene i componenti. |\n| `callback` | `Function` | yes |  | Una funzione che riceve un array di [componenti](../component/). |\n\nExample: Valida un modulo\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.validate = function(value) {\n\t\treturn !!value;\n\t};\n});\n\nON('ready', function() {\n\tERRORS('form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nChiama una funzione in base al suo nome.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La destinazione della chiamata. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nLa forma di `name` determina che cosa viene chiamato:\n\n| Nome | Chiama |\n| --- | --- |\n| `name` | Una funzione globale. |\n| `FUNC.name` | Una funzione trovata in un path. |\n| `plugin/method` | Un metodo di un [plugin](../plugin/). |\n| `*/method` | Un metodo del plugin common. |\n| `-component/method` | Un metodo di un componente, tramite [SETTER()](../globals/). |\n| `#event` | Un evento, tramite [EMIT()](../globals/). |\n\nAggiungi il flag `@important` per riprovare ogni 500 millisecondi finché la funzione non esiste, ad esempio `EXEC('app/refresh @important')`. `EXE()` è la stessa funzione con un altro nome.\n\nExample: Chiama una funzione tramite path\n```js\nFUNC.sum = function(a, b) {\n\tconsole.log(a + b); // 5\n};\n\nEXEC('FUNC.sum', 2, 3);\n```\n\nExample: Attendi una funzione\n```js\nEXEC('app.start @important', 'now');\n\nsetTimeout(function() {\n\twindow.app = {};\n\tapp.start = function(value) {\n\t\tconsole.log(value); // now\n\t};\n}, 100);\n```\n\n### EXTENSION(name, [config], callback)\n\nType: `method`\n\nEstende un componente o un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del componente, oppure `@` seguito dal nome del plugin. |\n| `config` | `String|Object` | no |  | La configurazione aggiunta a ogni istanza. |\n| `callback` | `Function` | yes |  | Una funzione `(instance, config, cls)`, dove `cls` è la classe CSS dell'istanza. `this` è l'istanza. |\n\n`callback` viene eseguita per ogni istanza esistente e per ogni nuova istanza, subito dopo la dichiarazione, sempre con gli stessi argomenti. Per un plugin, scrivi `@` davanti al suo nome.\n\nExample: Aggiungi un metodo a un componente\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nEXTENSION('box', 'color:red', function(self, config) {\n\tself.describe = function() {\n\t\treturn config.color;\n\t};\n});\n\nON('ready', function() {\n\tconsole.log(FIND('box').describe()); // red\n});\n</script>\n```\n\n### FIND(selector, [all])\n\nType: `method`\n\nTrova un componente pronto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Il nome, l'identificatore o il path. |\n| `all` | `Boolean` | no | `false` | Restituisce tutte le corrispondenze in un array. |\n\nReturns: `Component|Array` Il primo [componente](../component/), oppure un array quando `all` è `true`.\n\n`selector` è il nome di un componente, `#id` per un identificatore oppure `.path` per un path.\n\nExample: Trova per nome e per path\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('field').name); // field\n\tconsole.log(FIND('.form.name').path.path); // form.name\n\tconsole.log(FIND('field', true).length); // 1\n});\n</script>\n```\n\n### FLAGS(flags, [callback])\n\nType: `method`\n\nEmette dei flag e poi esegue una funzione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | I flag, ad esempio `@loading @save`. |\n| `callback` | `Function` | no |  | Una funzione eseguita al termine. |\n\nOgni flag emette l'evento `@flag name`, che puoi intercettare con [ON()](../globals/). Consulta [Flag e modificatori di path](../../guides/flags/).\n\nExample: Intercetta un flag\n```js\nON('@flag loading', function() {\n\tconsole.log('flag captured'); // flag captured\n});\n\nFLAGS('@loading', function() {\n\tconsole.log('done'); // done\n});\n```\n\n### FN(code)\n\nType: `method`\n\nCompila una arrow function da una stringa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | yes |  | Il codice della funzione. |\n\nReturns: `Function` La funzione compilata.\n\nIl codice può avere fino a quattro argomenti. Il codice senza freccia diventa una funzione con l'argomento `value`. Le funzioni compilate vengono memorizzate nella cache.\n\nExample: Compila delle funzioni\n```js\nconsole.log(FN('n => n * 2')(4)); // 8\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value + 1')(1)); // 2\n```\n\n### FREE()\n\nType: `method`\n\nRimuove i componenti, le associazioni e i plugin i cui elementi hanno lasciato il DOM.\n\nLa libreria esegue questa pulizia ogni minuto. Chiamala quando hai bisogno che le istanze vengano rimosse subito.\n\nExample: Rimuovi un componente scollegato\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\t$('ui-component').remove();\n\tFREE();\n\tconsole.log(COMPONENTS('form').length); // 0\n});\n</script>\n```\n\n### FUNC\n\nType: `property`\n\nUn oggetto vuoto per le funzioni della tua app.\n\nReturns: `Object` Il contenitore.\n\nLe funzioni salvate qui possono essere chiamate tramite path con [EXEC()](../globals/).\n\nExample: Salva una funzione\n```js\nFUNC.hello = function() {\n\treturn 'Hello';\n};\n\nconsole.log(FUNC.hello()); // Hello\n```\n\n### GET(path, [noflags])\n\nType: `method`\n\nLegge il valore di un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, eventualmente con dei flag. |\n| `noflags` | `Boolean` | no | `false` | Legge il valore senza applicare i flag. |\n\nReturns: `Object` Il valore.\n\nQuando il path contiene dei flag, questi vengono applicati ai componenti del path: `GET('form @reset')` restituisce il valore e ne azzera lo stato. Consulta [Path](../../guides/paths/).\n\nExample: Leggi dei valori\n```js\nSET('user.name', 'Peter');\n\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\n### GUID([length])\n\nType: `method`\n\nGenera un identificatore casuale.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | no |  | La lunghezza dell'identificatore. |\n\nReturns: `String` L'identificatore.\n\nSenza `length`, il risultato ha la forma di un UUID di 36 caratteri. Con `length`, è una stringa di lettere minuscole e cifre.\n\nExample: Genera degli identificatori\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value)\n\nType: `method`\n\nCrea un hash numerico di un valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Number|Boolean|Object|Date` | yes |  | Il valore. |\n\nReturns: `Number` L'hash.\n\nUn numero viene restituito così com'è, `true` dà `1`, una data dà il suo tempo in millisecondi e un valore vuoto dà `0`. Gli oggetti vengono prima serializzati.\n\nExample: Calcola l'hash di una stringa\n```js\nconsole.log(HASH('hello')); // 99162322\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nControlla se un elemento annidato nella pagina è nascosto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Un elemento posizionato dentro un altro elemento del body. |\n\nReturns: `Boolean` `true` quando l'elemento è nascosto.\n\nL'elemento è considerato nascosto quando non ha un offset parent, come accade con `display:none`. Anche un elemento mancante è considerato nascosto. Per controllare la posizione nel viewport, usa [VISIBLE()](../globals/).\n\nExample: Controlla un elemento\n```html\n<main><div id=\"a\" style=\"display:none\"></div><div id=\"b\"></div></main>\n\n<script>\nconsole.log(HIDDEN($('#a'))); // true\nconsole.log(HIDDEN($('#b'))); // false\n</script>\n```\n\n### IMPORT(url, [target], [callback], [prepare])\n\nType: `method`\n\nCarica uno script, un foglio di stile o un frammento di HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'indirizzo e le parole chiave facoltative. |\n| `target` | `String|jQuery|Element` | no | `body` | L'elemento che riceve il contenuto HTML. |\n| `callback` | `Function` | no |  | Una funzione eseguita quando il contenuto è stato caricato. |\n| `prepare` | `Function` | no |  | Una funzione che riceve l'HTML e restituisce il testo da inserire. |\n\nGli indirizzi che terminano con `.js` o `.css` vengono aggiunti all'head della pagina. Qualsiasi altro indirizzo viene scaricato e inserito in `target`. L'indirizzo può essere combinato con parole chiave:\n\n| Parola chiave | Significato |\n| --- | --- |\n| `<name>` | Salta l'importazione quando esiste la variabile globale `name`. |\n| `.js`, `.css`, `.html` | Imposta il tipo del contenuto quando l'indirizzo non lo indica. |\n| `@singleton` | Importa l'indirizzo una sola volta. |\n| `@prepend` | Inserisce il contenuto all'inizio di `target`. |\n\nQuando uno script o un foglio di stile non può essere caricato, la libreria scrive un avviso nella console e `callback` viene eseguita comunque.\n\nConsulta [Importare contenuti](../../guides/importing/).\n\nExample: Inserisci un frammento di HTML\n```html\n<div id=\"menu\"></div>\n\n<script>\nIMPORT('/parts/menu.html', '#menu', function() {\n\tconsole.log($('#menu').html()); // <b>Menu</b>\n});\n</script>\n```\n\nExample: Salta una libreria già presente\n```js\nIMPORT('<jQuery> /js/jquery.min.js', function() {\n\tconsole.log('jQuery is available'); // jQuery is available\n});\n```\n\n### INC(path, [value])\n\nType: `method`\n\nIncrementa il numero salvato in un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `value` | `Number` | no | `1` | La quantità da aggiungere. |\n\nUn path vuoto parte da `0`. Una stringa viene convertita in numero. Usa un `value` negativo per diminuire il numero.\n\nExample: Incrementa un contatore\n```js\nSET('stats.visits', 10);\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 16\n```\n\n### inDOM(element)\n\nType: `method`\n\nControlla se un elemento è collegato al body del documento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | Un elemento DOM. |\n\nReturns: `Boolean` `true` quando l'elemento è collegato, altrimenti nulla.\n\nExample: Controlla un elemento\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(!!inDOM(document.createElement('div'))); // false\n```\n\n### isIE\n\nType: `property`\n\nIndica se il browser è Internet Explorer.\n\nReturns: `Boolean` Il risultato del rilevamento.\n\n### isMOBILE\n\nType: `property`\n\nIndica se lo user agent appartiene a un dispositivo mobile.\n\nReturns: `Boolean` Il risultato del rilevamento.\n\n### isPRIVATEMODE\n\nType: `property`\n\nIndica se `localStorage` non è disponibile, come in alcune finestre private. Il valore viene impostato durante l'avvio della libreria, quindi leggilo a partire dall'evento `ready`.\n\nReturns: `Boolean` Il risultato del rilevamento.\n\n### isROBOT\n\nType: `property`\n\nIndica se lo user agent appartiene a un motore di ricerca o a un crawler.\n\nReturns: `Boolean` Il risultato del rilevamento.\n\n### isSTANDALONE\n\nType: `property`\n\nIndica se la pagina è in esecuzione come web app installata.\n\nReturns: `Boolean` Il risultato del rilevamento.\n\n### isTOUCH\n\nType: `property`\n\nIndica se il dispositivo supporta l'input tattile.\n\nReturns: `Boolean` Il risultato del rilevamento.\n\n### jComponent\n\nType: `property`\n\nL'oggetto principale della libreria.\n\nReturns: `Object` L'oggetto principale.\n\nLo stesso oggetto di [MAIN](../main/).\n\n### LOCALIZE(text)\n\nType: `method`\n\nCarica le traduzioni nel dizionario.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Le righe con le traduzioni. |\n\nOgni riga ha la forma `key : translation` e le righe che iniziano con `//` vengono saltate. La chiave è l'hash del testo originale, in base 36, con il prefisso `T`. Le traduzioni vengono salvate in [DEF.dictionary](../def/) e usate da [TRANSLATE()](../globals/). Consulta [Localizzazione](../../guides/localization/).\n\nExample: Carica una traduzione\n```js\nvar key = 'T' + HASH('Hello').toString(36);\n\nLOCALIZE(key + ' : Hola');\nconsole.log(TRANSLATE('@(Hello)')); // Hola\n```\n\n### M\n\nType: `property`\n\nUn nome breve dell'oggetto principale.\n\nReturns: `Object` L'oggetto principale.\n\nLo stesso oggetto di [MAIN](../main/).\n\n### MAIN\n\nType: `property`\n\nL'oggetto principale della libreria.\n\nReturns: `Object` L'oggetto principale.\n\nDescritto nella sua pagina: [MAIN](../main/).\n\n### MONTHS\n\nType: `property`\n\nI nomi inglesi dei mesi, a partire da gennaio.\n\nReturns: `Array` Dodici stringhe.\n\nExample: Leggi un mese\n```js\nconsole.log(MONTHS[0]); // January\n```\n\n### NEWUIBIND(element, [path], [config])\n\nType: `method`\n\nCrea dal codice un'associazione dei dati su un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | L'elemento. |\n| `path` | `String` | no |  | Il path da osservare. |\n| `config` | `String` | no |  | I comandi di associazione. |\n\nL'associazione funziona come l'elemento [ui-bind](../ui-bind/). Senza `path` e `config`, i valori vengono letti dagli attributi dell'elemento.\n\nExample: Associa un elemento a un path\n```html\n<div id=\"name\"></div>\n\n<script>\nSET('user.name', 'Peter');\nNEWUIBIND($('#name'), 'user.name', 'text:value');\n\nsetTimeout(function() {\n\tconsole.log($('#name').html()); // Peter\n}, 200);\n</script>\n```\n\n### NODEINDEXOF(element)\n\nType: `method`\n\nRestituisce la posizione di un elemento tra i suoi fratelli.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | L'elemento. |\n\nReturns: `Number` La posizione, a partire da zero.\n\nExample: Leggi una posizione\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li></ul>\n\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, reference, [before])\n\nType: `method`\n\nInserisce un elemento accanto a un altro elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | L'elemento da inserire. |\n| `reference` | `jQuery|Element` | yes |  | L'elemento di riferimento. |\n| `before` | `Boolean` | no | `false` | Inserisce l'elemento davanti a quello di riferimento. |\n\nExample: Sposta un elemento\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEINSERT($('#c'), $('#a'), true);\nconsole.log($('ul').text()); // CAB\n</script>\n```\n\n### NODEMOVE(element, [up])\n\nType: `method`\n\nSposta un elemento di una posizione tra i suoi fratelli.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | L'elemento. |\n| `up` | `Boolean` | no | `false` | Sposta l'elemento verso l'inizio. Altrimenti lo sposta verso la fine. |\n\nExample: Riordina un elenco\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BAC\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nUna funzione che non fa nulla.\n\nUsala come callback predefinita.\n\nExample: Una callback predefinita\n```js\nvar callback = NOOP;\nconsole.log(typeof(callback)); // function\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nControlla se la pagina è in background.\n\nReturns: `Boolean` `true` quando il documento è nascosto.\n\nExample: Controlla la pagina\n```js\nconsole.log(NOTFOCUSED()); // false\n```\n\n### NOW\n\nType: `property`\n\nLa data corrente, aggiornata una volta al minuto.\n\nReturns: `Date` La data.\n\nUsala quando basta una precisione di un minuto. Evita di creare un nuovo oggetto `Date` a ogni utilizzo.\n\nExample: Leggi la data\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path)\n\nType: `method`\n\nImposta un path a `null`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\n`NULL()` è la stessa funzione con un altro nome.\n\nExample: Svuota un valore\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### OFF(name, [callback])\n\nType: `method`\n\nRimuove i gestori di eventi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `callback` | `Function` | no |  | Il gestore da rimuovere. |\n\nSenza `callback`, vengono rimossi tutti i gestori dell'evento. Puoi unire più eventi con `+`.\n\nExample: Rimuovi un gestore\n```js\nvar count = 0;\nvar handler = function() {\n\tcount++;\n};\n\nON('refresh', handler);\nEMIT('refresh');\nOFF('refresh', handler);\nEMIT('refresh');\nconsole.log(count); // 1\n```\n\n### ON(name, callback, [init])\n\nType: `method`\n\nRegistra un gestore di eventi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `callback` | `Function` | yes |  | Il gestore. Riceve gli argomenti dell'evento. |\n| `init` | `Boolean` | no | `false` | Chiama anche il gestore una volta, senza argomenti. |\n\nPuoi unire più eventi con `+`, ad esempio `saved + removed`. Un gestore per `ready` o `init` viene eseguito subito se la libreria è già avviata. Gli eventi della libreria sono elencati in [Eventi](../events/).\n\nExample: Intercetta due eventi\n```js\nvar count = 0;\n\nON('saved + removed', function() {\n\tcount++;\n});\n\nEMIT('saved');\nEMIT('removed');\nconsole.log(count); // 2\n```\n\n### PARSE(value)\n\nType: `method`\n\nAnalizza il JSON e converte le stringhe di data in oggetti `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Il JSON, un selettore o un oggetto. |\n\nReturns: `Object` Il valore analizzato, oppure `null`.\n\nUn valore che inizia con `#` o `.` è un selettore: il JSON viene letto dal contenuto di quell'elemento. Un oggetto viene restituito così com'è. Un JSON non valido restituisce `null`.\n\nExample: Analizza del JSON\n```js\nvar data = PARSE('{\"created\":\"2024-05-01T10:00:00.000Z\"}');\nconsole.log(data.created instanceof Date); // true\nconsole.log(PARSE('invalid')); // null\n```\n\n### PIPE(name, [data], callback, [scope])\n\nType: `method`\n\nChiama un'operazione sull'indirizzo indicato in `DEF.pipe`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'operazione, eventualmente seguito da parole chiave. |\n| `data` | `Object` | no |  | I dati dell'operazione. |\n| `callback` | `Function|String` | yes |  | Una funzione o un path che riceve la risposta. |\n| `scope` | `Object` | no | `window` | L'oggetto in cui viene risolto un path `callback`. |\n\nFunziona come [API()](../globals/), con l'indirizzo preso da [DEF.pipe](../def/).\n\nExample: Chiama un'operazione\n```js\nDEF.pipe = '/pipe/';\n\nPIPE('orders_list', function(response) {\n\tconsole.log(response.length); // 1\n});\n```\n\n### PLUGIN(name, [config], callback, [dependencies])\n\nType: `method`\n\nRegistra la dichiarazione di un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del plugin. |\n| `config` | `String` | no |  | La configurazione predefinita nella forma `key:value;key:value`. |\n| `callback` | `Function` | yes |  | La dichiarazione: `function(self, config)`. |\n| `dependencies` | `String|Array` | no |  | Gli indirizzi da importare prima. |\n\n`callback` viene eseguita quando viene creato un elemento [ui-plugin](../ui-plugin/) con questo path. Il nome `*` registra il plugin common. Consulta [Plugin](../../guides/plugins/) e l'oggetto [Plugin](../plugin/).\n\nExample: Dichiara un plugin\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('Hello ' + name); // Hello Peter\n\t};\n});\n\nON('ready', function() {\n\tEXEC('users/hello', 'Peter');\n});\n</script>\n```\n\n### PLUGINS\n\nType: `property`\n\nLe istanze di plugin in esecuzione, per nome.\n\nReturns: `Object` Le istanze di [plugin](../plugin/).\n\nExample: Leggi un plugin\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('ready', function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n});\n</script>\n```\n\n### PREF\n\nType: `property`\n\nLe preferenze persistenti dell'utente.\n\nReturns: `Object` Le preferenze.\n\nDescritto nella sua pagina: [PREF](../pref/).\n\n### PUSH(path, value)\n\nType: `method`\n\nAggiunge un elemento all'array salvato in un path e avvisa il path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path di un array esistente. |\n| `value` | `Object` | yes |  | L'elemento. |\n\nScrivi `^` davanti al path per aggiungere l'elemento all'inizio dell'array.\n\nExample: Aggiungi degli elementi\n```js\nSET('tags', ['b']);\nPUSH('tags', 'c');\nPUSH('^tags', 'a');\nconsole.log(GET('tags')); // [\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], data)\n\nType: `method`\n\nAggiunge dati a un indirizzo come stringa di query.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | L'indirizzo. |\n| `data` | `Object` | yes |  | I valori. |\n\nReturns: `String` L'indirizzo con la stringa di query.\n\nI valori vuoti vengono saltati, le date vengono convertite in stringhe ISO e gli array vengono uniti con virgole. `url` può iniziare con un metodo HTTP.\n\nExample: Crea degli indirizzi\n```js\nconsole.log(QUERIFY('/users/', { page: 2, q: 'a b' })); // /users/?page=2&q=a%20b\nconsole.log(QUERIFY('GET /users/', { page: 2 })); // GET /users/?page=2\nconsole.log(QUERIFY({ page: 2 })); // ?page=2\n```\n\n### REPO\n\nType: `property`\n\nUn oggetto vuoto per i dati condivisi della tua app.\n\nReturns: `Object` Il contenitore.\n\nExample: Salva un valore\n```js\nREPO.title = 'My app';\nconsole.log(REPO.title); // My app\n```\n\n### RESET(path)\n\nType: `method`\n\nAzzera lo stato dei componenti associati a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nGli stati `touched` e `modified` tornano ai valori predefiniti. Il valore del path non cambia.\n\nExample: Reimposta un modulo\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tSET('form.name @change', 'Peter');\n\tconsole.log(FIND('field').config.modified); // 1\n\tRESET('form');\n\tconsole.log(FIND('field').config.modified); // 0\n\tconsole.log(GET('form.name')); // Peter\n});\n</script>\n```\n\n### SCROLLBAR(element, [options])\n\nType: `method`\n\nAggiunge una barra di scorrimento personalizzata a un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'elemento. |\n| `options` | `Object` | no |  | Le opzioni. |\n\nReturns: `Object` La barra di scorrimento.\n\nOpzioni:\n\n| Opzione | Tipo | Descrizione |\n| --- | --- | --- |\n| `native` | Boolean | Mantiene la barra di scorrimento del browser e imposta solo l'overflow. |\n| `orientation` | String | `x` o `y`. Per impostazione predefinita sono attive entrambe le direzioni. |\n| `visibleX`, `visibleY` | Boolean | Mantiene visibile la traccia quando non c'è nulla da scorrere. |\n| `wrap` | Boolean | `false` usa il contenuto esistente come area di scorrimento. |\n| `controls` | jQuery | L'elemento che riceve le tracce della barra di scorrimento. |\n| `shadow` | Boolean | Aggiunge ombre sui bordi scorrevoli. |\n| `padding` | Number | La distanza delle tracce dal bordo. Valore predefinito: `5`. |\n| `minsize` | Number | La dimensione minima della barra. Valore predefinito: `50`. |\n| `thickness` | Number | Lo spessore usato quando il CSS non lo definisce. Valore predefinito: `10`. |\n| `margin`, `marginX`, `marginY` | Number | Regolano la dimensione dell'area di scorrimento. |\n| `offsetX`, `offsetY` | Number | Regolano la dimensione misurata dell'elemento. |\n| `floating` | Boolean | `false` riserva spazio per le barre. |\n| `parent` | String\\|jQuery | L'elemento di cui viene usata la dimensione. |\n| `interval` | Number | Il tempo tra i controlli della dimensione, in millisecondi. Valore predefinito: `54321`. |\n| `autoresize` | Boolean | `false` smette di misurare di nuovo l'elemento quando la finestra viene ridimensionata. Valore predefinito: `true`. |\n| `onscroll`, `onidle`, `onresize` | Function | Gestori che ricevono la barra di scorrimento. |\n\nL'oggetto restituito fornisce:\n\n| Membro | Descrizione |\n| --- | --- |\n| `area` | L'elemento che scorre. |\n| `body` | L'elemento con il contenuto. |\n| `element` | L'elemento originale. |\n| `resize()` | Misura di nuovo l'elemento. |\n| `scrollTop([value])` | Legge o imposta la posizione verticale. Una stringa come `'+20'` sposta rispetto alla posizione corrente. |\n| `scrollLeft([value])` | Legge o imposta la posizione orizzontale, con le stesse regole. |\n| `scrollBottom(offset)` | Scorre fino in fondo, meno `offset`. |\n| `scrollRight(offset)` | Scorre fino al bordo destro, meno `offset`. |\n| `scroll(x, y)` | Scorre fino a una posizione. |\n| `sync(element, [direction])` | Sincronizza lo scorrimento con un altro elemento. `direction` è `x` o `y`. |\n| `destroy()` | Ferma la barra di scorrimento. |\n\nGli [eventi](../events/) `scroll` e `scrollidle` segnalano lo scorrimento.\n\nExample: Scorri dal codice\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nvar scrollbar = SCROLLBAR($('#panel'));\n\nscrollbar.area.css('overflow', 'auto');\nscrollbar.resize(false, true);\nscrollbar.scrollTop(30);\nconsole.log(scrollbar.scrollTop()); // 30\nscrollbar.scrollTop('+20');\nconsole.log(scrollbar.scrollTop()); // 50\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nRestituisce la larghezza della barra di scorrimento del browser.\n\nReturns: `Number` La larghezza in pixel.\n\nExample: Leggi la larghezza\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nChiama una funzione o scrive un valore, a seconda del nome.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La destinazione. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nLa forma `plugin/method` chiama un metodo di un plugin e il nome di una funzione globale chiama quella funzione. Qualsiasi altro nome è un path, in cui `a` viene scritto con [SET()](../globals/).\n\nExample: Scrivi in un path\n```js\nSEEX('form.name', 'Peter');\nconsole.log(GET('form.name')); // Peter\n```\n\nExample: Chiama una funzione globale\n```js\nwindow.notify = function(text) {\n\tconsole.log(text); // Saved\n};\n\nSEEX('notify', 'Saved');\n```\n\n### SET(path, value)\n\nType: `method`\n\nScrive un valore in un path e avvisa tutto ciò che lo osserva.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, eventualmente con dei flag. |\n| `value` | `Object` | yes |  | Il valore, oppure una funzione `(current)` che lo restituisce. |\n\nGli oggetti mancanti lungo il path vengono creati. I flag fanno parte del path, ad esempio `form.name @change`. La forma `path[]` aggiunge il valore in fondo a un array. Una funzione come `value` riceve il valore corrente e il suo risultato viene scritto. Consulta [Path](../../guides/paths/) e [Flag e modificatori di path](../../guides/flags/).\n\nExample: Scrivi dei valori\n```js\nSET('user.name', 'Peter');\nSET('user.tags[]', 'admin');\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"tags\":[\"admin\"]}\n```\n\nExample: Scrivi un valore a partire da quello corrente\n```js\nSET('cart.count', 1);\nSET('cart.count', value => value + 1);\nconsole.log(GET('cart.count')); // 2\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nChiama un metodo sui componenti che corrispondono a un selettore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il selettore e il metodo. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\n`name` ha la forma `selector/method`:\n\n| Selettore | Corrisponde a |\n| --- | --- |\n| `name` | I componenti con questo nome. |\n| `#id` | Il componente con questo identificatore. |\n| `*` | Tutti i componenti che hanno il metodo. |\n\nIl flag `@important` riprova ogni 500 millisecondi finché non esiste un componente corrispondente con il metodo. Un componente dichiarato come lazy viene creato dalla prima chiamata, a meno che il nome non inizi con `!`.\n\nExample: Chiama un metodo di un componente\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log(value); // 5\n\t};\n});\n\nON('ready', function() {\n\tSETTER('counter/add', 5);\n});\n</script>\n```\n\n### setTimeout2(name, callback, timeout, [limit], [param])\n\nType: `method`\n\nEsegue una funzione dopo un ritardo, che riparte a ogni chiamata con lo stesso nome.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del timer. |\n| `callback` | `Function` | yes |  | La funzione. |\n| `timeout` | `Number` | yes |  | Il ritardo in millisecondi. |\n| `limit` | `Number` | no |  | Il numero massimo di chiamate in un periodo di attesa. |\n| `param` | `Object` | no |  | L'argomento della funzione. |\n\nReturns: `String` Il nome del timer. Una chiamata ignorata da `limit` non restituisce nulla.\n\nCon `limit`, il ritardo riparte al massimo `limit` volte. Le chiamate successive vengono ignorate finché la funzione non viene eseguita, quindi non può essere rimandata all'infinito.\n\nExample: Esegui una volta dopo l'ultima chiamata\n```js\nvar count = 0;\nvar run = function() {\n\tcount++;\n\tconsole.log(count); // 1\n};\n\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\n```\n\n### STRINGIFY(value, [compress], [fields], [encrypt])\n\nType: `method`\n\nSerializza un valore in JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore. |\n| `compress` | `Boolean` | no | `false` | Rimuove i valori vuoti. |\n| `fields` | `Array|Object|Function` | no |  | Le chiavi da mantenere. |\n| `encrypt` | `Boolean|String` | no |  | `true` codifica il JSON con [ENCRYPT()](../globals/). Una stringa fa lo stesso e fa da chiave. |\n\nReturns: `String` Il JSON.\n\nCon `compress` impostato a `true`, le stringhe vengono ripulite dagli spazi iniziali e finali, mentre le stringhe vuote, `false` e `null` vengono esclusi. L'argomento `fields` seleziona le chiavi: un array di chiavi consentite, un oggetto in cui `false` esclude una chiave, oppure una funzione `(key, value)` che restituisce `true` per le chiavi da mantenere.\n\nExample: Comprimi e filtra\n```js\nvar data = { name: ' Peter ', note: '', age: 30 };\n\nconsole.log(STRINGIFY(data, true)); // {\"name\":\"Peter\",\"age\":30}\nconsole.log(STRINGIFY(data, false, ['age'])); // {\"age\":30}\n```\n\nExample: Codifica il JSON\n```js\nvar text = STRINGIFY({ id: 5 }, false, null, 'secret');\nconsole.log(DECRYPT(text, 'secret')); // {\"id\":5}\n```\n\n### STYLE(value, [id], [selector])\n\nType: `method`\n\nAggiunge CSS alla pagina.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | Il CSS. |\n| `id` | `String` | no |  | L'identificatore dell'elemento di stile. |\n| `selector` | `String` | no |  | Un selettore anteposto a ogni regola. |\n\nUn elemento con lo stesso `id` viene sostituito. L'elemento ha come identificatore `css` seguito da `id`. Con `selector`, ogni regola viene preceduta da questo selettore.\n\nExample: Aggiungi stili con scope\n```js\nSTYLE('b { color: red }', 'theme', '.panel');\nconsole.log($('#csstheme').html()); // .panel b{ color: red }\n```\n\n### TAPI(name, [data], callback, [scope])\n\nType: `method`\n\nChiama un'operazione API di Total.js sull'indirizzo indicato in `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'operazione, eventualmente seguito da parole chiave. |\n| `data` | `Object` | no |  | I dati dell'operazione. |\n| `callback` | `Function|String` | yes |  | Una funzione o un path che riceve la risposta. |\n| `scope` | `Object` | no | `window` | L'oggetto in cui viene risolto un path `callback`. |\n\nFunziona come [API()](../globals/), con l'indirizzo preso da [DEF.api](../def/).\n\nExample: Salva una risposta in un path\n```js\nDEF.api = '/admin/api/';\n\nTAPI('users_list', { page: 1 }, 'users.items');\n\nWATCH('users.items', function(value) {\n\tconsole.log(value.length); // 2\n});\n```\n\n### TEMP\n\nType: `property`\n\nUn oggetto per i dati di breve durata.\n\nReturns: `Object` Il contenitore.\n\nLa libreria lo sostituisce con un oggetto vuoto ogni minuto.\n\nExample: Salva un valore\n```js\nTEMP.result = 5;\nconsole.log(TEMP.result); // 5\n```\n\n### TOGGLE(path)\n\nType: `method`\n\nInverte il valore booleano di un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nExample: Inverti un valore\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### Total\n\nType: `property`\n\nL'oggetto principale della libreria.\n\nReturns: `Object` L'oggetto principale.\n\nLo stesso oggetto di [MAIN](../main/).\n\n### TRANSLATE(text)\n\nType: `method`\n\nSostituisce il markup `@(text)` con le traduzioni.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Il testo con il markup. |\n\nReturns: `String` Il testo tradotto.\n\nIl testo senza traduzione resta nella lingua originale. Le traduzioni vengono caricate con [LOCALIZE()](../globals/).\n\nExample: Traduci un testo\n```js\nLOCALIZE('T' + HASH('Yes').toString(36) + ' : Ano');\nconsole.log(TRANSLATE('@(Yes) / @(No)')); // Ano / No\n```\n\n### UNAUTHORIZED(...permissions)\n\nType: `method`\n\nControlla i permessi dell'utente che ha effettuato l'accesso.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `permissions` | `String` | yes |  | Uno o più permessi. |\n\nReturns: `Boolean` `true` quando l'accesso è negato.\n\nIl metodo legge la variabile globale `user`. Un utente con `sa` o `su` impostato ha tutti i permessi. Altrimenti, i permessi provengono da `user.permissions` o `user.roles`, sotto forma di array o di oggetto. Il risultato è `true` quando l'utente non ha nessuno dei permessi indicati, oppure quando `user` non esiste.\n\nExample: Controlla un permesso\n```js\nwindow.user = { roles: ['editor'] };\n\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [callback])\n\nType: `method`\n\nRimuove gli osservatori da un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. Puoi unire più path con `+`. |\n| `callback` | `Function` | no |  | L'osservatore da rimuovere. |\n\nSenza `callback`, vengono rimossi tutti gli osservatori del path.\n\nExample: Smetti di osservare\n```js\nvar count = 0;\nvar watcher = function() {\n\tcount++;\n};\n\nWATCH('form.name', watcher);\nSET('form.name', 'A');\nUNWATCH('form.name', watcher);\nSET('form.name', 'B');\nconsole.log(count); // 1\n```\n\n### UPD(path)\n\nType: `method`\n\nAvvisa un path dopo che il suo valore è stato modificato direttamente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, eventualmente con dei flag. |\n\n`UPDATE()` è la stessa funzione con un altro nome.\n\nExample: Avvisa dopo una modifica diretta\n```js\nwindow.form = { name: 'A' };\n\nWATCH('form.name', function(value) {\n\tconsole.log(value); // B\n});\n\nform.name = 'B';\nUPD('form.name');\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nControlla la posizione verticale di un elemento rispetto al viewport.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | L'elemento. |\n| `threshold` | `Number` | no | `0` | Il numero di pixel dell'elemento che devono trovarsi dentro il viewport. |\n| `mode` | `String` | no | `visible` | `visible`, `above` o `below`. |\n\nReturns: `Boolean` Il risultato del controllo.\n\n`mode` seleziona il controllo: `visible` verifica se l'elemento è nel viewport, `above` se si trova sopra di esso e `below` se si trova sotto. Un elemento nascosto restituisce `false`.\n\nExample: Controlla un elemento\n```html\n<div id=\"top\">Top</div>\n<div style=\"height:5000px\"></div>\n<div id=\"far\">Far</div>\n\n<script>\nconsole.log(VISIBLE($('#top'))); // true\nconsole.log(VISIBLE($('#far'))); // false\nconsole.log(VISIBLE($('#far'), 0, 'below')); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nUn nome breve dell'oggetto `window`.\n\nReturns: `Object` L'oggetto `window`.\n\nExample: Confronta gli oggetti\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback)\n\nType: `method`\n\nEsegue una funzione quando una condizione è soddisfatta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | Una funzione o un path. |\n| `callback` | `Function` | yes |  | La funzione da eseguire. |\n\nLa condizione viene controllata subito e poi ogni 500 millisecondi. Una funzione deve restituire un valore truthy. Per un path, l'attesa termina quando il path contiene un valore truthy.\n\nExample: Attendi un valore\n```js\nWAIT('app.config', function() {\n\tconsole.log(GET('app.config.name')); // Demo\n});\n\nsetTimeout(function() {\n\tSET('app.config', { name: 'Demo' });\n}, 100);\n```\n\n### WARN(...values)\n\nType: `method`\n\nStampa un avviso nella console del browser.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `values` | `Object` | yes |  | I valori da stampare. |\n\n### WATCH(path, callback, [init])\n\nType: `method`\n\nOsserva le modifiche di un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `callback` | `Function` | yes |  | Una funzione che riceve `(value, flags, path)`: il valore osservato, i flag e il path modificato. |\n| `init` | `Boolean` | no | `false` | Chiama anche l'osservatore una volta dopo la registrazione. |\n\nUn osservatore viene eseguito quando cambia il suo path, quando cambia un path genitore e quando cambia un path annidato al suo interno. Puoi unire più path con `+`.\n\nExample: Osserva un path\n```js\nWATCH('user.name', function(value, flags, path) {\n\tconsole.log(value, path); // Peter user.name\n});\n\nSET('user.name', 'Peter');\n```\n\n### WH\n\nType: `property`\n\nL'altezza della finestra in pixel.\n\nReturns: `Number` L'altezza.\n\nIl valore viene impostato durante l'avvio della libreria e aggiornato quando la finestra viene ridimensionata.\n\nExample: Leggi l'altezza\n```js\nON('ready', function() {\n\tconsole.log(typeof(WH)); // number\n});\n```\n\n### WIDTH([element])\n\nType: `method`\n\nRestituisce il nome della dimensione del dispositivo in base alla larghezza di un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | L'elemento misurato. |\n\nReturns: `String` Il nome della dimensione.\n\nLe dimensioni `xs`, `sm`, `md` e `lg` sono definite in [DEF.devices](../def/).\n\nExample: Misura un elemento\n```html\n<div id=\"box\" style=\"width:800px\"></div>\n\n<script>\nconsole.log(WIDTH($('#box'))); // sm\n</script>\n```\n\n### WW\n\nType: `property`\n\nLa larghezza della finestra in pixel.\n\nReturns: `Number` La larghezza.\n\nIl valore viene impostato durante l'avvio della libreria e aggiornato quando la finestra viene ridimensionata.\n\nExample: Leggi la larghezza\n```js\nON('ready', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n","entries":[{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], callback, [onprogress], [scope], [id])","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(key, timeout, [callback])","since":"","deprecated":false},{"type":"method","name":"CACHE()","signature":"CACHE(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"CACHEPATH()","signature":"CACHEPATH(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, [callback])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [raw])","since":"","deprecated":false},{"type":"method","name":"CLRELOAD()","signature":"CLRELOAD(name, [callback])","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], callback, [dependencies], [css])","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"COMPONENTS(path)","since":"","deprecated":false},{"type":"method","name":"CONFIG()","signature":"CONFIG(selector, config)","since":"","deprecated":false},{"type":"property","name":"COOKIES","signature":"COOKIES","since":"","deprecated":false},{"type":"method","name":"COPY()","signature":"COPY(source, target)","since":"","deprecated":false},{"type":"method","name":"CSS()","signature":"CSS(value, [id], [selector])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(text, [key], [type])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"EMPTYARRAY","signature":"EMPTYARRAY","since":"","deprecated":false},{"type":"property","name":"EMPTYOBJECT","signature":"EMPTYOBJECT","since":"","deprecated":false},{"type":"method","name":"ENCRYPT()","signature":"ENCRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"method","name":"ENV()","signature":"ENV(name, [value])","since":"","deprecated":false},{"type":"method","name":"ENVIRONMENT()","signature":"ENVIRONMENT(name, [version], [language], [env])","since":"","deprecated":false},{"type":"method","name":"ERROR()","signature":"ERROR(response, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, callback)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], callback)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [all])","since":"","deprecated":false},{"type":"method","name":"FLAGS()","signature":"FLAGS(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(code)","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE()","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [noflags])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([length])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value)","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value])","since":"","deprecated":false},{"type":"method","name":"inDOM()","signature":"inDOM(element)","since":"","deprecated":false},{"type":"property","name":"isIE","signature":"isIE","since":"","deprecated":false},{"type":"property","name":"isMOBILE","signature":"isMOBILE","since":"","deprecated":false},{"type":"property","name":"isPRIVATEMODE","signature":"isPRIVATEMODE","since":"","deprecated":false},{"type":"property","name":"isROBOT","signature":"isROBOT","since":"","deprecated":false},{"type":"property","name":"isSTANDALONE","signature":"isSTANDALONE","since":"","deprecated":false},{"type":"property","name":"isTOUCH","signature":"isTOUCH","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"method","name":"LOCALIZE()","signature":"LOCALIZE(text)","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"method","name":"NEWUIBIND()","signature":"NEWUIBIND(element, [path], [config])","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, reference, [before])","since":"","deprecated":false},{"type":"method","name":"NODEMOVE()","signature":"NODEMOVE(element, [up])","since":"","deprecated":false},{"type":"method","name":"NOOP()","signature":"NOOP()","since":"","deprecated":false},{"type":"method","name":"NOTFOCUSED()","signature":"NOTFOCUSED()","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path)","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [callback])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value)","since":"","deprecated":false},{"type":"method","name":"PIPE()","signature":"PIPE(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [config], callback, [dependencies])","since":"","deprecated":false},{"type":"property","name":"PLUGINS","signature":"PLUGINS","since":"","deprecated":false},{"type":"property","name":"PREF","signature":"PREF","since":"","deprecated":false},{"type":"method","name":"PUSH()","signature":"PUSH(path, value)","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], data)","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path)","since":"","deprecated":false},{"type":"method","name":"SCROLLBAR()","signature":"SCROLLBAR(element, [options])","since":"","deprecated":false},{"type":"method","name":"SCROLLBARWIDTH()","signature":"SCROLLBARWIDTH()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, callback, timeout, [limit], [param])","since":"","deprecated":false},{"type":"method","name":"STRINGIFY()","signature":"STRINGIFY(value, [compress], [fields], [encrypt])","since":"","deprecated":false},{"type":"method","name":"STYLE()","signature":"STYLE(value, [id], [selector])","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path)","since":"","deprecated":false},{"type":"property","name":"Total","signature":"Total","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...permissions)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [callback])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path)","since":"","deprecated":false},{"type":"method","name":"VISIBLE()","signature":"VISIBLE(element, [threshold], [mode])","since":"","deprecated":false},{"type":"property","name":"W","signature":"W","since":"","deprecated":false},{"type":"method","name":"WAIT()","signature":"WAIT(condition, callback)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...values)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcS61wo61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/globals/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Globálne funkcie","summary":"Funkcie a premenné, ktoré knižnica pridáva do objektu window.","markdown":"---\ntitle: \"Globálne funkcie\"\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/globals/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Globálne funkcie\n\n> Funkcie a premenné, ktoré knižnica pridáva do objektu window.\n\nKnižnica pridáva tieto funkcie a premenné do `window`, takže sú dostupné všade v tvojom kóde. Ako spolu fungujú, zistíš v častiach [Paths](../../guides/paths/) a [Dátová väzba](../../guides/data-binding/).\n\n## API\n\n### ADAPT(path, id, text)\n\nType: `method`\n\nPripraví kúsok HTML pre konkrétnu path a identifikátor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Hodnota pre `~PATH~` a `CLASS`. Ak chceš tieto náhrady preskočiť, použi `null`. |\n| `id` | `String` | yes |  | Hodnota pre `~ID~`. Ak chceš túto náhradu preskočiť, použi `null`. |\n| `text` | `String` | yes |  | Text na prípravu. |\n\nReturns: `String` Pripravený text.\n\nMetóda preloží značky `@(text)`, použije premenné `--name--` a nahradí `~CDN~` hodnotou [DEF.cdn](../def/). Keď je nastavené `path`, `~PATH~` a `CLASS` sa zmenia na path, elementy `<ui-plugin>` bez atribútu `path` ho dostanú a prvé `PLUGIN(function(` sa zmení na `PLUGIN('path', function(`. Keď je nastavené `id`, `~ID~` sa zmení na identifikátor. Hodnota `text`, ktorá je prázdna alebo nie je reťazec, sa vráti nezmenená.\n\nExample: Nahraď kľúčové slová\n```js\nvar html = '<div class=\"CLASS\" data-id=\"~ID~\">~PATH~</div>';\nconsole.log(ADAPT('users', 'u1', html)); // <div class=\"users\" data-id=\"u1\">users</div>\n```\n\n### AJAX(url, [data], callback, [onprogress], [scope], [id])\n\nType: `method`\n\nOdošle HTTP požiadavku a odpoveď doručí funkcii alebo na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Metóda, adresa a voliteľné kľúčové slová, napríklad `POST /api/users/ ERROR`. |\n| `data` | `Object` | no |  | Telo požiadavky: objekt odoslaný ako JSON, reťazec odoslaný ako dáta formulára alebo `FormData`. |\n| `callback` | `Function|String` | yes |  | Funkcia, ktorá dostane odpoveď, alebo path, na ktorú sa odpoveď zapíše. |\n| `onprogress` | `Function|String` | no |  | Funkcia alebo path, ktorá dostane percento nahrávania. |\n| `scope` | `Object` | no | `window` | Objekt, v ktorom sa vyhodnotí path v `callback`. |\n| `id` | `String` | no | `url` | Kľúč, ktorý používa `SYNC` a cache. |\n\n`url` začína metódou HTTP, za ktorou nasleduje adresa a voliteľné kľúčové slová oddelené medzerami:\n\n| Kľúčové slovo | Význam |\n| --- | --- |\n| `ERROR` | Odovzdá odpoveď funkcii [ERROR()](../globals/). Ak obsahuje chybu, vyšle sa udalosť `ERROR` a `callback` sa nespustí. Chybový stav bez tela odpovede vyšle udalosť `ERROR` so stavovým kódom. |\n| `SYNC` | Zaradí požiadavky s rovnakým `id` do frontu, aby bežali jedna po druhej. |\n| `<1 minute>` | Uloží odpoveď na daný čas do cache cez [CACHE()](../globals/), pokiaľ nejde o chybu. Kým požiadavka čaká na odpoveď, ostatné volania s rovnakým `id` čakajú na jej odpoveď, takže sa odošle iba jedna požiadavka. |\n| `#name` | Najprv načíta zoznam kódov `name`. Pozri [CL()](../globals/). |\n| `@flag` | Vyšle flag pri odoslaní požiadavky. Pozri [Flagy a modifikátory path](../../guides/flags/). |\n\nObjekt v `data` sa odošle ako JSON, reťazec sa odošle tak, ako je, s typom obsahu `application/x-www-form-urlencoded` a `FormData` sa odošle ako formulár.\n\nStavový kód 400 alebo vyšší sa považuje za chybu. Požiadavka, ktorá sa nedostane k serveru, je prerušená alebo jej vyprší čas, má stavový kód `0` a `callback` dostane prázdnu odpoveď. Odpoveď s obsahom typu JSON sa spracuje cez [PARSE()](../globals/). Každá požiadavka pridáva hlavičky z [DEF.headers](../def/). Keď je nastavené [DEF.language](../def/), pridá sa do reťazca dotazu. Keď je nastavené [DEF.version](../def/), pridá sa do reťazca dotazu adries `.html`.\n\n[Udalosti](../events/) `request` a `response` ti umožňujú každé volanie skontrolovať alebo zmeniť. Po odoslaní požiadavky obsahuje `options.xhr` v udalosti `request` jej `XMLHttpRequest`, takže ju `options.xhr.abort()` zastaví. `UPLOAD()` je tá istá funkcia pod iným názvom.\n\nExample: Prečítaj odpoveď\n```js\nAJAX('GET /api/users/', function(response) {\n\tconsole.log(response.length); // 2\n});\n```\n\nExample: Ulož odpoveď na path\n```js\nAJAX('POST /api/orders/', { amount: 10 }, 'orders.last');\n\nWATCH('orders.last', function(value) {\n\tconsole.log(value.id); // 100\n});\n```\n\nExample: Odošli dáta formulára\n```js\nAJAX('POST /api/login/', 'name=Ann&remember=1', function(response) {\n\tconsole.log(response.ok); // true\n});\n```\n\nExample: Zastav požiadavku\n```js\nvar request;\n\nON('request', options => request = options);\nON('ERROR', status => console.log('failed', status)); // failed 0\n\nAJAX('GET /api/report/ ERROR', NOOP);\nrequest.xhr.abort();\n```\n\n### API(url, name, [data], callback, [scope])\n\nType: `method`\n\nZavolá API endpoint Total.js na konkrétnej adrese.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Adresa endpointu. |\n| `name` | `String` | yes |  | Názov operácie, voliteľne s kľúčovými slovami. |\n| `data` | `Object` | no |  | Dáta operácie. |\n| `callback` | `Function|String` | yes |  | Funkcia alebo path, ktorá dostane odpoveď. |\n| `scope` | `Object` | no | `window` | Objekt, v ktorom sa vyhodnotí path v `callback`. |\n\nMetóda odošle `POST url` s telom JSON `{ schema: name, data: data }`. Za názvom môžu nasledovať kľúčové slová, ktoré prijíma [AJAX()](../globals/), napríklad `users_list ERROR`. Ak chceš používať jednu pevnú adresu, pozri [TAPI()](../globals/) a [PIPE()](../globals/).\n\nExample: Zavolaj operáciu\n```js\nAPI('/admin/api/', 'users_read', { id: 5 }, function(response) {\n\tconsole.log(response.name); // Peter\n});\n```\n\n### APPEARANCE(options)\n\nType: `method`\n\nNastaví farebnú schému stránky cez CSS premenné a triedy elementu body.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Prepínače a CSS premenné. |\n\nKaždý kľúč sa stane CSS premennou na `:root`, okrem štyroch prepínačov uvedených nižšie. Kľúč `color` aktualizuje aj [DEF.color](../def/) a pridá premennú `--rgb` s hodnotami červenej, zelenej a modrej z hexadecimálnej farby s tromi alebo šiestimi číslicami.\n\n| Kľúč | Význam |\n| --- | --- |\n| `dark` alebo `darkmode` | Prepína triedu `ui-dark` na elemente body. |\n| `large` alebo `largemode` | Prepína triedu `ui-large` na elemente body. |\n\nPrefix triedy pochádza z [DEF.prefixcsslibrary](../def/).\n\nExample: Tmavý motív s akcentovou farbou\n```js\nAPPEARANCE({ dark: true, color: '#4285F4' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#4285F4;--rgb:66,133,244}\nconsole.log($('body').hclass('ui-dark')); // true\n```\n\nExample: Krátka farba\n```js\nAPPEARANCE({ color: '#abc' });\n\nconsole.log($('#cssappearance').html()); // :root{--color:#abc;--rgb:170,187,204}\n```\n\n### ASETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nVytvorí funkciu, ktorá neskôr zavolá metódu komponentu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Selektor a metóda v rovnakom tvare ako v `SETTER()`. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nReturns: `Function` Funkcia bez argumentov.\n\nKaždé volanie vrátenej funkcie spustí [SETTER()](../globals/) s argumentmi zadanými tu.\n\nExample: Priprav volanie\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log('added', value); // added 5\n\t};\n});\n\nON('ready', function() {\n\tvar add = ASETTER('counter/add', 5);\n\tadd();\n});\n</script>\n```\n\n### ATTRD(element, [name])\n\nType: `method`\n\nPrečíta atribút `data-*` z elementu alebo z jeho najbližšieho nadradeného elementu, ktorý ho má.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Event|Element|Object` | yes |  | Východiskový bod. |\n| `name` | `String` | no | `id` | Názov atribútu bez prefixu `data-`. |\n\nReturns: `String` Hodnota atribútu.\n\n`element` môže byť objekt jQuery, udalosť jQuery (použije sa jej `currentTarget`) alebo DOM element. Pri obyčajnom objekte vráti metóda vlastnosť `name`. Každá iná hodnota sa vráti tak, ako je.\n\nExample: Prečítaj najbližší identifikátor\n```html\n<div data-id=\"15\" data-type=\"user\"><button id=\"save\">Save</button></div>\n\n<script>\nvar button = $('#save');\nconsole.log(ATTRD(button)); // 15\nconsole.log(ATTRD(button, 'type')); // user\nconsole.log(ATTRD({ id: 20 })); // 20\n</script>\n```\n\n### BLOCKED(key, timeout, [callback])\n\nType: `method`\n\nObmedzuje, ako často sa môže operácia spustiť.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Názov operácie. |\n| `timeout` | `Number|String` | yes |  | Čas v milisekundách alebo text ako `5 minutes`. |\n| `callback` | `Function` | no |  | Funkcia, ktorá sa spustí, keď operácia nie je zablokovaná. |\n\nReturns: `Boolean` `true`, keď je operácia zablokovaná.\n\nPrvé volanie zablokuje `key` na zadaný čas a vráti `false`. Ďalšie volania vracajú `true`, kým čas neuplynie. Blokovanie na 10 sekúnd alebo dlhšie sa uchováva v `localStorage`, takže prežije opätovné načítanie stránky.\n\nExample: Povoľ jedno kliknutie za sekundu\n```js\nON('ready', function() {\n\tconsole.log(BLOCKED('save', 1000)); // false\n\tconsole.log(BLOCKED('save', 1000)); // true\n});\n```\n\n### CACHE(key, [value], [expire])\n\nType: `method`\n\nPrečíta alebo zapíše hodnotu v trvalej cache.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Kľúč. |\n| `value` | `Object` | no |  | Hodnota na uloženie. |\n| `expire` | `String` | no |  | Životnosť hodnoty alebo `session`. |\n\nReturns: `Object` Pri čítaní uložená hodnota, inak nič.\n\nS `expire` metóda hodnotu uloží. Bez neho vráti uloženú hodnotu alebo `null`, keď hodnota chýba alebo jej vypršala platnosť. Hodnota `session` drží dáta v pamäti, kým sa stránka nezatvorí. Každá iná hodnota je čas ako `10 minutes`, `2 hours`, `1 day`, `1 week`, `1 month` alebo `1 year` a dáta sa uložia cez [DEF.onstoragesave](../def/).\n\nCache sa načíta pri štarte knižnice, preto ju používaj až od [udalosti](../events/) `ready`.\n\nExample: Zapíš a prečítaj\n```js\nON('ready', function() {\n\tCACHE('filter', { page: 2 }, '1 day');\n\tconsole.log(CACHE('filter')); // {\"page\":2}\n\tconsole.log(CACHE('missing')); // null\n});\n```\n\n### CACHEPATH(path, expire, [def])\n\nType: `method`\n\nUchová hodnotu path v cache medzi návštevami.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `expire` | `String` | yes |  | Životnosť uloženej hodnoty, napríklad `1 day`. |\n| `def` | `Object|Function` | no |  | Hodnota, ktorá sa použije, keď nie je uložené nič. Ak je to funkcia, zavolá sa a vráti ju. |\n\nMetóda ukladá každú zmenu path cez [CACHE()](../globals/) na čas uvedený v `expire`. Keď je path prázdny, zapíše sa doň uložená hodnota, a keď nie je uložené nič, zapíše sa `def`. Path, ktorý už obsahuje hodnotu, si ju ponechá.\n\nAk metódu zavoláš skôr, ako knižnica načíta cache, počká na ňu a potom hodnotu obnoví. Pluginy majú rovnakú metódu s relatívnym path: [plugin.cachepath()](../plugin/).\n\nExample: Zapamätaj si filter\n```js\nCACHEPATH('filter.q', '1 day', 'all');\nconsole.log(GET('filter.q')); // all\n\nSET('filter.q', 'lamp');\n// After a reload of the page, GET('filter.q') returns lamp\n```\n\n### CL(name, [callback])\n\nType: `method`\n\nNačíta zoznamy kódov zaregistrované cez `CLINIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Jeden názov alebo niekoľko názvov oddelených čiarkami. |\n| `callback` | `Function` | no |  | Funkcia, ktorá sa spustí po načítaní zoznamov. |\n\nZoznam kódov sú zdieľané dáta, napríklad zoznam krajín, uložené v [DEF.cl](../def/). Zoznam sa načíta raz. `callback` sa spustí, keď sú dostupné všetky zoznamy. Názov, ktorý ešte nie je zaregistrovaný, sa kontroluje každých 500 milisekúnd, kým sa neobjaví.\n\nExample: Načítaj zoznam na požiadanie\n```js\nCLINIT('countries', function(next) {\n\tnext([{ id: 'SK', name: 'Slovakia' }]);\n});\n\nON('ready', function() {\n\tCL('countries', function() {\n\t\tconsole.log(DEF.cl.countries.length); // 1\n\t});\n});\n```\n\n### clearTimeout2(name)\n\nType: `method`\n\nZruší časovač vytvorený cez `setTimeout2()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov časovača. |\n\nReturns: `Boolean` `true`, keď časovač existuje.\n\nExample: Zruš časovač\n```js\nsetTimeout2('search', NOOP, 1000);\nconsole.log(clearTimeout2('search')); // true\nconsole.log(clearTimeout2('unknown')); // false\n```\n\n### CLINIT(name, source, [init])\n\nType: `method`\n\nZaregistruje zdroj zoznamu kódov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov zoznamu kódov. |\n| `source` | `Function|String` | yes |  | Funkcia, požiadavka alebo operácia. |\n| `init` | `Boolean` | no | `false` | Načíta zoznam okamžite. |\n\nKeď je `source` funkcia, dostane `next(value, [extend])`. Zoznam odovzdaj do `next()`. Keď je `extend` nastavené na `true`, `value` je objekt, ktorého kľúče sa uložia ako samostatné zoznamy kódov.\n\nKeď je `source` reťazec, hodnota začínajúca metódou HTTP sa načíta cez [AJAX()](../globals/). Každá iná hodnota je operácia pre [TAPI()](../globals/).\n\nExample: Načítaj niekoľko zoznamov naraz\n```js\nCLINIT('all', function(next) {\n\tnext({ colors: ['red'], sizes: ['XL'] }, true);\n}, true);\n\nON('ready', function() {\n\tsetTimeout(function() {\n\t\tconsole.log(DEF.cl.colors, DEF.cl.sizes); // [\"red\"] [\"XL\"]\n\t}, 100);\n});\n```\n\n### CLONE(value, [raw])\n\nType: `method`\n\nVytvorí hlbokú kópiu hodnoty.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object|String` | yes |  | Hodnota na skopírovanie alebo path. |\n| `raw` | `Boolean` | no | `false` | Považuje reťazec za obyčajnú hodnotu. |\n\nReturns: `Object` Kópia.\n\nReťazec sa považuje za path k objektu alebo poľu a skopíruje sa hodnota, ktorá sa tam nachádza. Keď je `raw` nastavené na `true`, reťazec sa vráti tak, ako je. Objekty sa kopírujú cez JSON a dátumy v nich zostávajú dátumami.\n\nExample: Skopíruj objekt\n```js\nvar a = { user: { name: 'Peter' } };\nvar b = CLONE(a);\nb.user.name = 'Lucia';\nconsole.log(a.user.name); // Peter\n```\n\nExample: Skopíruj hodnotu path\n```js\nSET('form', { name: 'Peter' });\nvar copy = CLONE('form');\nconsole.log(copy); // {\"name\":\"Peter\"}\n```\n\n### CLRELOAD(name, [callback])\n\nType: `method`\n\nZnova načíta zoznamy kódov z ich zdrojov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Jeden názov alebo niekoľko názvov oddelených čiarkami. |\n| `callback` | `Function` | no |  | Funkcia, ktorá sa spustí po opätovnom načítaní zoznamov. |\n\nZnova sa načítajú iba zoznamy, ktoré sú už načítané. Ostatné názvy sa preskočia.\n\nExample: Obnov zoznam\n```js\nvar counter = 0;\n\nCLINIT('stats', function(next) {\n\tnext([++counter]);\n});\n\nON('ready', function() {\n\tCL('stats', function() {\n\t\tCLRELOAD('stats', function() {\n\t\t\tconsole.log(DEF.cl.stats); // [2]\n\t\t});\n\t});\n});\n```\n\n### CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nSpustí príkaz na každom komponente, ktorý ho registruje.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Príkaz, voliteľne s flagmi za ním. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nKomponenty registrujú príkazy cez [command()](../component/). Za názvom môžu po medzere nasledovať flagy, napríklad `CMD('refresh @saved')`: vyšlú sa ako prvé, rovnako ako pri [SET()](../globals/). Ak chceš príkaz spustiť iba v časti stránky, použi [$(selector).CMD()](../jquery/) alebo [plugin.cmd()](../plugin/).\n\nExample: Vyčisti každý zoznam\n```html\n<ui-component name=\"list\"></ui-component>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nvar count = 0;\n\nCOMPONENT('list', function(self) {\n\tself.command('clear', value => count += value);\n});\n\nON('ready', function() {\n\tCMD('clear', 1);\n\tconsole.log(count); // 2\n});\n</script>\n```\n\n### COMPONENT(name, [config], callback, [dependencies], [css])\n\nType: `method`\n\nZaregistruje deklaráciu komponentu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov komponentu. |\n| `config` | `String` | no |  | Predvolená konfigurácia v tvare `key:value;key:value`. |\n| `callback` | `Function` | yes |  | Deklarácia: `function(self, config, cls)`. |\n| `dependencies` | `String|Array` | no |  | Adresy, ktoré sa majú najprv importovať, oddelené čiarkami. Pole môže obsahovať aj funkcie, ktoré dostanú `next`. |\n| `css` | `String` | no |  | Štýly komponentu. |\n\n`callback` sa spustí raz pre každú inštanciu a dostane inštanciu, jej konfiguráciu a jej CSS triedu. V argumente `css` sa slovo `CLASS` zmení na `ui-`, za ktorým nasleduje názov komponentu. Pozri [Vytváranie komponentov](../../guides/creating-components/) a objekt [Component](../component/).\n\nExample: Deklaruj komponent\n```html\n<ui-component name=\"hello\"></ui-component>\n\n<script>\nCOMPONENT('hello', 'name:World', function(self, config, cls) {\n\tself.make = function() {\n\t\tself.element.aclass(cls).html('Hello ' + config.name);\n\t\tconsole.log(self.element.html()); // Hello World\n\t};\n});\n</script>\n```\n\n### COMPONENTS(path)\n\nType: `method`\n\nVráti komponenty naviazané na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s flagmi. |\n\nReturns: `Array` Zodpovedajúce inštancie [komponentov](../component/).\n\nPath zahŕňa všetko pod ňou, takže `form` vráti aj komponent naviazaný na `form.name`. Flagy v path výsledok zúžia: `@visible`, `@hidden`, `@touched`, `@modified`, `@required`, `@invalid`, `@valid`, `@disabled` a `@enabled`.\n\nExample: Nájdi povinné polia\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n<ui-component name=\"field\" path=\"form.note\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.setter = NOOP;\n});\n\nON('ready', function() {\n\tconsole.log(COMPONENTS('form').length); // 2\n\tconsole.log(COMPONENTS('form @required').length); // 1\n});\n</script>\n```\n\n### CONFIG(selector, config)\n\nType: `method`\n\nZmení konfiguráciu existujúcich aj budúcich komponentov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String|Function` | yes |  | Komponenty na konfiguráciu. |\n| `config` | `String|Object` | yes |  | Konfigurácia ako objekt alebo v tvare `key:value;key:value`. |\n\n`selector` môže byť:\n\n| Selektor | Zodpovedá |\n| --- | --- |\n| `name` | Komponentom s týmto názvom. |\n| `#id` | Komponentu s týmto identifikátorom. |\n| `.path` | Komponentom, ktorých path obsahuje `path`. |\n| `*` | Všetkým komponentom. |\n| `a, b` | Niekoľkým selektorom oddeleným čiarkami. |\n| `function(instance)` | Komponentom, pre ktoré funkcia vráti `true`. |\n\nExample: Nakonfiguruj podľa názvu\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tCONFIG('box', 'color:red;size:10');\n\tconsole.log(FIND('box').config.size); // 10\n});\n</script>\n```\n\n### COOKIES\n\nType: `property`\n\nČíta a zapisuje cookies prehliadača.\n\nReturns: `Object` Objekt s metódami.\n\nObjekt má tri metódy:\n\n| Metóda | Popis |\n| --- | --- |\n| `COOKIES.get(name)` | Vráti hodnotu alebo prázdny reťazec. |\n| `COOKIES.set(name, value, [expire], [samesite])` | Zapíše cookie pre path `/`. `expire` je počet dní, `Date` alebo text ako `1 day`. Bez `expire` sa cookie uchová, kým nezavrieš prehliadač. `samesite` je napríklad `lax`. |\n| `COOKIES.rem(name)` | Odstráni cookie. |\n\nExample: Zapíš a prečítaj cookie\n```js\nCOOKIES.set('theme', 'dark', '1 month', 'lax');\nconsole.log(COOKIES.get('theme')); // dark\n```\n\nExample: Uchovaj cookie na týždeň\n```js\nCOOKIES.set('token', 'a=1', 7);\nconsole.log(COOKIES.get('token')); // a=1\n```\n\n### COPY(source, target)\n\nType: `method`\n\nSkopíruje vlastnosti jedného objektu do druhého.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `source` | `Object` | yes |  | Objekt, z ktorého sa číta. |\n| `target` | `Object` | yes |  | Objekt, do ktorého sa zapisuje. |\n\nReturns: `Object` Objekt `target`.\n\nVnorené objekty sa klonujú, takže neskoršie zmeny v `source` neovplyvnia `target`.\n\nExample: Zlúč dva objekty\n```js\nvar target = { a: 1 };\nCOPY({ b: { c: 2 } }, target);\nconsole.log(target); // {\"a\":1,\"b\":{\"c\":2}}\n```\n\n### CSS(value, [id], [selector])\n\nType: `method`\n\nIný názov pre `STYLE()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | CSS. |\n| `id` | `String` | no |  | Identifikátor elementu so štýlom. |\n| `selector` | `String` | no |  | Selektor, ktorý sa pridá pred každé pravidlo. |\n\nPozri [STYLE()](../globals/). Ak pred skriptom knižnice nastavíš `window.jc_globals = { CSS: false }`, táto globálna premenná zostane nedefinovaná.\n\n### DAYS\n\nType: `property`\n\nAnglické názvy dní v týždni, počnúc nedeľou.\n\nReturns: `Array` Sedem reťazcov.\n\nExample: Prečítaj deň\n```js\nconsole.log(DAYS[1]); // Monday\n```\n\n### DEF\n\nType: `property`\n\nPredvolené nastavenia knižnice.\n\nReturns: `Object` Nastavenia.\n\nOpísané na vlastnej stránke: [DEF](../def/).\n\n### DECRYPT(text, [key], [type])\n\nType: `method`\n\nPrečíta hodnotu zapísanú cez `ENCRYPT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Text z `ENCRYPT()`. |\n| `key` | `String` | no |  | Kľúč. |\n| `type` | `String` | no |  | Prefix textu. |\n\nReturns: `Object` Hodnota alebo `undefined`.\n\n`key` a `type` musia byť tie isté, ktoré si odovzdal [ENCRYPT()](../globals/). Keď im kontrolný súčet nezodpovedá, čo platí aj pre zmenený text, metóda vráti `undefined`. Hodnota, ktorá sa začína znakom `[`, `{` alebo `\"`, sa spracuje ako JSON.\n\nExample: Prečítaj objekt späť\n```js\nvar text = ENCRYPT({ id: 5 }, 'secret', 'U');\n\nconsole.log(text.charAt(0)); // U\nconsole.log(DECRYPT(text, 'secret', 'U')); // {\"id\":5}\nconsole.log(DECRYPT(text, 'secret')); // undefined\n```\n\n### DIFFDOM(element, selector, html, [attribute])\n\nType: `method`\n\nAktualizuje podradené elementy tak, aby zodpovedali novému HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Nadradený element. |\n| `selector` | `String` | yes |  | Selektor porovnávaných podradených elementov. |\n| `html` | `String` | yes |  | Nový obsah. |\n| `attribute` | `String` | no |  | Atribút použitý na porovnanie. |\n\nReturns: `Object` Počet pridaných, ponechaných a odstránených elementov: `{ add, upd, rem }`.\n\nPodradené elementy, ktoré sa nezmenili, zostávajú v DOM, takže si zachovajú svoj stav. Porovnávajú sa podľa celého HTML alebo podľa hodnoty `attribute`, keď je nastavený.\n\nExample: Aktualizuj zoznam\n```html\n<ul id=\"list\"><li>A</li><li>B</li></ul>\n\n<script>\nvar list = $('#list');\nvar result = DIFFDOM(list, 'li', '<li>A</li><li>C</li>');\nconsole.log(result); // {\"add\":1,\"upd\":1,\"rem\":1}\nconsole.log(list.html()); // <li>A</li><li>C</li>\n</script>\n```\n\n### EMIT(name, [a], [b], [c], [d])\n\nType: `method`\n\nVyšle udalosť.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nArgumenty dostanú obslužné funkcie zaregistrované cez [ON()](../globals/) a obslužné funkcie zaregistrované na [komponentoch](../component/) a [pluginoch](../plugin/). Za názvom môžu nasledovať flagy, napríklad `refresh @loading`. Udalosti knižnice uvádza časť [Udalosti](../events/).\n\nExample: Vyšli vlastnú udalosť\n```js\nON('saved', function(id, name) {\n\tconsole.log(id, name); // 5 Peter\n});\n\nEMIT('saved', 5, 'Peter');\n```\n\n### EMPTYARRAY\n\nType: `property`\n\nZmrazené prázdne pole.\n\nReturns: `Array` Pole, ktoré sa nedá zmeniť.\n\nExample: Zdieľaná predvolená hodnota\n```js\nconsole.log(Object.isFrozen(EMPTYARRAY)); // true\n```\n\n### EMPTYOBJECT\n\nType: `property`\n\nZmrazený prázdny objekt.\n\nReturns: `Object` Objekt, ktorý sa nedá zmeniť.\n\nExample: Zdieľaná predvolená hodnota\n```js\nconsole.log(Object.isFrozen(EMPTYOBJECT)); // true\n```\n\n### ENCRYPT(value, [key], [type])\n\nType: `method`\n\nZakóduje hodnotu ako text s kontrolným súčtom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | Hodnota. |\n| `key` | `String` | no |  | Kľúč kontrolného súčtu. |\n| `type` | `String` | no |  | Prefix zapísaný na začiatok textu. |\n\nReturns: `String` Zakódovaný text.\n\nObjekt alebo pole sa najprv serializuje cez [STRINGIFY()](../globals/). Výsledok má ako prefix `type`, za ním nasleduje hodnota v hexadecimálnych číslicach, písmeno `x` a kontrolný súčet vytvorený cez [HASH()](../globals/) z hodnoty, `key` a `type`.\n\nHodnotu si môže prečítať ktokoľvek, preto metódu nepoužívaj na skrývanie dát: kľúč iba umožní [DECRYPT()](../globals/) zistiť, či sa text zmenil.\n\nExample: Zakóduj a dekóduj\n```js\nvar text = ENCRYPT('hello', 'secret');\n\nconsole.log(text); // 68656c6c6fxds46dr\nconsole.log(DECRYPT(text, 'secret')); // hello\nconsole.log(DECRYPT(text, 'other')); // undefined\n```\n\n### ENV(name, [value])\n\nType: `method`\n\nČíta alebo zapisuje premenné prostredia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String|Object` | yes |  | Názov alebo objekt s názvami a hodnotami. |\n| `value` | `Object` | no |  | Hodnota na zápis. |\n\nReturns: `Object` Hodnota premennej.\n\nPremenné sa ukladajú do [DEF.env](../def/). Text sa na ne môže odkazovať ako `[name]`: path, adresy a konfiguračné hodnoty nahradia tento zápis hodnotou. Ak chceš zapísať niekoľko premenných, odovzdaj objekt. Každý zápis vyšle [udalosť](../events/) `env`.\n\nExample: Použi premennú v texte\n```js\nENV('api', '/api/v1/');\nconsole.log(ENV('api')); // /api/v1/\nconsole.log('[api]users/'.env()); // /api/v1/users/\n```\n\n### ENVIRONMENT(name, [version], [language], [env])\n\nType: `method`\n\nNastaví kľúč úložiska, verziu, jazyk a premenné prostredia aplikácie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Kľúč použitý v `localStorage`. |\n| `version` | `String` | no |  | Verzia aplikácie. |\n| `language` | `String` | no |  | Jazyk aplikácie. |\n| `env` | `Object` | no |  | Premenné prostredia. |\n\nMetóda priradí [DEF.localstorage](../def/), [DEF.version](../def/) a [DEF.language](../def/) a `env` odovzdá funkcii [ENV()](../globals/). Zavolaj ju hneď za skriptom knižnice, aby aplikácia čítala svoje vlastné úložisko.\n\nExample: Nakonfiguruj aplikáciu\n```js\nENVIRONMENT('myapp', '1.0', 'en', { title: 'My app' });\n\nconsole.log(DEF.localstorage, DEF.version, DEF.language); // myapp 1.0 en\nconsole.log(ENV('title')); // My app\n```\n\n### ERROR(response, [success], [error])\n\nType: `method`\n\nSkontroluje odpoveď na chyby a spustí príslušnú obslužnú funkciu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object` | yes |  | Odpoveď na kontrolu. |\n| `success` | `Function|String` | no |  | Spustí sa, keď nenastala chyba. |\n| `error` | `Function|String` | no |  | Spustí sa, keď nastala chyba. |\n\nReturns: `Boolean` `true`, keď odpoveď obsahuje chybu.\n\nOdpoveď je chybou, keď je objektom `Error`, má vlastnosť `error` alebo je poľom, ktorého prvá položka túto vlastnosť má. Chyba vyšle [udalosť](../events/) `ERROR`.\n\n`success` a `error` môžu byť funkcie alebo názvy pre [SEEX()](../globals/).\n\nZavolaj `ERROR(success, [error])` bez odpovede a vytvoríš funkciu, ktorú môžeš odovzdať ako callback.\n\nExample: Skontroluj odpoveď\n```js\nconsole.log(ERROR({ id: 1 })); // false\nconsole.log(ERROR([{ error: 'Invalid name' }])); // true\n```\n\nExample: Vytvor callback\n```js\nvar callback = ERROR(function(response) {\n\tconsole.log(response.id); // 1\n});\n\ncallback({ id: 1 });\n```\n\n### ERRORS(path, callback)\n\nType: `method`\n\nVráti neplatné komponenty path alebo elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String|jQuery` | yes |  | Path alebo element, ktorý obsahuje komponenty. |\n| `callback` | `Function` | yes |  | Funkcia, ktorá dostane pole [komponentov](../component/). |\n\nExample: Zvaliduj formulár\n```html\n<ui-component name=\"field\" path=\"form.name\" config=\"required:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {\n\tself.validate = function(value) {\n\t\treturn !!value;\n\t};\n});\n\nON('ready', function() {\n\tERRORS('form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá funkciu podľa jej názvu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Cieľ volania. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nTvar `name` určuje, čo sa zavolá:\n\n| Názov | Zavolá |\n| --- | --- |\n| `name` | Globálnu funkciu. |\n| `FUNC.name` | Funkciu nájdenú na path. |\n| `plugin/method` | Metódu [pluginu](../plugin/). |\n| `*/method` | Metódu pluginu common. |\n| `-component/method` | Metódu komponentu cez [SETTER()](../globals/). |\n| `#event` | Udalosť cez [EMIT()](../globals/). |\n\nPridaj flag `@important`, aby sa volanie opakovalo každých 500 milisekúnd, kým funkcia nebude existovať, napríklad `EXEC('app/refresh @important')`. `EXE()` je tá istá funkcia pod iným názvom.\n\nExample: Zavolaj funkciu podľa path\n```js\nFUNC.sum = function(a, b) {\n\tconsole.log(a + b); // 5\n};\n\nEXEC('FUNC.sum', 2, 3);\n```\n\nExample: Počkaj na funkciu\n```js\nEXEC('app.start @important', 'now');\n\nsetTimeout(function() {\n\twindow.app = {};\n\tapp.start = function(value) {\n\t\tconsole.log(value); // now\n\t};\n}, 100);\n```\n\n### EXTENSION(name, [config], callback)\n\nType: `method`\n\nRozšíri komponent alebo plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov komponentu alebo `@`, za ktorým nasleduje názov pluginu. |\n| `config` | `String|Object` | no |  | Konfigurácia pridaná každej inštancii. |\n| `callback` | `Function` | yes |  | Funkcia `(instance, config, cls)`, kde `cls` je CSS trieda inštancie. `this` je inštancia. |\n\n`callback` sa spustí pre každú existujúcu inštanciu a pre každú novú hneď po deklarácii, vždy s rovnakými argumentmi. Pri plugine napíš pred jeho názov `@`.\n\nExample: Pridaj komponentu metódu\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nEXTENSION('box', 'color:red', function(self, config) {\n\tself.describe = function() {\n\t\treturn config.color;\n\t};\n});\n\nON('ready', function() {\n\tconsole.log(FIND('box').describe()); // red\n});\n</script>\n```\n\n### FIND(selector, [all])\n\nType: `method`\n\nNájde pripravený komponent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Názov, identifikátor alebo path. |\n| `all` | `Boolean` | no | `false` | Vráti všetky zhody v poli. |\n\nReturns: `Component|Array` Prvý [komponent](../component/) alebo pole, keď je `all` nastavené na `true`.\n\n`selector` je názov komponentu, `#id` pre identifikátor alebo `.path` pre path.\n\nExample: Nájdi podľa názvu a podľa path\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('field').name); // field\n\tconsole.log(FIND('.form.name').path.path); // form.name\n\tconsole.log(FIND('field', true).length); // 1\n});\n</script>\n```\n\n### FLAGS(flags, [callback])\n\nType: `method`\n\nVyšle flagy a potom spustí funkciu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Flagy, napríklad `@loading @save`. |\n| `callback` | `Function` | no |  | Funkcia, ktorá sa spustí potom. |\n\nKaždý flag vyšle udalosť `@flag name`, ktorú môžeš zachytiť cez [ON()](../globals/). Pozri [Flagy a modifikátory path](../../guides/flags/).\n\nExample: Zachyť flag\n```js\nON('@flag loading', function() {\n\tconsole.log('flag captured'); // flag captured\n});\n\nFLAGS('@loading', function() {\n\tconsole.log('done'); // done\n});\n```\n\n### FN(code)\n\nType: `method`\n\nSkompiluje arrow funkciu z reťazca.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `String` | yes |  | Kód funkcie. |\n\nReturns: `Function` Skompilovaná funkcia.\n\nKód môže mať až štyri argumenty. Kód bez šípky sa stane funkciou s argumentom `value`. Skompilované funkcie sa ukladajú do cache.\n\nExample: Skompiluj funkcie\n```js\nconsole.log(FN('n => n * 2')(4)); // 8\nconsole.log(FN('(a, b) => a + b')(1, 2)); // 3\nconsole.log(FN('value + 1')(1)); // 2\n```\n\n### FREE()\n\nType: `method`\n\nOdstráni komponenty, väzby a pluginy, ktorých elementy opustili DOM.\n\nKnižnica toto upratovanie spúšťa každú minútu. Zavolaj ho, keď potrebuješ inštancie odstrániť hneď.\n\nExample: Odstráň odpojený komponent\n```html\n<ui-component name=\"box\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\t$('ui-component').remove();\n\tFREE();\n\tconsole.log(COMPONENTS('form').length); // 0\n});\n</script>\n```\n\n### FUNC\n\nType: `property`\n\nPrázdny objekt pre funkcie tvojej aplikácie.\n\nReturns: `Object` Kontajner.\n\nFunkcie uložené tu môžeš volať podľa path cez [EXEC()](../globals/).\n\nExample: Ulož funkciu\n```js\nFUNC.hello = function() {\n\treturn 'Hello';\n};\n\nconsole.log(FUNC.hello()); // Hello\n```\n\n### GET(path, [noflags])\n\nType: `method`\n\nPrečíta hodnotu path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s flagmi. |\n| `noflags` | `Boolean` | no | `false` | Prečíta hodnotu bez použitia flagov. |\n\nReturns: `Object` Hodnota.\n\nKeď path obsahuje flagy, použijú sa na komponenty danej path: `GET('form @reset')` vráti hodnotu a vynuluje ich stav. Pozri [Paths](../../guides/paths/).\n\nExample: Prečítaj hodnoty\n```js\nSET('user.name', 'Peter');\n\nconsole.log(GET('user.name')); // Peter\nconsole.log(GET('user')); // {\"name\":\"Peter\"}\n```\n\n### GUID([length])\n\nType: `method`\n\nVygeneruje náhodný identifikátor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | no |  | Dĺžka identifikátora. |\n\nReturns: `String` Identifikátor.\n\nBez `length` má výsledok 36-znakový tvar UUID. S `length` je to reťazec malých písmen a číslic.\n\nExample: Vygeneruj identifikátory\n```js\nconsole.log(GUID().length); // 36\nconsole.log(GUID(10).length); // 10\n```\n\n### HASH(value)\n\nType: `method`\n\nVytvorí číselný hash hodnoty.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Number|Boolean|Object|Date` | yes |  | Hodnota. |\n\nReturns: `Number` Hash.\n\nČíslo sa vráti tak, ako je, `true` dá `1`, dátum dá svoj čas v milisekundách a prázdna hodnota dá `0`. Objekty sa najprv serializujú.\n\nExample: Vytvor hash reťazca\n```js\nconsole.log(HASH('hello')); // 99162322\n```\n\n### HIDDEN(element)\n\nType: `method`\n\nSkontroluje, či je element vnorený v stránke skrytý.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Element umiestnený v inom elemente vo vnútri body. |\n\nReturns: `Boolean` `true`, keď je element skrytý.\n\nElement sa považuje za skrytý, keď nemá offset parent, čo platí pre `display:none`. Za skrytý sa považuje aj chýbajúci element. Polohu vo viewporte skontroluješ cez [VISIBLE()](../globals/).\n\nExample: Skontroluj element\n```html\n<main><div id=\"a\" style=\"display:none\"></div><div id=\"b\"></div></main>\n\n<script>\nconsole.log(HIDDEN($('#a'))); // true\nconsole.log(HIDDEN($('#b'))); // false\n</script>\n```\n\n### IMPORT(url, [target], [callback], [prepare])\n\nType: `method`\n\nNačíta skript, štýl alebo kúsok HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Adresa a voliteľné kľúčové slová. |\n| `target` | `String|jQuery|Element` | no | `body` | Element, ktorý dostane HTML obsah. |\n| `callback` | `Function` | no |  | Funkcia, ktorá sa spustí po načítaní obsahu. |\n| `prepare` | `Function` | no |  | Funkcia, ktorá dostane HTML a vráti text na vloženie. |\n\nAdresy končiace na `.js` alebo `.css` sa pridajú do hlavičky stránky. Každá iná adresa sa stiahne a vloží do `target`. Adresu môžeš kombinovať s kľúčovými slovami:\n\n| Kľúčové slovo | Význam |\n| --- | --- |\n| `<name>` | Preskočí import, keď existuje globálna premenná `name`. |\n| `.js`, `.css`, `.html` | Nastaví typ obsahu, keď ho adresa neukazuje. |\n| `@singleton` | Importuje adresu iba raz. |\n| `@prepend` | Vloží obsah na začiatok `target`. |\n\nKeď sa skript alebo štýl nepodarí načítať, knižnica zapíše do konzoly varovanie a `callback` sa aj tak spustí.\n\nPozri [Import obsahu](../../guides/importing/).\n\nExample: Vlož kúsok HTML\n```html\n<div id=\"menu\"></div>\n\n<script>\nIMPORT('/parts/menu.html', '#menu', function() {\n\tconsole.log($('#menu').html()); // <b>Menu</b>\n});\n</script>\n```\n\nExample: Preskoč knižnicu, ktorá už existuje\n```js\nIMPORT('<jQuery> /js/jquery.min.js', function() {\n\tconsole.log('jQuery is available'); // jQuery is available\n});\n```\n\n### INC(path, [value])\n\nType: `method`\n\nZvýši číslo uložené na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `value` | `Number` | no | `1` | Hodnota, ktorá sa pripočíta. |\n\nPrázdna path začína od `0`. Reťazec sa prevedie na číslo. Ak chceš číslo znížiť, použi zápornú hodnotu `value`.\n\nExample: Zvýš počítadlo\n```js\nSET('stats.visits', 10);\nINC('stats.visits');\nINC('stats.visits', 5);\nconsole.log(GET('stats.visits')); // 16\n```\n\n### inDOM(element)\n\nType: `method`\n\nSkontroluje, či je element pripojený k telu dokumentu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `Element` | yes |  | DOM element. |\n\nReturns: `Boolean` `true`, keď je element pripojený, inak nič.\n\nExample: Skontroluj element\n```js\nconsole.log(inDOM(document.body)); // true\nconsole.log(!!inDOM(document.createElement('div'))); // false\n```\n\n### isIE\n\nType: `property`\n\nUrčuje, či je prehliadačom Internet Explorer.\n\nReturns: `Boolean` Výsledok detekcie.\n\n### isMOBILE\n\nType: `property`\n\nUrčuje, či user agent patrí mobilnému zariadeniu.\n\nReturns: `Boolean` Výsledok detekcie.\n\n### isPRIVATEMODE\n\nType: `property`\n\nUrčuje, či je `localStorage` nedostupný, ako v niektorých súkromných oknách. Hodnota sa nastavuje počas štartu knižnice, preto ju čítaj až od udalosti `ready`.\n\nReturns: `Boolean` Výsledok detekcie.\n\n### isROBOT\n\nType: `property`\n\nUrčuje, či user agent patrí vyhľadávaču alebo crawleru.\n\nReturns: `Boolean` Výsledok detekcie.\n\n### isSTANDALONE\n\nType: `property`\n\nUrčuje, či stránka beží ako nainštalovaná webová aplikácia.\n\nReturns: `Boolean` Výsledok detekcie.\n\n### isTOUCH\n\nType: `property`\n\nUrčuje, či zariadenie podporuje dotykové ovládanie.\n\nReturns: `Boolean` Výsledok detekcie.\n\n### jComponent\n\nType: `property`\n\nHlavný objekt knižnice.\n\nReturns: `Object` Hlavný objekt.\n\nTen istý objekt ako [MAIN](../main/).\n\n### LOCALIZE(text)\n\nType: `method`\n\nNačíta preklady do slovníka.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Riadky s prekladmi. |\n\nKaždý riadok má tvar `key : translation` a riadky začínajúce na `//` sa preskočia. Kľúčom je hash pôvodného textu v základe 36 s prefixom `T`. Preklady sa ukladajú do [DEF.dictionary](../def/) a používa ich [TRANSLATE()](../globals/). Pozri [Lokalizácia](../../guides/localization/).\n\nExample: Načítaj preklad\n```js\nvar key = 'T' + HASH('Hello').toString(36);\n\nLOCALIZE(key + ' : Hola');\nconsole.log(TRANSLATE('@(Hello)')); // Hola\n```\n\n### M\n\nType: `property`\n\nKrátky názov hlavného objektu.\n\nReturns: `Object` Hlavný objekt.\n\nTen istý objekt ako [MAIN](../main/).\n\n### MAIN\n\nType: `property`\n\nHlavný objekt knižnice.\n\nReturns: `Object` Hlavný objekt.\n\nOpísané na vlastnej stránke: [MAIN](../main/).\n\n### MONTHS\n\nType: `property`\n\nAnglické názvy mesiacov, počnúc januárom.\n\nReturns: `Array` Dvanásť reťazcov.\n\nExample: Prečítaj mesiac\n```js\nconsole.log(MONTHS[0]); // January\n```\n\n### NEWUIBIND(element, [path], [config])\n\nType: `method`\n\nZ kódu vytvorí dátovú väzbu na elemente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Element. |\n| `path` | `String` | no |  | Path, ktorá sa má sledovať. |\n| `config` | `String` | no |  | Príkazy väzby. |\n\nVäzba funguje ako element [ui-bind](../ui-bind/). Bez `path` a `config` sa hodnoty čítajú z atribútov elementu.\n\nExample: Naviaž element na path\n```html\n<div id=\"name\"></div>\n\n<script>\nSET('user.name', 'Peter');\nNEWUIBIND($('#name'), 'user.name', 'text:value');\n\nsetTimeout(function() {\n\tconsole.log($('#name').html()); // Peter\n}, 200);\n</script>\n```\n\n### NODEINDEXOF(element)\n\nType: `method`\n\nVráti pozíciu elementu medzi jeho súrodencami.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Element. |\n\nReturns: `Number` Pozícia počítaná od nuly.\n\nExample: Prečítaj pozíciu\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li></ul>\n\n<script>\nconsole.log(NODEINDEXOF($('#b'))); // 1\n</script>\n```\n\n### NODEINSERT(element, reference, [before])\n\nType: `method`\n\nVloží element vedľa iného elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Element na vloženie. |\n| `reference` | `jQuery|Element` | yes |  | Referenčný element. |\n| `before` | `Boolean` | no | `false` | Vloží element pred referenčný element. |\n\nExample: Presuň element\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEINSERT($('#c'), $('#a'), true);\nconsole.log($('ul').text()); // CAB\n</script>\n```\n\n### NODEMOVE(element, [up])\n\nType: `method`\n\nPosunie element o jednu pozíciu medzi jeho súrodencami.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Element. |\n| `up` | `Boolean` | no | `false` | Posunie element smerom k začiatku. Inak ho posunie smerom ku koncu. |\n\nExample: Zmeň poradie v zozname\n```html\n<ul><li id=\"a\">A</li><li id=\"b\">B</li><li id=\"c\">C</li></ul>\n\n<script>\nNODEMOVE($('#b'), true);\nconsole.log($('ul').text()); // BAC\n</script>\n```\n\n### NOOP()\n\nType: `method`\n\nFunkcia, ktorá nič nerobí.\n\nPouži ju ako predvolený callback.\n\nExample: Predvolený callback\n```js\nvar callback = NOOP;\nconsole.log(typeof(callback)); // function\n```\n\n### NOTFOCUSED()\n\nType: `method`\n\nSkontroluje, či je stránka na pozadí.\n\nReturns: `Boolean` `true`, keď je dokument skrytý.\n\nExample: Skontroluj stránku\n```js\nconsole.log(NOTFOCUSED()); // false\n```\n\n### NOW\n\nType: `property`\n\nAktuálny dátum obnovovaný raz za minútu.\n\nReturns: `Date` Dátum.\n\nPouži ho, keď ti stačí presnosť na minútu. Vyhneš sa tak vytváraniu nového objektu `Date` pri každom použití.\n\nExample: Prečítaj dátum\n```js\nconsole.log(NOW instanceof Date); // true\n```\n\n### NUL(path)\n\nType: `method`\n\nNastaví path na `null`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\n`NULL()` je tá istá funkcia pod iným názvom.\n\nExample: Vymaž hodnotu\n```js\nSET('user.name', 'Peter');\nNUL('user.name');\nconsole.log(GET('user.name')); // null\n```\n\n### OFF(name, [callback])\n\nType: `method`\n\nOdstráni obslužné funkcie udalostí.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | no |  | Obslužná funkcia na odstránenie. |\n\nBez `callback` sa odstránia všetky obslužné funkcie udalosti. Niekoľko udalostí môžeš spojiť znakom `+`.\n\nExample: Odstráň obslužnú funkciu\n```js\nvar count = 0;\nvar handler = function() {\n\tcount++;\n};\n\nON('refresh', handler);\nEMIT('refresh');\nOFF('refresh', handler);\nEMIT('refresh');\nconsole.log(count); // 1\n```\n\n### ON(name, callback, [init])\n\nType: `method`\n\nZaregistruje obslužnú funkciu udalosti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | yes |  | Obslužná funkcia. Dostane argumenty udalosti. |\n| `init` | `Boolean` | no | `false` | Zavolá obslužnú funkciu aj raz bez argumentov. |\n\nNiekoľko udalostí môžeš spojiť znakom `+`, napríklad `saved + removed`. Obslužná funkcia pre `ready` alebo `init` sa spustí okamžite, keď už knižnica naštartovala. Udalosti knižnice uvádza časť [Udalosti](../events/).\n\nExample: Zachyť dve udalosti\n```js\nvar count = 0;\n\nON('saved + removed', function() {\n\tcount++;\n});\n\nEMIT('saved');\nEMIT('removed');\nconsole.log(count); // 2\n```\n\n### PARSE(value)\n\nType: `method`\n\nSpracuje JSON a reťazce s dátumami prevedie na objekty `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Object` | yes |  | JSON, selektor alebo objekt. |\n\nReturns: `Object` Spracovaná hodnota alebo `null`.\n\nHodnota začínajúca na `#` alebo `.` je selektor: JSON sa prečíta z obsahu daného elementu. Objekt sa vráti tak, ako je. Neplatný JSON vráti `null`.\n\nExample: Spracuj JSON\n```js\nvar data = PARSE('{\"created\":\"2024-05-01T10:00:00.000Z\"}');\nconsole.log(data.created instanceof Date); // true\nconsole.log(PARSE('invalid')); // null\n```\n\n### PIPE(name, [data], callback, [scope])\n\nType: `method`\n\nZavolá operáciu na adrese z `DEF.pipe`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov operácie, voliteľne s kľúčovými slovami. |\n| `data` | `Object` | no |  | Dáta operácie. |\n| `callback` | `Function|String` | yes |  | Funkcia alebo path, ktorá dostane odpoveď. |\n| `scope` | `Object` | no | `window` | Objekt, v ktorom sa vyhodnotí path v `callback`. |\n\nFunguje ako [API()](../globals/), pričom adresa sa berie z [DEF.pipe](../def/).\n\nExample: Zavolaj operáciu\n```js\nDEF.pipe = '/pipe/';\n\nPIPE('orders_list', function(response) {\n\tconsole.log(response.length); // 1\n});\n```\n\n### PLUGIN(name, [config], callback, [dependencies])\n\nType: `method`\n\nZaregistruje deklaráciu pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov pluginu. |\n| `config` | `String` | no |  | Predvolená konfigurácia v tvare `key:value;key:value`. |\n| `callback` | `Function` | yes |  | Deklarácia: `function(self, config)`. |\n| `dependencies` | `String|Array` | no |  | Adresy, ktoré sa majú najprv importovať. |\n\n`callback` sa spustí, keď sa vytvorí element [ui-plugin](../ui-plugin/) s touto path. Názov `*` zaregistruje plugin common. Pozri [Pluginy](../../guides/plugins/) a objekt [Plugin](../plugin/).\n\nExample: Deklaruj plugin\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.hello = function(name) {\n\t\tconsole.log('Hello ' + name); // Hello Peter\n\t};\n});\n\nON('ready', function() {\n\tEXEC('users/hello', 'Peter');\n});\n</script>\n```\n\n### PLUGINS\n\nType: `property`\n\nBežiace inštancie pluginov podľa názvu.\n\nReturns: `Object` Inštancie [pluginov](../plugin/).\n\nExample: Prečítaj plugin\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('ready', function() {\n\tconsole.log(Object.keys(PLUGINS)); // [\"users\"]\n});\n</script>\n```\n\n### PREF\n\nType: `property`\n\nTrvalé používateľské preferencie.\n\nReturns: `Object` Preferencie.\n\nOpísané na vlastnej stránke: [PREF](../pref/).\n\n### PUSH(path, value)\n\nType: `method`\n\nPridá položku do poľa uloženého na path a upozorní path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path existujúceho poľa. |\n| `value` | `Object` | yes |  | Položka. |\n\nAk chceš položku pridať na začiatok poľa, napíš pred path `^`.\n\nExample: Pridaj položky\n```js\nSET('tags', ['b']);\nPUSH('tags', 'c');\nPUSH('^tags', 'a');\nconsole.log(GET('tags')); // [\"a\",\"b\",\"c\"]\n```\n\n### QUERIFY([url], data)\n\nType: `method`\n\nPridá dáta k adrese ako reťazec dotazu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | Adresa. |\n| `data` | `Object` | yes |  | Hodnoty. |\n\nReturns: `String` Adresa s reťazcom dotazu.\n\nPrázdne hodnoty sa preskočia, dátumy sa prevedú na reťazce ISO a polia sa spoja čiarkami. `url` môže začínať metódou HTTP.\n\nExample: Zostav adresy\n```js\nconsole.log(QUERIFY('/users/', { page: 2, q: 'a b' })); // /users/?page=2&q=a%20b\nconsole.log(QUERIFY('GET /users/', { page: 2 })); // GET /users/?page=2\nconsole.log(QUERIFY({ page: 2 })); // ?page=2\n```\n\n### REPO\n\nType: `property`\n\nPrázdny objekt pre zdieľané dáta tvojej aplikácie.\n\nReturns: `Object` Kontajner.\n\nExample: Ulož hodnotu\n```js\nREPO.title = 'My app';\nconsole.log(REPO.title); // My app\n```\n\n### RESET(path)\n\nType: `method`\n\nVynuluje stav komponentov naviazaných na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nStavy `touched` a `modified` sa vrátia na predvolené hodnoty. Hodnota path sa nezmení.\n\nExample: Vynuluj formulár\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tSET('form.name @change', 'Peter');\n\tconsole.log(FIND('field').config.modified); // 1\n\tRESET('form');\n\tconsole.log(FIND('field').config.modified); // 0\n\tconsole.log(GET('form.name')); // Peter\n});\n</script>\n```\n\n### SCROLLBAR(element, [options])\n\nType: `method`\n\nPridá elementu vlastný posuvník.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Element. |\n| `options` | `Object` | no |  | Možnosti. |\n\nReturns: `Object` Posuvník.\n\nMožnosti:\n\n| Možnosť | Typ | Popis |\n| --- | --- | --- |\n| `native` | Boolean | Ponechá posuvník prehliadača a nastaví iba pretečenie. |\n| `orientation` | String | `x` alebo `y`. Predvolene sú aktívne oba smery. |\n| `visibleX`, `visibleY` | Boolean | Ponechá dráhu viditeľnú, aj keď nie je čo posúvať. |\n| `wrap` | Boolean | `false` použije existujúci obsah ako posúvanú oblasť. |\n| `controls` | jQuery | Element, ktorý dostane dráhy posuvníka. |\n| `shadow` | Boolean | Pridá tiene na posúvateľné okraje. |\n| `padding` | Number | Vzdialenosť dráh od okraja. Predvolená hodnota: `5`. |\n| `minsize` | Number | Minimálna veľkosť jazdca. Predvolená hodnota: `50`. |\n| `thickness` | Number | Hrúbka použitá vtedy, keď ju CSS neurčuje. Predvolená hodnota: `10`. |\n| `margin`, `marginX`, `marginY` | Number | Upravujú veľkosť posúvanej oblasti. |\n| `offsetX`, `offsetY` | Number | Upravujú nameranú veľkosť elementu. |\n| `floating` | Boolean | `false` vyhradí miesto pre jazdce. |\n| `parent` | String\\|jQuery | Element, ktorého veľkosť sa použije. |\n| `interval` | Number | Čas medzi kontrolami veľkosti v milisekundách. Predvolená hodnota: `54321`. |\n| `autoresize` | Boolean | `false` zastaví opätovné meranie elementu pri zmene veľkosti okna. Predvolená hodnota: `true`. |\n| `onscroll`, `onidle`, `onresize` | Function | Obslužné funkcie, ktoré dostanú posuvník. |\n\nVrátený objekt poskytuje:\n\n| Člen | Popis |\n| --- | --- |\n| `area` | Posúvaný element. |\n| `body` | Element s obsahom. |\n| `element` | Pôvodný element. |\n| `resize()` | Znova odmeria element. |\n| `scrollTop([value])` | Prečíta alebo nastaví zvislú polohu. Reťazec ako `'+20'` posúva relatívne k aktuálnej polohe. |\n| `scrollLeft([value])` | Prečíta alebo nastaví vodorovnú polohu podľa rovnakých pravidiel. |\n| `scrollBottom(offset)` | Posunie na spodok, mínus `offset`. |\n| `scrollRight(offset)` | Posunie k pravému okraju, mínus `offset`. |\n| `scroll(x, y)` | Posunie na zadanú polohu. |\n| `sync(element, [direction])` | Zosynchronizuje posúvanie s iným elementom. `direction` je `x` alebo `y`. |\n| `destroy()` | Zastaví posuvník. |\n\nPosúvanie oznamujú [udalosti](../events/) `scroll` a `scrollidle`.\n\nExample: Posúvaj z kódu\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nvar scrollbar = SCROLLBAR($('#panel'));\n\nscrollbar.area.css('overflow', 'auto');\nscrollbar.resize(false, true);\nscrollbar.scrollTop(30);\nconsole.log(scrollbar.scrollTop()); // 30\nscrollbar.scrollTop('+20');\nconsole.log(scrollbar.scrollTop()); // 50\n</script>\n```\n\n### SCROLLBARWIDTH()\n\nType: `method`\n\nVráti šírku posuvníka prehliadača.\n\nReturns: `Number` Šírka v pixeloch.\n\nExample: Prečítaj šírku\n```js\nconsole.log(typeof(SCROLLBARWIDTH())); // number\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nPodľa názvu zavolá funkciu alebo zapíše hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Cieľ. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nTvar `plugin/method` zavolá metódu pluginu a názov globálnej funkcie zavolá túto funkciu. Každý iný názov je path a `a` sa na ňu zapíše cez [SET()](../globals/).\n\nExample: Zapíš na path\n```js\nSEEX('form.name', 'Peter');\nconsole.log(GET('form.name')); // Peter\n```\n\nExample: Zavolaj globálnu funkciu\n```js\nwindow.notify = function(text) {\n\tconsole.log(text); // Saved\n};\n\nSEEX('notify', 'Saved');\n```\n\n### SET(path, value)\n\nType: `method`\n\nZapíše hodnotu na path a upozorní všetko, čo ju sleduje.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s flagmi. |\n| `value` | `Object` | yes |  | Hodnota alebo funkcia `(current)`, ktorá ju vráti. |\n\nChýbajúce objekty pozdĺž path sa vytvoria. Flagy sú súčasťou path, napríklad `form.name @change`. Tvar `path[]` pridá hodnotu na koniec poľa. Funkcia ako `value` dostane aktuálnu hodnotu a zapíše sa jej výsledok. Pozri [Paths](../../guides/paths/) a [Flagy a modifikátory path](../../guides/flags/).\n\nExample: Zapíš hodnoty\n```js\nSET('user.name', 'Peter');\nSET('user.tags[]', 'admin');\nconsole.log(GET('user')); // {\"name\":\"Peter\",\"tags\":[\"admin\"]}\n```\n\nExample: Zapíš hodnotu z aktuálnej\n```js\nSET('cart.count', 1);\nSET('cart.count', value => value + 1);\nconsole.log(GET('cart.count')); // 2\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá metódu na komponentoch, ktoré zodpovedajú selektoru.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Selektor a metóda. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\n`name` má tvar `selector/method`:\n\n| Selektor | Zodpovedá |\n| --- | --- |\n| `name` | Komponentom s týmto názvom. |\n| `#id` | Komponentu s týmto identifikátorom. |\n| `*` | Všetkým komponentom, ktoré danú metódu majú. |\n\nFlag `@important` opakuje volanie každých 500 milisekúnd, kým nebude existovať zodpovedajúci komponent s danou metódou. Komponent deklarovaný ako lenivý sa vytvorí pri prvom volaní, pokiaľ názov nezačína na `!`.\n\nExample: Zavolaj metódu komponentu\n```html\n<ui-component name=\"counter\"></ui-component>\n\n<script>\nCOMPONENT('counter', function(self) {\n\tself.add = function(value) {\n\t\tconsole.log(value); // 5\n\t};\n});\n\nON('ready', function() {\n\tSETTER('counter/add', 5);\n});\n</script>\n```\n\n### setTimeout2(name, callback, timeout, [limit], [param])\n\nType: `method`\n\nSpustí funkciu s oneskorením, ktoré sa pri každom volaní s rovnakým názvom začne počítať odznova.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov časovača. |\n| `callback` | `Function` | yes |  | Funkcia. |\n| `timeout` | `Number` | yes |  | Oneskorenie v milisekundách. |\n| `limit` | `Number` | no |  | Maximálny počet volaní v jednom období čakania. |\n| `param` | `Object` | no |  | Argument funkcie. |\n\nReturns: `String` Názov časovača. Volanie ignorované kvôli `limit` nevráti nič.\n\nS `limit` sa oneskorenie reštartuje najviac `limit`-krát. Ďalšie volania sa ignorujú, kým sa funkcia nespustí, takže sa nedá odkladať donekonečna.\n\nExample: Spusti raz po poslednom volaní\n```js\nvar count = 0;\nvar run = function() {\n\tcount++;\n\tconsole.log(count); // 1\n};\n\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\nsetTimeout2('search', run, 50);\n```\n\n### STRINGIFY(value, [compress], [fields], [encrypt])\n\nType: `method`\n\nSerializuje hodnotu do JSON.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota. |\n| `compress` | `Boolean` | no | `false` | Odstráni prázdne hodnoty. |\n| `fields` | `Array|Object|Function` | no |  | Kľúče, ktoré sa majú ponechať. |\n| `encrypt` | `Boolean|String` | no |  | `true` zakóduje JSON cez [ENCRYPT()](../globals/). Reťazec urobí to isté a zároveň je kľúčom. |\n\nReturns: `String` JSON.\n\nKeď je `compress` nastavené na `true`, reťazce sa orežú a prázdne reťazce, `false` a `null` sa vynechajú. Argument `fields` vyberá kľúče: pole povolených kľúčov, objekt, v ktorom `false` kľúč vylúči, alebo funkcia `(key, value)`, ktorá vráti `true` pre kľúče, ktoré sa majú ponechať.\n\nExample: Skomprimuj a vyfiltruj\n```js\nvar data = { name: ' Peter ', note: '', age: 30 };\n\nconsole.log(STRINGIFY(data, true)); // {\"name\":\"Peter\",\"age\":30}\nconsole.log(STRINGIFY(data, false, ['age'])); // {\"age\":30}\n```\n\nExample: Zakóduj JSON\n```js\nvar text = STRINGIFY({ id: 5 }, false, null, 'secret');\nconsole.log(DECRYPT(text, 'secret')); // {\"id\":5}\n```\n\n### STYLE(value, [id], [selector])\n\nType: `method`\n\nPridá na stránku CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String|Array` | yes |  | CSS. |\n| `id` | `String` | no |  | Identifikátor elementu so štýlom. |\n| `selector` | `String` | no |  | Selektor, ktorý sa pridá pred každé pravidlo. |\n\nElement s rovnakým `id` sa nahradí. Element má identifikátor `css`, za ktorým nasleduje `id`. So `selector` sa tento selektor pridá pred každé pravidlo.\n\nExample: Pridaj štýly s obmedzeným scope\n```js\nSTYLE('b { color: red }', 'theme', '.panel');\nconsole.log($('#csstheme').html()); // .panel b{ color: red }\n```\n\n### TAPI(name, [data], callback, [scope])\n\nType: `method`\n\nZavolá operáciu Total.js API na adrese z `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov operácie, voliteľne s kľúčovými slovami. |\n| `data` | `Object` | no |  | Dáta operácie. |\n| `callback` | `Function|String` | yes |  | Funkcia alebo path, ktorá dostane odpoveď. |\n| `scope` | `Object` | no | `window` | Objekt, v ktorom sa vyhodnotí path v `callback`. |\n\nFunguje ako [API()](../globals/), pričom adresa sa berie z [DEF.api](../def/).\n\nExample: Ulož odpoveď na path\n```js\nDEF.api = '/admin/api/';\n\nTAPI('users_list', { page: 1 }, 'users.items');\n\nWATCH('users.items', function(value) {\n\tconsole.log(value.length); // 2\n});\n```\n\n### TEMP\n\nType: `property`\n\nObjekt pre krátkodobé dáta.\n\nReturns: `Object` Kontajner.\n\nKnižnica ho každú minútu nahradí prázdnym objektom.\n\nExample: Ulož hodnotu\n```js\nTEMP.result = 5;\nconsole.log(TEMP.result); // 5\n```\n\n### TOGGLE(path)\n\nType: `method`\n\nInvertuje logickú hodnotu path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nExample: Prepni hodnotu\n```js\nSET('menu.open', false);\nTOGGLE('menu.open');\nconsole.log(GET('menu.open')); // true\n```\n\n### Total\n\nType: `property`\n\nHlavný objekt knižnice.\n\nReturns: `Object` Hlavný objekt.\n\nTen istý objekt ako [MAIN](../main/).\n\n### TRANSLATE(text)\n\nType: `method`\n\nNahradí značky `@(text)` prekladmi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | yes |  | Text so značkami. |\n\nReturns: `String` Preložený text.\n\nText bez prekladu zostáva v pôvodnom jazyku. Preklady sa načítavajú cez [LOCALIZE()](../globals/).\n\nExample: Prelož text\n```js\nLOCALIZE('T' + HASH('Yes').toString(36) + ' : Ano');\nconsole.log(TRANSLATE('@(Yes) / @(No)')); // Ano / No\n```\n\n### UNAUTHORIZED(...permissions)\n\nType: `method`\n\nSkontroluje oprávnenia prihláseného používateľa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `permissions` | `String` | yes |  | Jedno alebo viac oprávnení. |\n\nReturns: `Boolean` `true`, keď je prístup odmietnutý.\n\nMetóda číta globálnu premennú `user`. Používateľ s nastaveným `sa` alebo `su` má všetky oprávnenia. Inak oprávnenia pochádzajú z `user.permissions` alebo `user.roles` ako pole alebo objekt. Výsledok je `true`, keď používateľ nemá žiadne zo zadaných oprávnení alebo keď `user` neexistuje.\n\nExample: Skontroluj oprávnenie\n```js\nwindow.user = { roles: ['editor'] };\n\nconsole.log(UNAUTHORIZED('editor')); // false\nconsole.log(UNAUTHORIZED('admin')); // true\n```\n\n### UNWATCH(path, [callback])\n\nType: `method`\n\nOdstráni sledovače z path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. Niekoľko path môžeš spojiť znakom `+`. |\n| `callback` | `Function` | no |  | Sledovač na odstránenie. |\n\nBez `callback` sa odstránia všetky sledovače danej path.\n\nExample: Zastav sledovanie\n```js\nvar count = 0;\nvar watcher = function() {\n\tcount++;\n};\n\nWATCH('form.name', watcher);\nSET('form.name', 'A');\nUNWATCH('form.name', watcher);\nSET('form.name', 'B');\nconsole.log(count); // 1\n```\n\n### UPD(path)\n\nType: `method`\n\nUpozorní path po priamej zmene jej hodnoty.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s flagmi. |\n\n`UPDATE()` je tá istá funkcia pod iným názvom.\n\nExample: Upozorni po priamej zmene\n```js\nwindow.form = { name: 'A' };\n\nWATCH('form.name', function(value) {\n\tconsole.log(value); // B\n});\n\nform.name = 'B';\nUPD('form.name');\n```\n\n### VISIBLE(element, [threshold], [mode])\n\nType: `method`\n\nSkontroluje zvislú polohu elementu vzhľadom na viewport.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Element` | yes |  | Element. |\n| `threshold` | `Number` | no | `0` | Počet pixelov elementu, ktoré musia byť vo viewporte. |\n| `mode` | `String` | no | `visible` | `visible`, `above` alebo `below`. |\n\nReturns: `Boolean` Výsledok kontroly.\n\n`mode` vyberá kontrolu: `visible` overí, či je element vo viewporte, `above`, či je nad ním, a `below`, či je pod ním. Skrytý element vráti `false`.\n\nExample: Skontroluj element\n```html\n<div id=\"top\">Top</div>\n<div style=\"height:5000px\"></div>\n<div id=\"far\">Far</div>\n\n<script>\nconsole.log(VISIBLE($('#top'))); // true\nconsole.log(VISIBLE($('#far'))); // false\nconsole.log(VISIBLE($('#far'), 0, 'below')); // true\n</script>\n```\n\n### W\n\nType: `property`\n\nKrátky názov objektu `window`.\n\nReturns: `Object` Objekt `window`.\n\nExample: Porovnaj objekty\n```js\nconsole.log(W === window); // true\n```\n\n### WAIT(condition, callback)\n\nType: `method`\n\nSpustí funkciu, keď je splnená podmienka.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `condition` | `Function|String` | yes |  | Funkcia alebo path. |\n| `callback` | `Function` | yes |  | Funkcia, ktorá sa má spustiť. |\n\nPodmienka sa skontroluje okamžite a potom každých 500 milisekúnd. Funkcia musí vrátiť pravdivú hodnotu. Pri path sa čakanie skončí, keď path obsahuje pravdivú hodnotu.\n\nExample: Počkaj na hodnotu\n```js\nWAIT('app.config', function() {\n\tconsole.log(GET('app.config.name')); // Demo\n});\n\nsetTimeout(function() {\n\tSET('app.config', { name: 'Demo' });\n}, 100);\n```\n\n### WARN(...values)\n\nType: `method`\n\nVypíše varovanie do konzoly prehliadača.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `values` | `Object` | yes |  | Hodnoty na výpis. |\n\n### WATCH(path, callback, [init])\n\nType: `method`\n\nSleduje zmeny path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `callback` | `Function` | yes |  | Funkcia, ktorá dostane `(value, flags, path)`: sledovanú hodnotu, flagy a zmenenú path. |\n| `init` | `Boolean` | no | `false` | Zavolá sledovač aj raz po registrácii. |\n\nSledovač sa spustí, keď sa zmení jeho vlastná path, nadradená path alebo path vnorená pod ňou. Niekoľko path môžeš spojiť znakom `+`.\n\nExample: Sleduj path\n```js\nWATCH('user.name', function(value, flags, path) {\n\tconsole.log(value, path); // Peter user.name\n});\n\nSET('user.name', 'Peter');\n```\n\n### WH\n\nType: `property`\n\nVýška okna v pixeloch.\n\nReturns: `Number` Výška.\n\nHodnota sa nastaví počas štartu knižnice a obnoví sa pri zmene veľkosti okna.\n\nExample: Prečítaj výšku\n```js\nON('ready', function() {\n\tconsole.log(typeof(WH)); // number\n});\n```\n\n### WIDTH([element])\n\nType: `method`\n\nVráti názov veľkosti zariadenia pre šírku elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | no | `window` | Meraný element. |\n\nReturns: `String` Názov veľkosti.\n\nVeľkosti `xs`, `sm`, `md` a `lg` sú definované v [DEF.devices](../def/).\n\nExample: Odmeraj element\n```html\n<div id=\"box\" style=\"width:800px\"></div>\n\n<script>\nconsole.log(WIDTH($('#box'))); // sm\n</script>\n```\n\n### WW\n\nType: `property`\n\nŠírka okna v pixeloch.\n\nReturns: `Number` Šírka.\n\nHodnota sa nastaví počas štartu knižnice a obnoví sa pri zmene veľkosti okna.\n\nExample: Prečítaj šírku\n```js\nON('ready', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n","entries":[{"type":"method","name":"ADAPT()","signature":"ADAPT(path, id, text)","since":"","deprecated":false},{"type":"method","name":"AJAX()","signature":"AJAX(url, [data], callback, [onprogress], [scope], [id])","since":"","deprecated":false},{"type":"method","name":"API()","signature":"API(url, name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"APPEARANCE()","signature":"APPEARANCE(options)","since":"","deprecated":false},{"type":"method","name":"ASETTER()","signature":"ASETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ATTRD()","signature":"ATTRD(element, [name])","since":"","deprecated":false},{"type":"method","name":"BLOCKED()","signature":"BLOCKED(key, timeout, [callback])","since":"","deprecated":false},{"type":"method","name":"CACHE()","signature":"CACHE(key, [value], [expire])","since":"","deprecated":false},{"type":"method","name":"CACHEPATH()","signature":"CACHEPATH(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"CL()","signature":"CL(name, [callback])","since":"","deprecated":false},{"type":"method","name":"clearTimeout2()","signature":"clearTimeout2(name)","since":"","deprecated":false},{"type":"method","name":"CLINIT()","signature":"CLINIT(name, source, [init])","since":"","deprecated":false},{"type":"method","name":"CLONE()","signature":"CLONE(value, [raw])","since":"","deprecated":false},{"type":"method","name":"CLRELOAD()","signature":"CLRELOAD(name, [callback])","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"COMPONENT()","signature":"COMPONENT(name, [config], callback, [dependencies], [css])","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"COMPONENTS(path)","since":"","deprecated":false},{"type":"method","name":"CONFIG()","signature":"CONFIG(selector, config)","since":"","deprecated":false},{"type":"property","name":"COOKIES","signature":"COOKIES","since":"","deprecated":false},{"type":"method","name":"COPY()","signature":"COPY(source, target)","since":"","deprecated":false},{"type":"method","name":"CSS()","signature":"CSS(value, [id], [selector])","since":"","deprecated":false},{"type":"property","name":"DAYS","signature":"DAYS","since":"","deprecated":false},{"type":"property","name":"DEF","signature":"DEF","since":"","deprecated":false},{"type":"method","name":"DECRYPT()","signature":"DECRYPT(text, [key], [type])","since":"","deprecated":false},{"type":"method","name":"DIFFDOM()","signature":"DIFFDOM(element, selector, html, [attribute])","since":"","deprecated":false},{"type":"method","name":"EMIT()","signature":"EMIT(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"EMPTYARRAY","signature":"EMPTYARRAY","since":"","deprecated":false},{"type":"property","name":"EMPTYOBJECT","signature":"EMPTYOBJECT","since":"","deprecated":false},{"type":"method","name":"ENCRYPT()","signature":"ENCRYPT(value, [key], [type])","since":"","deprecated":false},{"type":"method","name":"ENV()","signature":"ENV(name, [value])","since":"","deprecated":false},{"type":"method","name":"ENVIRONMENT()","signature":"ENVIRONMENT(name, [version], [language], [env])","since":"","deprecated":false},{"type":"method","name":"ERROR()","signature":"ERROR(response, [success], [error])","since":"","deprecated":false},{"type":"method","name":"ERRORS()","signature":"ERRORS(path, callback)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"EXTENSION()","signature":"EXTENSION(name, [config], callback)","since":"","deprecated":false},{"type":"method","name":"FIND()","signature":"FIND(selector, [all])","since":"","deprecated":false},{"type":"method","name":"FLAGS()","signature":"FLAGS(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"FN()","signature":"FN(code)","since":"","deprecated":false},{"type":"method","name":"FREE()","signature":"FREE()","since":"","deprecated":false},{"type":"property","name":"FUNC","signature":"FUNC","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path, [noflags])","since":"","deprecated":false},{"type":"method","name":"GUID()","signature":"GUID([length])","since":"","deprecated":false},{"type":"method","name":"HASH()","signature":"HASH(value)","since":"","deprecated":false},{"type":"method","name":"HIDDEN()","signature":"HIDDEN(element)","since":"","deprecated":false},{"type":"method","name":"IMPORT()","signature":"IMPORT(url, [target], [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"INC()","signature":"INC(path, [value])","since":"","deprecated":false},{"type":"method","name":"inDOM()","signature":"inDOM(element)","since":"","deprecated":false},{"type":"property","name":"isIE","signature":"isIE","since":"","deprecated":false},{"type":"property","name":"isMOBILE","signature":"isMOBILE","since":"","deprecated":false},{"type":"property","name":"isPRIVATEMODE","signature":"isPRIVATEMODE","since":"","deprecated":false},{"type":"property","name":"isROBOT","signature":"isROBOT","since":"","deprecated":false},{"type":"property","name":"isSTANDALONE","signature":"isSTANDALONE","since":"","deprecated":false},{"type":"property","name":"isTOUCH","signature":"isTOUCH","since":"","deprecated":false},{"type":"property","name":"jComponent","signature":"jComponent","since":"","deprecated":false},{"type":"method","name":"LOCALIZE()","signature":"LOCALIZE(text)","since":"","deprecated":false},{"type":"property","name":"M","signature":"M","since":"","deprecated":false},{"type":"property","name":"MAIN","signature":"MAIN","since":"","deprecated":false},{"type":"property","name":"MONTHS","signature":"MONTHS","since":"","deprecated":false},{"type":"method","name":"NEWUIBIND()","signature":"NEWUIBIND(element, [path], [config])","since":"","deprecated":false},{"type":"method","name":"NODEINDEXOF()","signature":"NODEINDEXOF(element)","since":"","deprecated":false},{"type":"method","name":"NODEINSERT()","signature":"NODEINSERT(element, reference, [before])","since":"","deprecated":false},{"type":"method","name":"NODEMOVE()","signature":"NODEMOVE(element, [up])","since":"","deprecated":false},{"type":"method","name":"NOOP()","signature":"NOOP()","since":"","deprecated":false},{"type":"method","name":"NOTFOCUSED()","signature":"NOTFOCUSED()","since":"","deprecated":false},{"type":"property","name":"NOW","signature":"NOW","since":"","deprecated":false},{"type":"method","name":"NUL()","signature":"NUL(path)","since":"","deprecated":false},{"type":"method","name":"OFF()","signature":"OFF(name, [callback])","since":"","deprecated":false},{"type":"method","name":"ON()","signature":"ON(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"PARSE()","signature":"PARSE(value)","since":"","deprecated":false},{"type":"method","name":"PIPE()","signature":"PIPE(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"method","name":"PLUGIN()","signature":"PLUGIN(name, [config], callback, [dependencies])","since":"","deprecated":false},{"type":"property","name":"PLUGINS","signature":"PLUGINS","since":"","deprecated":false},{"type":"property","name":"PREF","signature":"PREF","since":"","deprecated":false},{"type":"method","name":"PUSH()","signature":"PUSH(path, value)","since":"","deprecated":false},{"type":"method","name":"QUERIFY()","signature":"QUERIFY([url], data)","since":"","deprecated":false},{"type":"property","name":"REPO","signature":"REPO","since":"","deprecated":false},{"type":"method","name":"RESET()","signature":"RESET(path)","since":"","deprecated":false},{"type":"method","name":"SCROLLBAR()","signature":"SCROLLBAR(element, [options])","since":"","deprecated":false},{"type":"method","name":"SCROLLBARWIDTH()","signature":"SCROLLBARWIDTH()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setTimeout2()","signature":"setTimeout2(name, callback, timeout, [limit], [param])","since":"","deprecated":false},{"type":"method","name":"STRINGIFY()","signature":"STRINGIFY(value, [compress], [fields], [encrypt])","since":"","deprecated":false},{"type":"method","name":"STYLE()","signature":"STYLE(value, [id], [selector])","since":"","deprecated":false},{"type":"method","name":"TAPI()","signature":"TAPI(name, [data], callback, [scope])","since":"","deprecated":false},{"type":"property","name":"TEMP","signature":"TEMP","since":"","deprecated":false},{"type":"method","name":"TOGGLE()","signature":"TOGGLE(path)","since":"","deprecated":false},{"type":"property","name":"Total","signature":"Total","since":"","deprecated":false},{"type":"method","name":"TRANSLATE()","signature":"TRANSLATE(text)","since":"","deprecated":false},{"type":"method","name":"UNAUTHORIZED()","signature":"UNAUTHORIZED(...permissions)","since":"","deprecated":false},{"type":"method","name":"UNWATCH()","signature":"UNWATCH(path, [callback])","since":"","deprecated":false},{"type":"method","name":"UPD()","signature":"UPD(path)","since":"","deprecated":false},{"type":"method","name":"VISIBLE()","signature":"VISIBLE(element, [threshold], [mode])","since":"","deprecated":false},{"type":"property","name":"W","signature":"W","since":"","deprecated":false},{"type":"method","name":"WAIT()","signature":"WAIT(condition, callback)","since":"","deprecated":false},{"type":"method","name":"WARN()","signature":"WARN(...values)","since":"","deprecated":false},{"type":"method","name":"WATCH()","signature":"WATCH(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"WH","signature":"WH","since":"","deprecated":false},{"type":"method","name":"WIDTH()","signature":"WIDTH([element])","since":"","deprecated":false},{"type":"property","name":"WW","signature":"WW","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcQb5Qd61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/def/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"DEF","summary":"The default settings of the library.","markdown":"---\ntitle: DEF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/def/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# DEF\n\n> The default settings of the library.\n\n`DEF` holds the default settings of the library. Assign the values directly after the library script, so that they apply from the start. [Getting started](../../guides/getting-started/) shows where this code belongs.\n\n## API\n\n### DEF.api = undefined\n\nType: `config`\n\nThe address used by `TAPI()`.\n\nReturns: `String` Default: `undefined`.\n\nAssign it to use [TAPI()](../globals/).\n\nExample: Set the endpoint\n```js\nDEF.api = '/admin/api/';\nconsole.log(DEF.api); // /admin/api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nThe prefix that `String.ROOT()` adds to relative addresses.\n\nReturns: `String|Function` Default: `''`.\n\nA function receives the address and returns the final address. [DEF.root](../def/) takes priority. See [String](../string/).\n\nExample: Prefix an address\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nThe value of the `~CDN~` keyword in imported content.\n\nReturns: `String` Default: `''`.\n\nThe keyword is replaced by [ADAPT()](../globals/).\n\nExample: Use the keyword\n```js\nDEF.cdn = 'https://cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/logo.png')); // https://cdn.example.com/logo.png\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nThe loaded code lists.\n\nReturns: `Object` Default: `{}`.\n\nThe path prefix `#` points here, so `#countries` is `DEF.cl.countries`. See [CL()](../globals/).\n\nExample: Read a list through its path\n```js\nSET('#colors', ['red']);\nconsole.log(DEF.cl.colors); // [\"red\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nThe accent colour of the app.\n\nReturns: `String` Default: `'#4285F4'`.\n\n[APPEARANCE()](../globals/) updates it.\n\nExample: Change the colour\n```js\nAPPEARANCE({ color: '#FF0000' });\nconsole.log(DEF.color); // #FF0000\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nThe formatters used by `Number.currency()`.\n\nReturns: `Object` Default: `{}`.\n\nEach key is a currency name and each value is a function that receives the number. See [Number](../number/).\n\nExample: Define a currency\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\nconsole.log((10).currency('eur')); // 10.00 EUR\n```\n\n### DEF.currency = ''\n\nType: `config`\n\nThe default currency of `Number.currency()`.\n\nReturns: `String` Default: `''`.\n\nExample: Set the default currency\n```js\nDEF.currencies.usd = function(value) {\n\treturn '$' + value.format(2);\n};\n\nDEF.currency = 'usd';\nconsole.log((5).currency()); // $5.00\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nThe default format of `Date.format()` and of date parsing.\n\nReturns: `String` Default: `'yyyy-MM-dd'`.\n\nSee [Date](../date/).\n\nExample: Change the format\n```js\nDEF.dateformat = 'dd.MM.yyyy';\nconsole.log(new Date(2024, 0, 15).format()); // 15.01.2024\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nFormats all dates in UTC.\n\nReturns: `Boolean` Default: `false`.\n\nIt applies to `Date.format()`. See [Date](../date/).\n\nExample: Format in UTC\n```js\nDEF.dateformatutc = true;\nconsole.log(new Date(Date.UTC(2024, 0, 15, 12, 30)).format('HH:mm')); // 12:30\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nThe decimal separator of formatted numbers.\n\nReturns: `String` Default: `'.'`.\n\nIt is used by `Number.format()` and when numbers are parsed. See [Number](../number/).\n\nExample: Use a decimal comma\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }\n\nType: `config`\n\nThe width ranges of the device sizes.\n\nReturns: `Object` Default: `{ xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }`.\n\nThe ranges are used by [WIDTH()](../globals/) and by the `jc-xs`, `jc-sm`, `jc-md` and `jc-lg` body classes.\n\nExample: Read a range\n```js\nconsole.log(DEF.devices.md); // {\"min\":992,\"max\":1200}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nThe translations loaded with `LOCALIZE()`.\n\nReturns: `Object` Default: `{}`.\n\nSee [Localization](../../guides/localization/).\n\nExample: Read the dictionary\n```js\nLOCALIZE('Tabc : Hola');\nconsole.log(DEF.dictionary.Tabc); // Hola\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nThe text displayed for an empty value.\n\nReturns: `String` Default: `'---'`.\n\nIt is used by the `empty` command of [ui-bind](../ui-bind/) and by the `empty` [Tangular helper](../tangular-helpers/).\n\nExample: Read the text\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }\n\nType: `config`\n\nThe environment variables.\n\nReturns: `Object` Default: `{ ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }`.\n\nVariables are managed with [ENV()](../globals/). The default values can be used as date formats, for example `[ts]`.\n\nExample: Use a variable as a date format\n```js\nvar date = new Date(2024, 0, 15, 8, 5);\nconsole.log(date.format('[ts]')); // 2024-01-15 - 08:05\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nThe address from which unknown components are downloaded.\n\nReturns: `String` Default: `'https://cdn.componentator.com/j-{0}.html'`.\n\nThe `{0}` keyword becomes the component name. The `source` attribute of [ui-component](../ui-component/) overrides it.\n\nExample: Read the address\n```js\nconsole.log(DEF.fallback.format('input')); // https://cdn.componentator.com/j-input.html\n```\n\n### DEF.firstdayofweek = 1\n\nType: `config`\n\nThe first day of the week, for components that display a calendar.\n\nReturns: `Number` Default: `1`.\n\nThe value `0` is Sunday and `1` is Monday. The library only stores it.\n\nExample: Start the week on Sunday\n```js\nDEF.firstdayofweek = 0;\nconsole.log(DAYS[DEF.firstdayofweek]); // Sunday\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nThe headers added to every `AJAX()` request.\n\nReturns: `Object` Default: `{ 'X-Requested-With': 'XMLHttpRequest' }`.\n\nExample: Add a header\n```js\nDEF.headers['x-token'] = '123456';\nconsole.log(DEF.headers['x-token']); // 123456\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nThe prefix added to icon names by `component.icon()`.\n\nReturns: `String` Default: `'ti ti-'`.\n\nA value that contains a space is used as it is. See [Component](../component/).\n\nExample: Change the prefix\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tDEF.iconprefix = 'fa fa-';\n\t\tconsole.log(self.icon('home')); // fa fa-home\n\t};\n});\n</script>\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nThe language added to the query string of every `AJAX()` request.\n\nReturns: `String` Default: `undefined`.\n\nThe name of the parameter is in [DEF.languagekey](../def/). [ENVIRONMENT()](../globals/) can set this value.\n\nExample: Set the language\n```js\nDEF.language = 'en';\nconsole.log(DEF.language); // en\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nThe name of the query parameter that carries the language.\n\nReturns: `String` Default: `'language'`.\n\nExample: Read the name\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nThe `localStorage` key of the cache.\n\nReturns: `String` Default: `'jc'`.\n\n[ENVIRONMENT()](../globals/) can set this value.\n\nExample: Read the key\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.onstorageread = function(callback)\n\nType: `config`\n\nLoads the persistent cache when the library starts.\n\nReturns: `Function` Default: `function(callback)`.\n\nAssign your own function directly after the library script. It must call `callback` with the stored object. The default function reads `localStorage`.\n\nExample: Provide the stored data\n```js\nDEF.onstorageread = function(callback) {\n\tcallback({});\n};\n\nON('ready', function() {\n\tconsole.log('loaded'); // loaded\n});\n```\n\n### DEF.onstoragesave = function(data)\n\nType: `config`\n\nSaves the persistent cache.\n\nReturns: `Function` Default: `function(data)`.\n\nThe function receives an object with all the items that have an expiration. The default function writes to `localStorage`.\n\nExample: Observe saving\n```js\nDEF.onstoragesave = function(data) {\n\tconsole.log(Object.keys(data).length); // 1\n};\n\nON('ready', function() {\n\tCACHE('filter', 1, '1 day');\n});\n```\n\n### DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }\n\nType: `config`\n\nThe targets of the short path prefixes.\n\nReturns: `Object` Default: `{ common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }`.\n\n`common` is the target of `*`, `cl` of `#` and `tmp` of `%`. `plugins` holds the data of plugins with a generated path. The function `DEF.path.clean(name)` returns a value without the final dot. See [Paths](../../guides/paths/).\n\nExample: Read a prefix\n```js\nconsole.log(DEF.path.common); // common.\nconsole.log(DEF.path.clean('common')); // common\n```\n\n### DEF.pipe = undefined\n\nType: `config`\n\nThe address used by `PIPE()`.\n\nReturns: `String` Default: `undefined`.\n\nAssign it to use [PIPE()](../globals/).\n\nExample: Set the endpoint\n```js\nDEF.pipe = '/pipe/';\nconsole.log(DEF.pipe); // /pipe/\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nThe prefix of the CSS class that a component receives as `cls`.\n\nReturns: `String` Default: `'ui-'`.\n\nExample: Change the prefix\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nDEF.prefixcsscomponents = 'my-';\n\nCOMPONENT('box', function(self, config, cls) {\n\tconsole.log(cls); // my-box\n});\n</script>\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nThe prefix of the CSS classes created by the library.\n\nReturns: `String` Default: `'ui-'`.\n\nIt is used by [APPEARANCE()](../globals/) and [SCROLLBAR()](../globals/).\n\nExample: Change the prefix\n```js\nDEF.prefixcsslibrary = 'app-';\nAPPEARANCE({ dark: true });\nconsole.log($('body').hclass('app-dark')); // true\n```\n\n### DEF.regexp = { int, float, date, pluralize, format, url, phone, email }\n\nType: `config`\n\nThe regular expressions used by the helpers.\n\nReturns: `Object` Default: `{ int, float, date, pluralize, format, url, phone, email }`.\n\nFor example, `String.isEmail()` uses `DEF.regexp.email`. See [String](../string/).\n\nExample: Validate an e-mail address\n```js\nconsole.log(DEF.regexp.email.test('info@example.com')); // true\nconsole.log('invalid'.isEmail()); // false\n```\n\n### DEF.root = ''\n\nType: `config`\n\nThe prefix that `String.ROOT()` adds to every relative address.\n\nReturns: `String|Function` Default: `''`.\n\nIt takes priority over [DEF.baseurl](../def/), and `ROOT(true)` applies only this value. See [String](../string/).\n\nExample: Prefix an address\n```js\nDEF.root = '/admin';\nconsole.log('/users/'.ROOT()); // /admin/users/\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnimates the bar of a custom scrollbar at the edges of the scrolling area.\n\nReturns: `Boolean` Default: `true`.\n\nSee [SCROLLBAR()](../globals/).\n\nExample: Disable the animation\n```js\nDEF.scrollbaranimate = false;\nconsole.log(DEF.scrollbaranimate); // false\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nThe thousands separator of formatted numbers.\n\nReturns: `String` Default: `' '`.\n\nIt is used by `Number.format()` and when numbers are parsed. See [Number](../number/).\n\nExample: Use a comma\n```js\nDEF.thousandsseparator = ',';\nconsole.log((1234567).format(0)); // 1,234,567\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nThe time format copied into the environment variables at startup.\n\nReturns: `String` Default: `'HH:mm'`.\n\nTo change the format later, write the variables `time` and `ts` with [ENV()](../globals/).\n\nExample: Read the format\n```js\nconsole.log(DEF.timeformat); // HH:mm\nconsole.log(ENV('time')); // HH:mm\n```\n\n### DEF.tmp = {}\n\nType: `config`\n\nThe storage of temporary paths.\n\nReturns: `Object` Default: `{}`.\n\nThe path prefix `%` points here, so `%form` is `DEF.tmp.form`. See [Paths](../../guides/paths/).\n\nExample: Write a temporary value\n```js\nSET('%search', 'phone');\nconsole.log(DEF.tmp.search); // phone\n```\n\n### DEF.version = undefined\n\nType: `config`\n\nThe version added to `.html` addresses requested with `AJAX()`.\n\nReturns: `String` Default: `undefined`.\n\nThe name of the parameter is in [DEF.versionkey](../def/). [ENVIRONMENT()](../globals/) can set this value.\n\nExample: Set the version\n```js\nDEF.version = '1.0';\nconsole.log(DEF.version); // 1.0\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nThe version for `.html` addresses when `DEF.version` is empty.\n\nReturns: `String` Default: `undefined`.\n\nExample: Set the version of HTML files\n```js\nDEF.versionhtml = '2';\nconsole.log(DEF.versionhtml); // 2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nThe name of the query parameter that carries the version.\n\nReturns: `String` Default: `'version'`.\n\nExample: Read the name\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.warnings = false\n\nType: `config`\n\nPrints the warnings of the library to the console.\n\nReturns: `Boolean` Default: `false`.\n\nEnable it during development, for example to report a method that was not found.\n\nExample: Enable warnings\n```js\nDEF.warnings = true;\nconsole.log(DEF.warnings); // true\n```\n","entries":[{"type":"config","name":"DEF.api","signature":"DEF.api = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.baseurl","signature":"DEF.baseurl = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cdn","signature":"DEF.cdn = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cl","signature":"DEF.cl = {}","since":"","deprecated":false},{"type":"config","name":"DEF.color","signature":"DEF.color = '#4285F4'","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = ''","since":"","deprecated":false},{"type":"config","name":"DEF.dateformat","signature":"DEF.dateformat = 'yyyy-MM-dd'","since":"","deprecated":false},{"type":"config","name":"DEF.dateformatutc","signature":"DEF.dateformatutc = false","since":"","deprecated":false},{"type":"config","name":"DEF.decimalseparator","signature":"DEF.decimalseparator = '.'","since":"","deprecated":false},{"type":"config","name":"DEF.devices","signature":"DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }","since":"","deprecated":false},{"type":"config","name":"DEF.dictionary","signature":"DEF.dictionary = {}","since":"","deprecated":false},{"type":"config","name":"DEF.empty","signature":"DEF.empty = '---'","since":"","deprecated":false},{"type":"config","name":"DEF.env","signature":"DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }","since":"","deprecated":false},{"type":"config","name":"DEF.fallback","signature":"DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'","since":"","deprecated":false},{"type":"config","name":"DEF.firstdayofweek","signature":"DEF.firstdayofweek = 1","since":"","deprecated":false},{"type":"config","name":"DEF.headers","signature":"DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }","since":"","deprecated":false},{"type":"config","name":"DEF.iconprefix","signature":"DEF.iconprefix = 'ti ti-'","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagekey","signature":"DEF.languagekey = 'language'","since":"","deprecated":false},{"type":"config","name":"DEF.localstorage","signature":"DEF.localstorage = 'jc'","since":"","deprecated":false},{"type":"config","name":"DEF.onstorageread","signature":"DEF.onstorageread = function(callback)","since":"","deprecated":false},{"type":"config","name":"DEF.onstoragesave","signature":"DEF.onstoragesave = function(data)","since":"","deprecated":false},{"type":"config","name":"DEF.path","signature":"DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }","since":"","deprecated":false},{"type":"config","name":"DEF.pipe","signature":"DEF.pipe = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsscomponents","signature":"DEF.prefixcsscomponents = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsslibrary","signature":"DEF.prefixcsslibrary = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format, url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.thousandsseparator","signature":"DEF.thousandsseparator = ' '","since":"","deprecated":false},{"type":"config","name":"DEF.timeformat","signature":"DEF.timeformat = 'HH:mm'","since":"","deprecated":false},{"type":"config","name":"DEF.tmp","signature":"DEF.tmp = {}","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionhtml","signature":"DEF.versionhtml = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionkey","signature":"DEF.versionkey = 'version'","since":"","deprecated":false},{"type":"config","name":"DEF.warnings","signature":"DEF.warnings = false","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcQb5Qd61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/def/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"DEF","summary":"Die Standardeinstellungen der Bibliothek.","markdown":"---\ntitle: DEF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/def/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# DEF\n\n> Die Standardeinstellungen der Bibliothek.\n\n`DEF` enthält die Standardeinstellungen der Bibliothek. Weise die Werte direkt nach dem Skript der Bibliothek zu, damit sie von Anfang an gelten. [Erste Schritte](../../guides/getting-started/) zeigt, wo dieser Code hingehört.\n\n## API\n\n### DEF.api = undefined\n\nType: `config`\n\nDie von `TAPI()` verwendete Adresse.\n\nReturns: `String` Standardwert: `undefined`.\n\nWeise sie zu, um [TAPI()](../globals/) zu verwenden.\n\nExample: Den Endpunkt festlegen\n```js\nDEF.api = '/admin/api/';\nconsole.log(DEF.api); // /admin/api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nDas Präfix, das `String.ROOT()` relativen Adressen hinzufügt.\n\nReturns: `String|Function` Standardwert: `''`.\n\nEine Funktion erhält die Adresse und gibt die endgültige Adresse zurück. [DEF.root](../def/) hat Vorrang. Siehe [String](../string/).\n\nExample: Einer Adresse ein Präfix voranstellen\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nDer Wert des Schlüsselworts `~CDN~` in importierten Inhalten.\n\nReturns: `String` Standardwert: `''`.\n\nDas Schlüsselwort wird von [ADAPT()](../globals/) ersetzt.\n\nExample: Das Schlüsselwort verwenden\n```js\nDEF.cdn = 'https://cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/logo.png')); // https://cdn.example.com/logo.png\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nDie geladenen Codelisten.\n\nReturns: `Object` Standardwert: `{}`.\n\nDas Path-Präfix `#` zeigt hierher, `#countries` ist also `DEF.cl.countries`. Siehe [CL()](../globals/).\n\nExample: Eine Liste über ihren Path lesen\n```js\nSET('#colors', ['red']);\nconsole.log(DEF.cl.colors); // [\"red\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nDie Akzentfarbe der App.\n\nReturns: `String` Standardwert: `'#4285F4'`.\n\n[APPEARANCE()](../globals/) aktualisiert sie.\n\nExample: Die Farbe ändern\n```js\nAPPEARANCE({ color: '#FF0000' });\nconsole.log(DEF.color); // #FF0000\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nDie von `Number.currency()` verwendeten Formatierer.\n\nReturns: `Object` Standardwert: `{}`.\n\nJeder Schlüssel ist ein Währungsname und jeder Wert eine Funktion, die die Zahl erhält. Siehe [Number](../number/).\n\nExample: Eine Währung definieren\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\nconsole.log((10).currency('eur')); // 10.00 EUR\n```\n\n### DEF.currency = ''\n\nType: `config`\n\nDie Standardwährung von `Number.currency()`.\n\nReturns: `String` Standardwert: `''`.\n\nExample: Die Standardwährung festlegen\n```js\nDEF.currencies.usd = function(value) {\n\treturn '$' + value.format(2);\n};\n\nDEF.currency = 'usd';\nconsole.log((5).currency()); // $5.00\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nDas Standardformat von `Date.format()` und beim Parsen von Datumsangaben.\n\nReturns: `String` Standardwert: `'yyyy-MM-dd'`.\n\nSiehe [Date](../date/).\n\nExample: Das Format ändern\n```js\nDEF.dateformat = 'dd.MM.yyyy';\nconsole.log(new Date(2024, 0, 15).format()); // 15.01.2024\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nFormatiert alle Datumsangaben in UTC.\n\nReturns: `Boolean` Standardwert: `false`.\n\nDas gilt für `Date.format()`. Siehe [Date](../date/).\n\nExample: In UTC formatieren\n```js\nDEF.dateformatutc = true;\nconsole.log(new Date(Date.UTC(2024, 0, 15, 12, 30)).format('HH:mm')); // 12:30\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nDas Dezimaltrennzeichen formatierter Zahlen.\n\nReturns: `String` Standardwert: `'.'`.\n\nEs wird von `Number.format()` und beim Parsen von Zahlen verwendet. Siehe [Number](../number/).\n\nExample: Ein Dezimalkomma verwenden\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }\n\nType: `config`\n\nDie Breitenbereiche der Gerätegrößen.\n\nReturns: `Object` Standardwert: `{ xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }`.\n\nDie Bereiche werden von [WIDTH()](../globals/) und von den Body-Klassen `jc-xs`, `jc-sm`, `jc-md` und `jc-lg` verwendet.\n\nExample: Einen Bereich lesen\n```js\nconsole.log(DEF.devices.md); // {\"min\":992,\"max\":1200}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nDie mit `LOCALIZE()` geladenen Übersetzungen.\n\nReturns: `Object` Standardwert: `{}`.\n\nSiehe [Lokalisierung](../../guides/localization/).\n\nExample: Das Wörterbuch lesen\n```js\nLOCALIZE('Tabc : Hola');\nconsole.log(DEF.dictionary.Tabc); // Hola\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nDer Text, der bei einem leeren Wert angezeigt wird.\n\nReturns: `String` Standardwert: `'---'`.\n\nEr wird vom Befehl `empty` von [ui-bind](../ui-bind/) und vom [Tangular-Helper](../tangular-helpers/) `empty` verwendet.\n\nExample: Den Text lesen\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }\n\nType: `config`\n\nDie Umgebungsvariablen.\n\nReturns: `Object` Standardwert: `{ ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }`.\n\nVariablen werden mit [ENV()](../globals/) verwaltet. Die Standardwerte lassen sich als Datumsformate verwenden, zum Beispiel `[ts]`.\n\nExample: Eine Variable als Datumsformat verwenden\n```js\nvar date = new Date(2024, 0, 15, 8, 5);\nconsole.log(date.format('[ts]')); // 2024-01-15 - 08:05\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nDie Adresse, von der unbekannte Komponenten heruntergeladen werden.\n\nReturns: `String` Standardwert: `'https://cdn.componentator.com/j-{0}.html'`.\n\nDas Schlüsselwort `{0}` wird zum Namen der Komponente. Das Attribut `source` von [ui-component](../ui-component/) überschreibt die Adresse.\n\nExample: Die Adresse lesen\n```js\nconsole.log(DEF.fallback.format('input')); // https://cdn.componentator.com/j-input.html\n```\n\n### DEF.firstdayofweek = 1\n\nType: `config`\n\nDer erste Tag der Woche, für Komponenten, die einen Kalender anzeigen.\n\nReturns: `Number` Standardwert: `1`.\n\nDer Wert `0` steht für Sonntag und `1` für Montag. Die Bibliothek speichert ihn nur.\n\nExample: Die Woche am Sonntag beginnen\n```js\nDEF.firstdayofweek = 0;\nconsole.log(DAYS[DEF.firstdayofweek]); // Sunday\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nDie Header, die jeder `AJAX()`-Anfrage hinzugefügt werden.\n\nReturns: `Object` Standardwert: `{ 'X-Requested-With': 'XMLHttpRequest' }`.\n\nExample: Einen Header hinzufügen\n```js\nDEF.headers['x-token'] = '123456';\nconsole.log(DEF.headers['x-token']); // 123456\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nDas Präfix, das `component.icon()` Icon-Namen hinzufügt.\n\nReturns: `String` Standardwert: `'ti ti-'`.\n\nEin Wert, der ein Leerzeichen enthält, wird unverändert verwendet. Siehe [Component](../component/).\n\nExample: Das Präfix ändern\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tDEF.iconprefix = 'fa fa-';\n\t\tconsole.log(self.icon('home')); // fa fa-home\n\t};\n});\n</script>\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nDie Sprache, die dem Query-String jeder `AJAX()`-Anfrage hinzugefügt wird.\n\nReturns: `String` Standardwert: `undefined`.\n\nDer Name des Parameters steht in [DEF.languagekey](../def/). [ENVIRONMENT()](../globals/) kann diesen Wert setzen.\n\nExample: Die Sprache festlegen\n```js\nDEF.language = 'en';\nconsole.log(DEF.language); // en\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nDer Name des Query-Parameters, der die Sprache überträgt.\n\nReturns: `String` Standardwert: `'language'`.\n\nExample: Den Namen lesen\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nDer `localStorage`-Schlüssel des Caches.\n\nReturns: `String` Standardwert: `'jc'`.\n\n[ENVIRONMENT()](../globals/) kann diesen Wert setzen.\n\nExample: Den Schlüssel lesen\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.onstorageread = function(callback)\n\nType: `config`\n\nLädt den persistenten Cache beim Start der Bibliothek.\n\nReturns: `Function` Standardwert: `function(callback)`.\n\nWeise direkt nach dem Skript der Bibliothek deine eigene Funktion zu. Diese muss `callback` mit dem gespeicherten Objekt aufrufen. Die Standardfunktion liest aus `localStorage`.\n\nExample: Die gespeicherten Daten bereitstellen\n```js\nDEF.onstorageread = function(callback) {\n\tcallback({});\n};\n\nON('ready', function() {\n\tconsole.log('loaded'); // loaded\n});\n```\n\n### DEF.onstoragesave = function(data)\n\nType: `config`\n\nSpeichert den persistenten Cache.\n\nReturns: `Function` Standardwert: `function(data)`.\n\nDie Funktion erhält ein Objekt mit allen Einträgen, die ein Ablaufdatum haben. Die Standardfunktion schreibt in `localStorage`.\n\nExample: Das Speichern beobachten\n```js\nDEF.onstoragesave = function(data) {\n\tconsole.log(Object.keys(data).length); // 1\n};\n\nON('ready', function() {\n\tCACHE('filter', 1, '1 day');\n});\n```\n\n### DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }\n\nType: `config`\n\nDie Ziele der kurzen Path-Präfixe.\n\nReturns: `Object` Standardwert: `{ common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }`.\n\n`common` ist das Ziel von `*`, `cl` von `#` und `tmp` von `%`. `plugins` enthält die Daten von Plugins mit generiertem Path. Die Funktion `DEF.path.clean(name)` gibt einen Wert ohne den abschließenden Punkt zurück. Siehe [Paths](../../guides/paths/).\n\nExample: Ein Präfix lesen\n```js\nconsole.log(DEF.path.common); // common.\nconsole.log(DEF.path.clean('common')); // common\n```\n\n### DEF.pipe = undefined\n\nType: `config`\n\nDie von `PIPE()` verwendete Adresse.\n\nReturns: `String` Standardwert: `undefined`.\n\nWeise sie zu, um [PIPE()](../globals/) zu verwenden.\n\nExample: Den Endpunkt festlegen\n```js\nDEF.pipe = '/pipe/';\nconsole.log(DEF.pipe); // /pipe/\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nDas Präfix der CSS-Klasse, die eine Komponente als `cls` erhält.\n\nReturns: `String` Standardwert: `'ui-'`.\n\nExample: Das Präfix ändern\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nDEF.prefixcsscomponents = 'my-';\n\nCOMPONENT('box', function(self, config, cls) {\n\tconsole.log(cls); // my-box\n});\n</script>\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nDas Präfix der von der Bibliothek erstellten CSS-Klassen.\n\nReturns: `String` Standardwert: `'ui-'`.\n\nEs wird von [APPEARANCE()](../globals/) und [SCROLLBAR()](../globals/) verwendet.\n\nExample: Das Präfix ändern\n```js\nDEF.prefixcsslibrary = 'app-';\nAPPEARANCE({ dark: true });\nconsole.log($('body').hclass('app-dark')); // true\n```\n\n### DEF.regexp = { int, float, date, pluralize, format, url, phone, email }\n\nType: `config`\n\nDie von den Helpern verwendeten regulären Ausdrücke.\n\nReturns: `Object` Standardwert: `{ int, float, date, pluralize, format, url, phone, email }`.\n\n`String.isEmail()` verwendet zum Beispiel `DEF.regexp.email`. Siehe [String](../string/).\n\nExample: Eine E-Mail-Adresse validieren\n```js\nconsole.log(DEF.regexp.email.test('info@example.com')); // true\nconsole.log('invalid'.isEmail()); // false\n```\n\n### DEF.root = ''\n\nType: `config`\n\nDas Präfix, das `String.ROOT()` jeder relativen Adresse hinzufügt.\n\nReturns: `String|Function` Standardwert: `''`.\n\nEs hat Vorrang vor [DEF.baseurl](../def/), und `ROOT(true)` wendet nur diesen Wert an. Siehe [String](../string/).\n\nExample: Einer Adresse ein Präfix voranstellen\n```js\nDEF.root = '/admin';\nconsole.log('/users/'.ROOT()); // /admin/users/\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnimiert den Balken einer eigenen Scrollbar an den Rändern des Scrollbereichs.\n\nReturns: `Boolean` Standardwert: `true`.\n\nSiehe [SCROLLBAR()](../globals/).\n\nExample: Die Animation deaktivieren\n```js\nDEF.scrollbaranimate = false;\nconsole.log(DEF.scrollbaranimate); // false\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nDas Tausendertrennzeichen formatierter Zahlen.\n\nReturns: `String` Standardwert: `' '`.\n\nEs wird von `Number.format()` und beim Parsen von Zahlen verwendet. Siehe [Number](../number/).\n\nExample: Ein Komma verwenden\n```js\nDEF.thousandsseparator = ',';\nconsole.log((1234567).format(0)); // 1,234,567\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nDas Zeitformat, das beim Start in die Umgebungsvariablen kopiert wird.\n\nReturns: `String` Standardwert: `'HH:mm'`.\n\nUm das Format später zu ändern, schreibe die Variablen `time` und `ts` mit [ENV()](../globals/).\n\nExample: Format lesen\n```js\nconsole.log(DEF.timeformat); // HH:mm\nconsole.log(ENV('time')); // HH:mm\n```\n\n### DEF.tmp = {}\n\nType: `config`\n\nDer Speicher für temporäre Paths.\n\nReturns: `Object` Standardwert: `{}`.\n\nDas Path-Präfix `%` verweist hierher, `%form` ist also `DEF.tmp.form`. Siehe [Paths](../../guides/paths/).\n\nExample: Temporären Wert schreiben\n```js\nSET('%search', 'phone');\nconsole.log(DEF.tmp.search); // phone\n```\n\n### DEF.version = undefined\n\nType: `config`\n\nDie Version, die an `.html`-Adressen angehängt wird, wenn du sie mit `AJAX()` anforderst.\n\nReturns: `String` Standardwert: `undefined`.\n\nDer Name des Parameters steht in [DEF.versionkey](../def/). [ENVIRONMENT()](../globals/) kann diesen Wert setzen.\n\nExample: Version setzen\n```js\nDEF.version = '1.0';\nconsole.log(DEF.version); // 1.0\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nDie Version für `.html`-Adressen, wenn `DEF.version` leer ist.\n\nReturns: `String` Standardwert: `undefined`.\n\nExample: Version der HTML-Dateien setzen\n```js\nDEF.versionhtml = '2';\nconsole.log(DEF.versionhtml); // 2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nDer Name des Query-Parameters, der die Version enthält.\n\nReturns: `String` Standardwert: `'version'`.\n\nExample: Den Namen lesen\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.warnings = false\n\nType: `config`\n\nGibt die Warnungen der Bibliothek in der Konsole aus.\n\nReturns: `Boolean` Standardwert: `false`.\n\nAktiviere das während der Entwicklung, damit zum Beispiel eine nicht gefundene Methode gemeldet wird.\n\nExample: Warnungen aktivieren\n```js\nDEF.warnings = true;\nconsole.log(DEF.warnings); // true\n```\n","entries":[{"type":"config","name":"DEF.api","signature":"DEF.api = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.baseurl","signature":"DEF.baseurl = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cdn","signature":"DEF.cdn = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cl","signature":"DEF.cl = {}","since":"","deprecated":false},{"type":"config","name":"DEF.color","signature":"DEF.color = '#4285F4'","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = ''","since":"","deprecated":false},{"type":"config","name":"DEF.dateformat","signature":"DEF.dateformat = 'yyyy-MM-dd'","since":"","deprecated":false},{"type":"config","name":"DEF.dateformatutc","signature":"DEF.dateformatutc = false","since":"","deprecated":false},{"type":"config","name":"DEF.decimalseparator","signature":"DEF.decimalseparator = '.'","since":"","deprecated":false},{"type":"config","name":"DEF.devices","signature":"DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }","since":"","deprecated":false},{"type":"config","name":"DEF.dictionary","signature":"DEF.dictionary = {}","since":"","deprecated":false},{"type":"config","name":"DEF.empty","signature":"DEF.empty = '---'","since":"","deprecated":false},{"type":"config","name":"DEF.env","signature":"DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }","since":"","deprecated":false},{"type":"config","name":"DEF.fallback","signature":"DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'","since":"","deprecated":false},{"type":"config","name":"DEF.firstdayofweek","signature":"DEF.firstdayofweek = 1","since":"","deprecated":false},{"type":"config","name":"DEF.headers","signature":"DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }","since":"","deprecated":false},{"type":"config","name":"DEF.iconprefix","signature":"DEF.iconprefix = 'ti ti-'","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagekey","signature":"DEF.languagekey = 'language'","since":"","deprecated":false},{"type":"config","name":"DEF.localstorage","signature":"DEF.localstorage = 'jc'","since":"","deprecated":false},{"type":"config","name":"DEF.onstorageread","signature":"DEF.onstorageread = function(callback)","since":"","deprecated":false},{"type":"config","name":"DEF.onstoragesave","signature":"DEF.onstoragesave = function(data)","since":"","deprecated":false},{"type":"config","name":"DEF.path","signature":"DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }","since":"","deprecated":false},{"type":"config","name":"DEF.pipe","signature":"DEF.pipe = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsscomponents","signature":"DEF.prefixcsscomponents = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsslibrary","signature":"DEF.prefixcsslibrary = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format, url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.thousandsseparator","signature":"DEF.thousandsseparator = ' '","since":"","deprecated":false},{"type":"config","name":"DEF.timeformat","signature":"DEF.timeformat = 'HH:mm'","since":"","deprecated":false},{"type":"config","name":"DEF.tmp","signature":"DEF.tmp = {}","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionhtml","signature":"DEF.versionhtml = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionkey","signature":"DEF.versionkey = 'version'","since":"","deprecated":false},{"type":"config","name":"DEF.warnings","signature":"DEF.warnings = false","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcQb5Qd61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/def/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"DEF","summary":"La configuración predeterminada de la biblioteca.","markdown":"---\ntitle: DEF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/def/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# DEF\n\n> La configuración predeterminada de la biblioteca.\n\n`DEF` contiene la configuración predeterminada de la biblioteca. Asigna los valores justo después del script de la biblioteca, para que se apliquen desde el principio. [Primeros pasos](../../guides/getting-started/) muestra dónde va este código.\n\n## API\n\n### DEF.api = undefined\n\nType: `config`\n\nLa dirección que usa `TAPI()`.\n\nReturns: `String` Valor predeterminado: `undefined`.\n\nAsígnala para usar [TAPI()](../globals/).\n\nExample: Establecer el endpoint\n```js\nDEF.api = '/admin/api/';\nconsole.log(DEF.api); // /admin/api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nEl prefijo que `String.ROOT()` añade a las direcciones relativas.\n\nReturns: `String|Function` Valor predeterminado: `''`.\n\nUna función recibe la dirección y devuelve la dirección final. [DEF.root](../def/) tiene prioridad. Consulta [String](../string/).\n\nExample: Añadir un prefijo a una dirección\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nEl valor de la palabra clave `~CDN~` en el contenido importado.\n\nReturns: `String` Valor predeterminado: `''`.\n\n[ADAPT()](../globals/) sustituye la palabra clave.\n\nExample: Usar la palabra clave\n```js\nDEF.cdn = 'https://cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/logo.png')); // https://cdn.example.com/logo.png\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nLas listas de códigos cargadas.\n\nReturns: `Object` Valor predeterminado: `{}`.\n\nEl prefijo de path `#` apunta aquí, así que `#countries` es `DEF.cl.countries`. Consulta [CL()](../globals/).\n\nExample: Leer una lista a través de su path\n```js\nSET('#colors', ['red']);\nconsole.log(DEF.cl.colors); // [\"red\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nEl color de acento de la aplicación.\n\nReturns: `String` Valor predeterminado: `'#4285F4'`.\n\n[APPEARANCE()](../globals/) lo actualiza.\n\nExample: Cambiar el color\n```js\nAPPEARANCE({ color: '#FF0000' });\nconsole.log(DEF.color); // #FF0000\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nLos formateadores que usa `Number.currency()`.\n\nReturns: `Object` Valor predeterminado: `{}`.\n\nCada clave es el nombre de una moneda y cada valor es una función que recibe el número. Consulta [Number](../number/).\n\nExample: Definir una moneda\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\nconsole.log((10).currency('eur')); // 10.00 EUR\n```\n\n### DEF.currency = ''\n\nType: `config`\n\nLa moneda predeterminada de `Number.currency()`.\n\nReturns: `String` Valor predeterminado: `''`.\n\nExample: Establecer la moneda predeterminada\n```js\nDEF.currencies.usd = function(value) {\n\treturn '$' + value.format(2);\n};\n\nDEF.currency = 'usd';\nconsole.log((5).currency()); // $5.00\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nEl formato predeterminado de `Date.format()` y del análisis de fechas.\n\nReturns: `String` Valor predeterminado: `'yyyy-MM-dd'`.\n\nConsulta [Date](../date/).\n\nExample: Cambiar el formato\n```js\nDEF.dateformat = 'dd.MM.yyyy';\nconsole.log(new Date(2024, 0, 15).format()); // 15.01.2024\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nDa formato a todas las fechas en UTC.\n\nReturns: `Boolean` Valor predeterminado: `false`.\n\nSe aplica a `Date.format()`. Consulta [Date](../date/).\n\nExample: Dar formato en UTC\n```js\nDEF.dateformatutc = true;\nconsole.log(new Date(Date.UTC(2024, 0, 15, 12, 30)).format('HH:mm')); // 12:30\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nEl separador decimal de los números con formato.\n\nReturns: `String` Valor predeterminado: `'.'`.\n\nLo usan `Number.format()` y el análisis de números. Consulta [Number](../number/).\n\nExample: Usar la coma decimal\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }\n\nType: `config`\n\nLos rangos de ancho de los tamaños de dispositivo.\n\nReturns: `Object` Valor predeterminado: `{ xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }`.\n\nLos rangos los usan [WIDTH()](../globals/) y las clases `jc-xs`, `jc-sm`, `jc-md` y `jc-lg` del body.\n\nExample: Leer un rango\n```js\nconsole.log(DEF.devices.md); // {\"min\":992,\"max\":1200}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nLas traducciones cargadas con `LOCALIZE()`.\n\nReturns: `Object` Valor predeterminado: `{}`.\n\nConsulta [Localización](../../guides/localization/).\n\nExample: Leer el diccionario\n```js\nLOCALIZE('Tabc : Hola');\nconsole.log(DEF.dictionary.Tabc); // Hola\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nEl texto que se muestra para un valor vacío.\n\nReturns: `String` Valor predeterminado: `'---'`.\n\nLo usan el comando `empty` de [ui-bind](../ui-bind/) y el [helper de Tangular](../tangular-helpers/) `empty`.\n\nExample: Leer el texto\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }\n\nType: `config`\n\nLas variables de entorno.\n\nReturns: `Object` Valor predeterminado: `{ ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }`.\n\nLas variables se gestionan con [ENV()](../globals/). Los valores predeterminados se pueden usar como formatos de fecha, por ejemplo `[ts]`.\n\nExample: Usar una variable como formato de fecha\n```js\nvar date = new Date(2024, 0, 15, 8, 5);\nconsole.log(date.format('[ts]')); // 2024-01-15 - 08:05\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nLa dirección desde la que se descargan los componentes desconocidos.\n\nReturns: `String` Valor predeterminado: `'https://cdn.componentator.com/j-{0}.html'`.\n\nLa palabra clave `{0}` se convierte en el nombre del componente. El atributo `source` de [ui-component](../ui-component/) la sobrescribe.\n\nExample: Leer la dirección\n```js\nconsole.log(DEF.fallback.format('input')); // https://cdn.componentator.com/j-input.html\n```\n\n### DEF.firstdayofweek = 1\n\nType: `config`\n\nEl primer día de la semana, para los componentes que muestran un calendario.\n\nReturns: `Number` Valor predeterminado: `1`.\n\nEl valor `0` es el domingo y `1` es el lunes. La biblioteca solo lo guarda.\n\nExample: Empezar la semana en domingo\n```js\nDEF.firstdayofweek = 0;\nconsole.log(DAYS[DEF.firstdayofweek]); // Sunday\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nLas cabeceras que se añaden a cada petición `AJAX()`.\n\nReturns: `Object` Valor predeterminado: `{ 'X-Requested-With': 'XMLHttpRequest' }`.\n\nExample: Añadir una cabecera\n```js\nDEF.headers['x-token'] = '123456';\nconsole.log(DEF.headers['x-token']); // 123456\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nEl prefijo que `component.icon()` añade a los nombres de los iconos.\n\nReturns: `String` Valor predeterminado: `'ti ti-'`.\n\nUn valor que contiene un espacio se usa tal cual. Consulta [Component](../component/).\n\nExample: Cambiar el prefijo\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tDEF.iconprefix = 'fa fa-';\n\t\tconsole.log(self.icon('home')); // fa fa-home\n\t};\n});\n</script>\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nEl idioma que se añade a la cadena de consulta de cada petición `AJAX()`.\n\nReturns: `String` Valor predeterminado: `undefined`.\n\nEl nombre del parámetro está en [DEF.languagekey](../def/). [ENVIRONMENT()](../globals/) puede establecer este valor.\n\nExample: Establecer el idioma\n```js\nDEF.language = 'en';\nconsole.log(DEF.language); // en\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nEl nombre del parámetro de consulta que lleva el idioma.\n\nReturns: `String` Valor predeterminado: `'language'`.\n\nExample: Leer el nombre\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nLa clave de `localStorage` de la caché.\n\nReturns: `String` Valor predeterminado: `'jc'`.\n\n[ENVIRONMENT()](../globals/) puede establecer este valor.\n\nExample: Leer la clave\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.onstorageread = function(callback)\n\nType: `config`\n\nCarga la caché persistente cuando arranca la biblioteca.\n\nReturns: `Function` Valor predeterminado: `function(callback)`.\n\nAsigna tu propia función justo después del script de la biblioteca. Debe llamar a `callback` con el objeto guardado. La función predeterminada lee `localStorage`.\n\nExample: Proporcionar los datos guardados\n```js\nDEF.onstorageread = function(callback) {\n\tcallback({});\n};\n\nON('ready', function() {\n\tconsole.log('loaded'); // loaded\n});\n```\n\n### DEF.onstoragesave = function(data)\n\nType: `config`\n\nGuarda la caché persistente.\n\nReturns: `Function` Valor predeterminado: `function(data)`.\n\nLa función recibe un objeto con todos los elementos que tienen caducidad. La función predeterminada escribe en `localStorage`.\n\nExample: Observar el guardado\n```js\nDEF.onstoragesave = function(data) {\n\tconsole.log(Object.keys(data).length); // 1\n};\n\nON('ready', function() {\n\tCACHE('filter', 1, '1 day');\n});\n```\n\n### DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }\n\nType: `config`\n\nLos destinos de los prefijos cortos de path.\n\nReturns: `Object` Valor predeterminado: `{ common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }`.\n\n`common` es el destino de `*`, `cl` el de `#` y `tmp` el de `%`. `plugins` contiene los datos de los plugins con un path generado. La función `DEF.path.clean(name)` devuelve un valor sin el punto final. Consulta [Paths](../../guides/paths/).\n\nExample: Leer un prefijo\n```js\nconsole.log(DEF.path.common); // common.\nconsole.log(DEF.path.clean('common')); // common\n```\n\n### DEF.pipe = undefined\n\nType: `config`\n\nLa dirección que usa `PIPE()`.\n\nReturns: `String` Valor predeterminado: `undefined`.\n\nAsígnala para usar [PIPE()](../globals/).\n\nExample: Establecer el endpoint\n```js\nDEF.pipe = '/pipe/';\nconsole.log(DEF.pipe); // /pipe/\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nEl prefijo de la clase CSS que un componente recibe como `cls`.\n\nReturns: `String` Valor predeterminado: `'ui-'`.\n\nExample: Cambiar el prefijo\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nDEF.prefixcsscomponents = 'my-';\n\nCOMPONENT('box', function(self, config, cls) {\n\tconsole.log(cls); // my-box\n});\n</script>\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nEl prefijo de las clases CSS que crea la biblioteca.\n\nReturns: `String` Valor predeterminado: `'ui-'`.\n\nLo usan [APPEARANCE()](../globals/) y [SCROLLBAR()](../globals/).\n\nExample: Cambiar el prefijo\n```js\nDEF.prefixcsslibrary = 'app-';\nAPPEARANCE({ dark: true });\nconsole.log($('body').hclass('app-dark')); // true\n```\n\n### DEF.regexp = { int, float, date, pluralize, format, url, phone, email }\n\nType: `config`\n\nLas expresiones regulares que usan los helpers.\n\nReturns: `Object` Valor predeterminado: `{ int, float, date, pluralize, format, url, phone, email }`.\n\nPor ejemplo, `String.isEmail()` usa `DEF.regexp.email`. Consulta [String](../string/).\n\nExample: Validar una dirección de correo electrónico\n```js\nconsole.log(DEF.regexp.email.test('info@example.com')); // true\nconsole.log('invalid'.isEmail()); // false\n```\n\n### DEF.root = ''\n\nType: `config`\n\nEl prefijo que `String.ROOT()` añade a cada dirección relativa.\n\nReturns: `String|Function` Valor predeterminado: `''`.\n\nTiene prioridad sobre [DEF.baseurl](../def/), y `ROOT(true)` aplica solo este valor. Consulta [String](../string/).\n\nExample: Añadir un prefijo a una dirección\n```js\nDEF.root = '/admin';\nconsole.log('/users/'.ROOT()); // /admin/users/\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnima la barra de una barra de desplazamiento personalizada en los bordes del área de desplazamiento.\n\nReturns: `Boolean` Valor predeterminado: `true`.\n\nConsulta [SCROLLBAR()](../globals/).\n\nExample: Desactivar la animación\n```js\nDEF.scrollbaranimate = false;\nconsole.log(DEF.scrollbaranimate); // false\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nEl separador de miles de los números con formato.\n\nReturns: `String` Valor predeterminado: `' '`.\n\nLo usan `Number.format()` y el análisis de números. Consulta [Number](../number/).\n\nExample: Usar una coma\n```js\nDEF.thousandsseparator = ',';\nconsole.log((1234567).format(0)); // 1,234,567\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nEl formato de hora que se copia en las variables de entorno al arrancar.\n\nReturns: `String` Valor predeterminado: `'HH:mm'`.\n\nPara cambiar el formato más adelante, escribe las variables `time` y `ts` con [ENV()](../globals/).\n\nExample: Leer el formato\n```js\nconsole.log(DEF.timeformat); // HH:mm\nconsole.log(ENV('time')); // HH:mm\n```\n\n### DEF.tmp = {}\n\nType: `config`\n\nEl almacén de paths temporales.\n\nReturns: `Object` Valor predeterminado: `{}`.\n\nEl prefijo de path `%` apunta aquí, así que `%form` es `DEF.tmp.form`. Consulta [Paths](../../guides/paths/).\n\nExample: Escribir un valor temporal\n```js\nSET('%search', 'phone');\nconsole.log(DEF.tmp.search); // phone\n```\n\n### DEF.version = undefined\n\nType: `config`\n\nLa versión que se añade a las direcciones `.html` solicitadas con `AJAX()`.\n\nReturns: `String` Valor predeterminado: `undefined`.\n\nEl nombre del parámetro está en [DEF.versionkey](../def/). [ENVIRONMENT()](../globals/) puede establecer este valor.\n\nExample: Establecer la versión\n```js\nDEF.version = '1.0';\nconsole.log(DEF.version); // 1.0\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nLa versión de las direcciones `.html` cuando `DEF.version` está vacío.\n\nReturns: `String` Valor predeterminado: `undefined`.\n\nExample: Establecer la versión de los archivos HTML\n```js\nDEF.versionhtml = '2';\nconsole.log(DEF.versionhtml); // 2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nEl nombre del parámetro de consulta que lleva la versión.\n\nReturns: `String` Valor predeterminado: `'version'`.\n\nExample: Leer el nombre\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.warnings = false\n\nType: `config`\n\nMuestra en la consola las advertencias de la biblioteca.\n\nReturns: `Boolean` Valor predeterminado: `false`.\n\nActívalo durante el desarrollo, por ejemplo para que te avise de un método que no se ha encontrado.\n\nExample: Activar las advertencias\n```js\nDEF.warnings = true;\nconsole.log(DEF.warnings); // true\n```\n","entries":[{"type":"config","name":"DEF.api","signature":"DEF.api = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.baseurl","signature":"DEF.baseurl = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cdn","signature":"DEF.cdn = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cl","signature":"DEF.cl = {}","since":"","deprecated":false},{"type":"config","name":"DEF.color","signature":"DEF.color = '#4285F4'","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = ''","since":"","deprecated":false},{"type":"config","name":"DEF.dateformat","signature":"DEF.dateformat = 'yyyy-MM-dd'","since":"","deprecated":false},{"type":"config","name":"DEF.dateformatutc","signature":"DEF.dateformatutc = false","since":"","deprecated":false},{"type":"config","name":"DEF.decimalseparator","signature":"DEF.decimalseparator = '.'","since":"","deprecated":false},{"type":"config","name":"DEF.devices","signature":"DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }","since":"","deprecated":false},{"type":"config","name":"DEF.dictionary","signature":"DEF.dictionary = {}","since":"","deprecated":false},{"type":"config","name":"DEF.empty","signature":"DEF.empty = '---'","since":"","deprecated":false},{"type":"config","name":"DEF.env","signature":"DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }","since":"","deprecated":false},{"type":"config","name":"DEF.fallback","signature":"DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'","since":"","deprecated":false},{"type":"config","name":"DEF.firstdayofweek","signature":"DEF.firstdayofweek = 1","since":"","deprecated":false},{"type":"config","name":"DEF.headers","signature":"DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }","since":"","deprecated":false},{"type":"config","name":"DEF.iconprefix","signature":"DEF.iconprefix = 'ti ti-'","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagekey","signature":"DEF.languagekey = 'language'","since":"","deprecated":false},{"type":"config","name":"DEF.localstorage","signature":"DEF.localstorage = 'jc'","since":"","deprecated":false},{"type":"config","name":"DEF.onstorageread","signature":"DEF.onstorageread = function(callback)","since":"","deprecated":false},{"type":"config","name":"DEF.onstoragesave","signature":"DEF.onstoragesave = function(data)","since":"","deprecated":false},{"type":"config","name":"DEF.path","signature":"DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }","since":"","deprecated":false},{"type":"config","name":"DEF.pipe","signature":"DEF.pipe = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsscomponents","signature":"DEF.prefixcsscomponents = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsslibrary","signature":"DEF.prefixcsslibrary = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format, url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.thousandsseparator","signature":"DEF.thousandsseparator = ' '","since":"","deprecated":false},{"type":"config","name":"DEF.timeformat","signature":"DEF.timeformat = 'HH:mm'","since":"","deprecated":false},{"type":"config","name":"DEF.tmp","signature":"DEF.tmp = {}","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionhtml","signature":"DEF.versionhtml = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionkey","signature":"DEF.versionkey = 'version'","since":"","deprecated":false},{"type":"config","name":"DEF.warnings","signature":"DEF.warnings = false","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcQb5Qd61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/def/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"DEF","summary":"Les paramètres par défaut de la bibliothèque.","markdown":"---\ntitle: DEF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/def/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# DEF\n\n> Les paramètres par défaut de la bibliothèque.\n\n`DEF` contient les paramètres par défaut de la bibliothèque. Assigne les valeurs juste après le script de la bibliothèque, pour qu'elles s'appliquent dès le départ. [Premiers pas](../../guides/getting-started/) montre où placer ce code.\n\n## API\n\n### DEF.api = undefined\n\nType: `config`\n\nL'adresse utilisée par `TAPI()`.\n\nReturns: `String` Valeur par défaut : `undefined`.\n\nAssigne-la pour utiliser [TAPI()](../globals/).\n\nExample: Définir le point de terminaison\n```js\nDEF.api = '/admin/api/';\nconsole.log(DEF.api); // /admin/api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nLe préfixe que `String.ROOT()` ajoute aux adresses relatives.\n\nReturns: `String|Function` Valeur par défaut : `''`.\n\nUne fonction reçoit l'adresse et renvoie l'adresse finale. [DEF.root](../def/) est prioritaire. Consulte [String](../string/).\n\nExample: Préfixer une adresse\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nLa valeur du mot-clé `~CDN~` dans le contenu importé.\n\nReturns: `String` Valeur par défaut : `''`.\n\nLe mot-clé est remplacé par [ADAPT()](../globals/).\n\nExample: Utiliser le mot-clé\n```js\nDEF.cdn = 'https://cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/logo.png')); // https://cdn.example.com/logo.png\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nLes listes de codes chargées.\n\nReturns: `Object` Valeur par défaut : `{}`.\n\nLe préfixe de path `#` pointe ici : `#countries` correspond donc à `DEF.cl.countries`. Consulte [CL()](../globals/).\n\nExample: Lire une liste par son path\n```js\nSET('#colors', ['red']);\nconsole.log(DEF.cl.colors); // [\"red\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nLa couleur d'accent de l'application.\n\nReturns: `String` Valeur par défaut : `'#4285F4'`.\n\n[APPEARANCE()](../globals/) la met à jour.\n\nExample: Changer la couleur\n```js\nAPPEARANCE({ color: '#FF0000' });\nconsole.log(DEF.color); // #FF0000\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nLes formateurs utilisés par `Number.currency()`.\n\nReturns: `Object` Valeur par défaut : `{}`.\n\nChaque clé est un nom de devise et chaque valeur une fonction qui reçoit le nombre. Consulte [Number](../number/).\n\nExample: Définir une devise\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\nconsole.log((10).currency('eur')); // 10.00 EUR\n```\n\n### DEF.currency = ''\n\nType: `config`\n\nLa devise par défaut de `Number.currency()`.\n\nReturns: `String` Valeur par défaut : `''`.\n\nExample: Définir la devise par défaut\n```js\nDEF.currencies.usd = function(value) {\n\treturn '$' + value.format(2);\n};\n\nDEF.currency = 'usd';\nconsole.log((5).currency()); // $5.00\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nLe format par défaut de `Date.format()` et de l'analyse des dates.\n\nReturns: `String` Valeur par défaut : `'yyyy-MM-dd'`.\n\nConsulte [Date](../date/).\n\nExample: Changer le format\n```js\nDEF.dateformat = 'dd.MM.yyyy';\nconsole.log(new Date(2024, 0, 15).format()); // 15.01.2024\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nFormate toutes les dates en UTC.\n\nReturns: `Boolean` Valeur par défaut : `false`.\n\nS'applique à `Date.format()`. Consulte [Date](../date/).\n\nExample: Formater en UTC\n```js\nDEF.dateformatutc = true;\nconsole.log(new Date(Date.UTC(2024, 0, 15, 12, 30)).format('HH:mm')); // 12:30\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nLe séparateur décimal des nombres formatés.\n\nReturns: `String` Valeur par défaut : `'.'`.\n\nIl est utilisé par `Number.format()` et lors de l'analyse des nombres. Consulte [Number](../number/).\n\nExample: Utiliser une virgule décimale\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }\n\nType: `config`\n\nLes plages de largeur des tailles d'appareil.\n\nReturns: `Object` Valeur par défaut : `{ xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }`.\n\nLes plages sont utilisées par [WIDTH()](../globals/) et par les classes `jc-xs`, `jc-sm`, `jc-md` et `jc-lg` du body.\n\nExample: Lire une plage\n```js\nconsole.log(DEF.devices.md); // {\"min\":992,\"max\":1200}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nLes traductions chargées avec `LOCALIZE()`.\n\nReturns: `Object` Valeur par défaut : `{}`.\n\nConsulte [Localisation](../../guides/localization/).\n\nExample: Lire le dictionnaire\n```js\nLOCALIZE('Tabc : Hola');\nconsole.log(DEF.dictionary.Tabc); // Hola\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nLe texte affiché pour une valeur vide.\n\nReturns: `String` Valeur par défaut : `'---'`.\n\nIl est utilisé par la commande `empty` de [ui-bind](../ui-bind/) et par le [helper Tangular](../tangular-helpers/) `empty`.\n\nExample: Lire le texte\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }\n\nType: `config`\n\nLes variables d'environnement.\n\nReturns: `Object` Valeur par défaut : `{ ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }`.\n\nLes variables sont gérées avec [ENV()](../globals/). Les valeurs par défaut peuvent servir de formats de date, par exemple `[ts]`.\n\nExample: Utiliser une variable comme format de date\n```js\nvar date = new Date(2024, 0, 15, 8, 5);\nconsole.log(date.format('[ts]')); // 2024-01-15 - 08:05\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nL'adresse depuis laquelle les composants inconnus sont téléchargés.\n\nReturns: `String` Valeur par défaut : `'https://cdn.componentator.com/j-{0}.html'`.\n\nLe mot-clé `{0}` devient le nom du composant. L'attribut `source` de [ui-component](../ui-component/) la remplace.\n\nExample: Lire l'adresse\n```js\nconsole.log(DEF.fallback.format('input')); // https://cdn.componentator.com/j-input.html\n```\n\n### DEF.firstdayofweek = 1\n\nType: `config`\n\nLe premier jour de la semaine, pour les composants qui affichent un calendrier.\n\nReturns: `Number` Valeur par défaut : `1`.\n\nLa valeur `0` correspond au dimanche et `1` au lundi. La bibliothèque se contente de la stocker.\n\nExample: Commencer la semaine le dimanche\n```js\nDEF.firstdayofweek = 0;\nconsole.log(DAYS[DEF.firstdayofweek]); // Sunday\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nLes en-têtes ajoutés à chaque requête `AJAX()`.\n\nReturns: `Object` Valeur par défaut : `{ 'X-Requested-With': 'XMLHttpRequest' }`.\n\nExample: Ajouter un en-tête\n```js\nDEF.headers['x-token'] = '123456';\nconsole.log(DEF.headers['x-token']); // 123456\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nLe préfixe ajouté aux noms d'icônes par `component.icon()`.\n\nReturns: `String` Valeur par défaut : `'ti ti-'`.\n\nUne valeur contenant une espace est utilisée telle quelle. Consulte [Component](../component/).\n\nExample: Changer le préfixe\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tDEF.iconprefix = 'fa fa-';\n\t\tconsole.log(self.icon('home')); // fa fa-home\n\t};\n});\n</script>\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nLa langue ajoutée à la chaîne de requête de chaque requête `AJAX()`.\n\nReturns: `String` Valeur par défaut : `undefined`.\n\nLe nom du paramètre se trouve dans [DEF.languagekey](../def/). [ENVIRONMENT()](../globals/) peut définir cette valeur.\n\nExample: Définir la langue\n```js\nDEF.language = 'en';\nconsole.log(DEF.language); // en\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nLe nom du paramètre de requête qui transporte la langue.\n\nReturns: `String` Valeur par défaut : `'language'`.\n\nExample: Lire le nom\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nLa clé `localStorage` du cache.\n\nReturns: `String` Valeur par défaut : `'jc'`.\n\n[ENVIRONMENT()](../globals/) peut définir cette valeur.\n\nExample: Lire la clé\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.onstorageread = function(callback)\n\nType: `config`\n\nCharge le cache persistant au démarrage de la bibliothèque.\n\nReturns: `Function` Valeur par défaut : `function(callback)`.\n\nAssigne ta propre fonction juste après le script de la bibliothèque. Elle doit appeler `callback` avec l'objet stocké. La fonction par défaut lit `localStorage`.\n\nExample: Fournir les données stockées\n```js\nDEF.onstorageread = function(callback) {\n\tcallback({});\n};\n\nON('ready', function() {\n\tconsole.log('loaded'); // loaded\n});\n```\n\n### DEF.onstoragesave = function(data)\n\nType: `config`\n\nEnregistre le cache persistant.\n\nReturns: `Function` Valeur par défaut : `function(data)`.\n\nLa fonction reçoit un objet contenant tous les éléments qui ont une expiration. La fonction par défaut écrit dans `localStorage`.\n\nExample: Observer l'enregistrement\n```js\nDEF.onstoragesave = function(data) {\n\tconsole.log(Object.keys(data).length); // 1\n};\n\nON('ready', function() {\n\tCACHE('filter', 1, '1 day');\n});\n```\n\n### DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }\n\nType: `config`\n\nLes cibles des préfixes de path courts.\n\nReturns: `Object` Valeur par défaut : `{ common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }`.\n\n`common` est la cible de `*`, `cl` celle de `#` et `tmp` celle de `%`. `plugins` contient les données des plugins dont le path est généré. La fonction `DEF.path.clean(name)` renvoie une valeur sans le point final. Consulte [Paths](../../guides/paths/).\n\nExample: Lire un préfixe\n```js\nconsole.log(DEF.path.common); // common.\nconsole.log(DEF.path.clean('common')); // common\n```\n\n### DEF.pipe = undefined\n\nType: `config`\n\nL'adresse utilisée par `PIPE()`.\n\nReturns: `String` Valeur par défaut : `undefined`.\n\nAssigne-la pour utiliser [PIPE()](../globals/).\n\nExample: Définir le point de terminaison\n```js\nDEF.pipe = '/pipe/';\nconsole.log(DEF.pipe); // /pipe/\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nLe préfixe de la classe CSS qu'un composant reçoit dans `cls`.\n\nReturns: `String` Valeur par défaut : `'ui-'`.\n\nExample: Changer le préfixe\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nDEF.prefixcsscomponents = 'my-';\n\nCOMPONENT('box', function(self, config, cls) {\n\tconsole.log(cls); // my-box\n});\n</script>\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nLe préfixe des classes CSS créées par la bibliothèque.\n\nReturns: `String` Valeur par défaut : `'ui-'`.\n\nIl est utilisé par [APPEARANCE()](../globals/) et [SCROLLBAR()](../globals/).\n\nExample: Changer le préfixe\n```js\nDEF.prefixcsslibrary = 'app-';\nAPPEARANCE({ dark: true });\nconsole.log($('body').hclass('app-dark')); // true\n```\n\n### DEF.regexp = { int, float, date, pluralize, format, url, phone, email }\n\nType: `config`\n\nLes expressions régulières utilisées par les helpers.\n\nReturns: `Object` Valeur par défaut : `{ int, float, date, pluralize, format, url, phone, email }`.\n\nPar exemple, `String.isEmail()` utilise `DEF.regexp.email`. Consulte [String](../string/).\n\nExample: Valider une adresse e-mail\n```js\nconsole.log(DEF.regexp.email.test('info@example.com')); // true\nconsole.log('invalid'.isEmail()); // false\n```\n\n### DEF.root = ''\n\nType: `config`\n\nLe préfixe que `String.ROOT()` ajoute à chaque adresse relative.\n\nReturns: `String|Function` Valeur par défaut : `''`.\n\nIl est prioritaire sur [DEF.baseurl](../def/), et `ROOT(true)` n'applique que cette valeur. Consulte [String](../string/).\n\nExample: Préfixer une adresse\n```js\nDEF.root = '/admin';\nconsole.log('/users/'.ROOT()); // /admin/users/\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnime la barre d'une barre de défilement personnalisée aux bords de la zone de défilement.\n\nReturns: `Boolean` Valeur par défaut : `true`.\n\nConsulte [SCROLLBAR()](../globals/).\n\nExample: Désactiver l'animation\n```js\nDEF.scrollbaranimate = false;\nconsole.log(DEF.scrollbaranimate); // false\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nLe séparateur des milliers des nombres formatés.\n\nReturns: `String` Valeur par défaut : `' '`.\n\nIl est utilisé par `Number.format()` et lors de l'analyse des nombres. Consulte [Number](../number/).\n\nExample: Utiliser une virgule\n```js\nDEF.thousandsseparator = ',';\nconsole.log((1234567).format(0)); // 1,234,567\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nLe format de l'heure copié dans les variables d'environnement au démarrage.\n\nReturns: `String` Valeur par défaut : `'HH:mm'`.\n\nPour changer le format plus tard, écris les variables `time` et `ts` avec [ENV()](../globals/).\n\nExample: Lire le format\n```js\nconsole.log(DEF.timeformat); // HH:mm\nconsole.log(ENV('time')); // HH:mm\n```\n\n### DEF.tmp = {}\n\nType: `config`\n\nLe stockage des paths temporaires.\n\nReturns: `Object` Valeur par défaut : `{}`.\n\nLe préfixe de path `%` pointe ici : `%form` correspond donc à `DEF.tmp.form`. Voir [Paths](../../guides/paths/).\n\nExample: Écrire une valeur temporaire\n```js\nSET('%search', 'phone');\nconsole.log(DEF.tmp.search); // phone\n```\n\n### DEF.version = undefined\n\nType: `config`\n\nLa version ajoutée aux adresses `.html` demandées avec `AJAX()`.\n\nReturns: `String` Valeur par défaut : `undefined`.\n\nLe nom du paramètre se trouve dans [DEF.versionkey](../def/). [ENVIRONMENT()](../globals/) peut définir cette valeur.\n\nExample: Définir la version\n```js\nDEF.version = '1.0';\nconsole.log(DEF.version); // 1.0\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nLa version des adresses `.html` quand `DEF.version` est vide.\n\nReturns: `String` Valeur par défaut : `undefined`.\n\nExample: Définir la version des fichiers HTML\n```js\nDEF.versionhtml = '2';\nconsole.log(DEF.versionhtml); // 2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nLe nom du paramètre de requête qui porte la version.\n\nReturns: `String` Valeur par défaut : `'version'`.\n\nExample: Lire le nom\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.warnings = false\n\nType: `config`\n\nAffiche les avertissements de la bibliothèque dans la console.\n\nReturns: `Boolean` Valeur par défaut : `false`.\n\nActive-le pendant le développement, par exemple pour signaler une méthode introuvable.\n\nExample: Activer les avertissements\n```js\nDEF.warnings = true;\nconsole.log(DEF.warnings); // true\n```\n","entries":[{"type":"config","name":"DEF.api","signature":"DEF.api = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.baseurl","signature":"DEF.baseurl = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cdn","signature":"DEF.cdn = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cl","signature":"DEF.cl = {}","since":"","deprecated":false},{"type":"config","name":"DEF.color","signature":"DEF.color = '#4285F4'","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = ''","since":"","deprecated":false},{"type":"config","name":"DEF.dateformat","signature":"DEF.dateformat = 'yyyy-MM-dd'","since":"","deprecated":false},{"type":"config","name":"DEF.dateformatutc","signature":"DEF.dateformatutc = false","since":"","deprecated":false},{"type":"config","name":"DEF.decimalseparator","signature":"DEF.decimalseparator = '.'","since":"","deprecated":false},{"type":"config","name":"DEF.devices","signature":"DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }","since":"","deprecated":false},{"type":"config","name":"DEF.dictionary","signature":"DEF.dictionary = {}","since":"","deprecated":false},{"type":"config","name":"DEF.empty","signature":"DEF.empty = '---'","since":"","deprecated":false},{"type":"config","name":"DEF.env","signature":"DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }","since":"","deprecated":false},{"type":"config","name":"DEF.fallback","signature":"DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'","since":"","deprecated":false},{"type":"config","name":"DEF.firstdayofweek","signature":"DEF.firstdayofweek = 1","since":"","deprecated":false},{"type":"config","name":"DEF.headers","signature":"DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }","since":"","deprecated":false},{"type":"config","name":"DEF.iconprefix","signature":"DEF.iconprefix = 'ti ti-'","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagekey","signature":"DEF.languagekey = 'language'","since":"","deprecated":false},{"type":"config","name":"DEF.localstorage","signature":"DEF.localstorage = 'jc'","since":"","deprecated":false},{"type":"config","name":"DEF.onstorageread","signature":"DEF.onstorageread = function(callback)","since":"","deprecated":false},{"type":"config","name":"DEF.onstoragesave","signature":"DEF.onstoragesave = function(data)","since":"","deprecated":false},{"type":"config","name":"DEF.path","signature":"DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }","since":"","deprecated":false},{"type":"config","name":"DEF.pipe","signature":"DEF.pipe = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsscomponents","signature":"DEF.prefixcsscomponents = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsslibrary","signature":"DEF.prefixcsslibrary = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format, url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.thousandsseparator","signature":"DEF.thousandsseparator = ' '","since":"","deprecated":false},{"type":"config","name":"DEF.timeformat","signature":"DEF.timeformat = 'HH:mm'","since":"","deprecated":false},{"type":"config","name":"DEF.tmp","signature":"DEF.tmp = {}","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionhtml","signature":"DEF.versionhtml = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionkey","signature":"DEF.versionkey = 'version'","since":"","deprecated":false},{"type":"config","name":"DEF.warnings","signature":"DEF.warnings = false","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcQb5Qd61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/def/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"DEF","summary":"Le impostazioni predefinite della libreria.","markdown":"---\ntitle: DEF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/def/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# DEF\n\n> Le impostazioni predefinite della libreria.\n\n`DEF` contiene le impostazioni predefinite della libreria. Assegna i valori subito dopo lo script della libreria, così si applicano fin dall'inizio. [Primi passi](../../guides/getting-started/) mostra dove inserire questo codice.\n\n## API\n\n### DEF.api = undefined\n\nType: `config`\n\nL'indirizzo usato da `TAPI()`.\n\nReturns: `String` Valore predefinito: `undefined`.\n\nAssegnalo per usare [TAPI()](../globals/).\n\nExample: Imposta l'endpoint\n```js\nDEF.api = '/admin/api/';\nconsole.log(DEF.api); // /admin/api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nIl prefisso che `String.ROOT()` aggiunge agli indirizzi relativi.\n\nReturns: `String|Function` Valore predefinito: `''`.\n\nUna funzione riceve l'indirizzo e restituisce l'indirizzo finale. [DEF.root](../def/) ha la precedenza. Consulta [String](../string/).\n\nExample: Aggiungi un prefisso a un indirizzo\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nIl valore della parola chiave `~CDN~` nei contenuti importati.\n\nReturns: `String` Valore predefinito: `''`.\n\nLa parola chiave viene sostituita da [ADAPT()](../globals/).\n\nExample: Usa la parola chiave\n```js\nDEF.cdn = 'https://cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/logo.png')); // https://cdn.example.com/logo.png\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nGli elenchi di codici caricati.\n\nReturns: `Object` Valore predefinito: `{}`.\n\nIl prefisso di path `#` punta qui, quindi `#countries` è `DEF.cl.countries`. Consulta [CL()](../globals/).\n\nExample: Leggi un elenco tramite il suo path\n```js\nSET('#colors', ['red']);\nconsole.log(DEF.cl.colors); // [\"red\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nIl colore di accento dell'app.\n\nReturns: `String` Valore predefinito: `'#4285F4'`.\n\n[APPEARANCE()](../globals/) lo aggiorna.\n\nExample: Cambia il colore\n```js\nAPPEARANCE({ color: '#FF0000' });\nconsole.log(DEF.color); // #FF0000\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nI formattatori usati da `Number.currency()`.\n\nReturns: `Object` Valore predefinito: `{}`.\n\nOgni chiave è il nome di una valuta e ogni valore è una funzione che riceve il numero. Consulta [Number](../number/).\n\nExample: Definisci una valuta\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\nconsole.log((10).currency('eur')); // 10.00 EUR\n```\n\n### DEF.currency = ''\n\nType: `config`\n\nLa valuta predefinita di `Number.currency()`.\n\nReturns: `String` Valore predefinito: `''`.\n\nExample: Imposta la valuta predefinita\n```js\nDEF.currencies.usd = function(value) {\n\treturn '$' + value.format(2);\n};\n\nDEF.currency = 'usd';\nconsole.log((5).currency()); // $5.00\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nIl formato predefinito di `Date.format()` e dell'analisi delle date.\n\nReturns: `String` Valore predefinito: `'yyyy-MM-dd'`.\n\nConsulta [Date](../date/).\n\nExample: Cambia il formato\n```js\nDEF.dateformat = 'dd.MM.yyyy';\nconsole.log(new Date(2024, 0, 15).format()); // 15.01.2024\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nFormatta tutte le date in UTC.\n\nReturns: `Boolean` Valore predefinito: `false`.\n\nSi applica a `Date.format()`. Consulta [Date](../date/).\n\nExample: Formatta in UTC\n```js\nDEF.dateformatutc = true;\nconsole.log(new Date(Date.UTC(2024, 0, 15, 12, 30)).format('HH:mm')); // 12:30\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nIl separatore decimale dei numeri formattati.\n\nReturns: `String` Valore predefinito: `'.'`.\n\nViene usato da `Number.format()` e durante l'analisi dei numeri. Consulta [Number](../number/).\n\nExample: Usa la virgola decimale\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }\n\nType: `config`\n\nGli intervalli di larghezza delle dimensioni dei dispositivi.\n\nReturns: `Object` Valore predefinito: `{ xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }`.\n\nGli intervalli vengono usati da [WIDTH()](../globals/) e dalle classi del body `jc-xs`, `jc-sm`, `jc-md` e `jc-lg`.\n\nExample: Leggi un intervallo\n```js\nconsole.log(DEF.devices.md); // {\"min\":992,\"max\":1200}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nLe traduzioni caricate con `LOCALIZE()`.\n\nReturns: `Object` Valore predefinito: `{}`.\n\nConsulta [Localizzazione](../../guides/localization/).\n\nExample: Leggi il dizionario\n```js\nLOCALIZE('Tabc : Hola');\nconsole.log(DEF.dictionary.Tabc); // Hola\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nIl testo visualizzato per un valore vuoto.\n\nReturns: `String` Valore predefinito: `'---'`.\n\nViene usato dal comando `empty` di [ui-bind](../ui-bind/) e dall'[helper di Tangular](../tangular-helpers/) `empty`.\n\nExample: Leggi il testo\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }\n\nType: `config`\n\nLe variabili d'ambiente.\n\nReturns: `Object` Valore predefinito: `{ ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }`.\n\nLe variabili vengono gestite con [ENV()](../globals/). I valori predefiniti possono essere usati come formati di data, ad esempio `[ts]`.\n\nExample: Usa una variabile come formato di data\n```js\nvar date = new Date(2024, 0, 15, 8, 5);\nconsole.log(date.format('[ts]')); // 2024-01-15 - 08:05\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nL'indirizzo da cui vengono scaricati i componenti sconosciuti.\n\nReturns: `String` Valore predefinito: `'https://cdn.componentator.com/j-{0}.html'`.\n\nLa parola chiave `{0}` diventa il nome del componente. L'attributo `source` di [ui-component](../ui-component/) lo sovrascrive.\n\nExample: Leggi l'indirizzo\n```js\nconsole.log(DEF.fallback.format('input')); // https://cdn.componentator.com/j-input.html\n```\n\n### DEF.firstdayofweek = 1\n\nType: `config`\n\nIl primo giorno della settimana, per i componenti che mostrano un calendario.\n\nReturns: `Number` Valore predefinito: `1`.\n\nIl valore `0` è la domenica e `1` è il lunedì. La libreria si limita a conservarlo.\n\nExample: Inizia la settimana di domenica\n```js\nDEF.firstdayofweek = 0;\nconsole.log(DAYS[DEF.firstdayofweek]); // Sunday\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nLe intestazioni aggiunte a ogni richiesta `AJAX()`.\n\nReturns: `Object` Valore predefinito: `{ 'X-Requested-With': 'XMLHttpRequest' }`.\n\nExample: Aggiungi un'intestazione\n```js\nDEF.headers['x-token'] = '123456';\nconsole.log(DEF.headers['x-token']); // 123456\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nIl prefisso aggiunto ai nomi delle icone da `component.icon()`.\n\nReturns: `String` Valore predefinito: `'ti ti-'`.\n\nUn valore che contiene uno spazio viene usato così com'è. Consulta [Component](../component/).\n\nExample: Cambia il prefisso\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tDEF.iconprefix = 'fa fa-';\n\t\tconsole.log(self.icon('home')); // fa fa-home\n\t};\n});\n</script>\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nLa lingua aggiunta alla stringa di query di ogni richiesta `AJAX()`.\n\nReturns: `String` Valore predefinito: `undefined`.\n\nIl nome del parametro si trova in [DEF.languagekey](../def/). [ENVIRONMENT()](../globals/) può impostare questo valore.\n\nExample: Imposta la lingua\n```js\nDEF.language = 'en';\nconsole.log(DEF.language); // en\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nIl nome del parametro di query che contiene la lingua.\n\nReturns: `String` Valore predefinito: `'language'`.\n\nExample: Leggi il nome\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nLa chiave `localStorage` della cache.\n\nReturns: `String` Valore predefinito: `'jc'`.\n\n[ENVIRONMENT()](../globals/) può impostare questo valore.\n\nExample: Leggi la chiave\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.onstorageread = function(callback)\n\nType: `config`\n\nCarica la cache persistente all'avvio della libreria.\n\nReturns: `Function` Valore predefinito: `function(callback)`.\n\nAssegna la tua funzione subito dopo lo script della libreria. Deve chiamare `callback` con l'oggetto salvato. La funzione predefinita legge `localStorage`.\n\nExample: Fornisci i dati salvati\n```js\nDEF.onstorageread = function(callback) {\n\tcallback({});\n};\n\nON('ready', function() {\n\tconsole.log('loaded'); // loaded\n});\n```\n\n### DEF.onstoragesave = function(data)\n\nType: `config`\n\nSalva la cache persistente.\n\nReturns: `Function` Valore predefinito: `function(data)`.\n\nLa funzione riceve un oggetto con tutti gli elementi che hanno una scadenza. La funzione predefinita scrive in `localStorage`.\n\nExample: Osserva il salvataggio\n```js\nDEF.onstoragesave = function(data) {\n\tconsole.log(Object.keys(data).length); // 1\n};\n\nON('ready', function() {\n\tCACHE('filter', 1, '1 day');\n});\n```\n\n### DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }\n\nType: `config`\n\nLe destinazioni dei prefissi brevi dei path.\n\nReturns: `Object` Valore predefinito: `{ common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }`.\n\n`common` è la destinazione di `*`, `cl` di `#` e `tmp` di `%`. `plugins` contiene i dati dei plugin con un path generato. La funzione `DEF.path.clean(name)` restituisce un valore senza il punto finale. Consulta [Path](../../guides/paths/).\n\nExample: Leggi un prefisso\n```js\nconsole.log(DEF.path.common); // common.\nconsole.log(DEF.path.clean('common')); // common\n```\n\n### DEF.pipe = undefined\n\nType: `config`\n\nL'indirizzo usato da `PIPE()`.\n\nReturns: `String` Valore predefinito: `undefined`.\n\nAssegnalo per usare [PIPE()](../globals/).\n\nExample: Imposta l'endpoint\n```js\nDEF.pipe = '/pipe/';\nconsole.log(DEF.pipe); // /pipe/\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nIl prefisso della classe CSS che un componente riceve come `cls`.\n\nReturns: `String` Valore predefinito: `'ui-'`.\n\nExample: Cambia il prefisso\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nDEF.prefixcsscomponents = 'my-';\n\nCOMPONENT('box', function(self, config, cls) {\n\tconsole.log(cls); // my-box\n});\n</script>\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nIl prefisso delle classi CSS create dalla libreria.\n\nReturns: `String` Valore predefinito: `'ui-'`.\n\nViene usato da [APPEARANCE()](../globals/) e [SCROLLBAR()](../globals/).\n\nExample: Cambia il prefisso\n```js\nDEF.prefixcsslibrary = 'app-';\nAPPEARANCE({ dark: true });\nconsole.log($('body').hclass('app-dark')); // true\n```\n\n### DEF.regexp = { int, float, date, pluralize, format, url, phone, email }\n\nType: `config`\n\nLe espressioni regolari usate dagli helper.\n\nReturns: `Object` Valore predefinito: `{ int, float, date, pluralize, format, url, phone, email }`.\n\nAd esempio, `String.isEmail()` usa `DEF.regexp.email`. Consulta [String](../string/).\n\nExample: Valida un indirizzo e-mail\n```js\nconsole.log(DEF.regexp.email.test('info@example.com')); // true\nconsole.log('invalid'.isEmail()); // false\n```\n\n### DEF.root = ''\n\nType: `config`\n\nIl prefisso che `String.ROOT()` aggiunge a ogni indirizzo relativo.\n\nReturns: `String|Function` Valore predefinito: `''`.\n\nHa la precedenza su [DEF.baseurl](../def/) e `ROOT(true)` applica solo questo valore. Consulta [String](../string/).\n\nExample: Aggiungi un prefisso a un indirizzo\n```js\nDEF.root = '/admin';\nconsole.log('/users/'.ROOT()); // /admin/users/\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnima la barra di una barra di scorrimento personalizzata ai bordi dell'area di scorrimento.\n\nReturns: `Boolean` Valore predefinito: `true`.\n\nConsulta [SCROLLBAR()](../globals/).\n\nExample: Disattiva l'animazione\n```js\nDEF.scrollbaranimate = false;\nconsole.log(DEF.scrollbaranimate); // false\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nIl separatore delle migliaia dei numeri formattati.\n\nReturns: `String` Valore predefinito: `' '`.\n\nViene usato da `Number.format()` e durante l'analisi dei numeri. Consulta [Number](../number/).\n\nExample: Usa una virgola\n```js\nDEF.thousandsseparator = ',';\nconsole.log((1234567).format(0)); // 1,234,567\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nIl formato dell'ora copiato nelle variabili d'ambiente all'avvio.\n\nReturns: `String` Valore predefinito: `'HH:mm'`.\n\nPer cambiare il formato in seguito, scrivi le variabili `time` e `ts` con [ENV()](../globals/).\n\nExample: Leggi il formato\n```js\nconsole.log(DEF.timeformat); // HH:mm\nconsole.log(ENV('time')); // HH:mm\n```\n\n### DEF.tmp = {}\n\nType: `config`\n\nL'archivio dei path temporanei.\n\nReturns: `Object` Valore predefinito: `{}`.\n\nIl prefisso di path `%` punta qui, quindi `%form` equivale a `DEF.tmp.form`. Vedi [Path](../../guides/paths/).\n\nExample: Scrivi un valore temporaneo\n```js\nSET('%search', 'phone');\nconsole.log(DEF.tmp.search); // phone\n```\n\n### DEF.version = undefined\n\nType: `config`\n\nLa versione aggiunta agli indirizzi `.html` richiesti con `AJAX()`.\n\nReturns: `String` Valore predefinito: `undefined`.\n\nIl nome del parametro si trova in [DEF.versionkey](../def/). Anche [ENVIRONMENT()](../globals/) può impostare questo valore.\n\nExample: Imposta la versione\n```js\nDEF.version = '1.0';\nconsole.log(DEF.version); // 1.0\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nLa versione per gli indirizzi `.html` quando `DEF.version` è vuoto.\n\nReturns: `String` Valore predefinito: `undefined`.\n\nExample: Imposta la versione dei file HTML\n```js\nDEF.versionhtml = '2';\nconsole.log(DEF.versionhtml); // 2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nIl nome del parametro di query che contiene la versione.\n\nReturns: `String` Valore predefinito: `'version'`.\n\nExample: Leggi il nome\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.warnings = false\n\nType: `config`\n\nStampa nella console gli avvisi della libreria.\n\nReturns: `Boolean` Valore predefinito: `false`.\n\nAttivalo durante lo sviluppo, ad esempio per segnalare un metodo non trovato.\n\nExample: Attiva gli avvisi\n```js\nDEF.warnings = true;\nconsole.log(DEF.warnings); // true\n```\n","entries":[{"type":"config","name":"DEF.api","signature":"DEF.api = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.baseurl","signature":"DEF.baseurl = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cdn","signature":"DEF.cdn = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cl","signature":"DEF.cl = {}","since":"","deprecated":false},{"type":"config","name":"DEF.color","signature":"DEF.color = '#4285F4'","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = ''","since":"","deprecated":false},{"type":"config","name":"DEF.dateformat","signature":"DEF.dateformat = 'yyyy-MM-dd'","since":"","deprecated":false},{"type":"config","name":"DEF.dateformatutc","signature":"DEF.dateformatutc = false","since":"","deprecated":false},{"type":"config","name":"DEF.decimalseparator","signature":"DEF.decimalseparator = '.'","since":"","deprecated":false},{"type":"config","name":"DEF.devices","signature":"DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }","since":"","deprecated":false},{"type":"config","name":"DEF.dictionary","signature":"DEF.dictionary = {}","since":"","deprecated":false},{"type":"config","name":"DEF.empty","signature":"DEF.empty = '---'","since":"","deprecated":false},{"type":"config","name":"DEF.env","signature":"DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }","since":"","deprecated":false},{"type":"config","name":"DEF.fallback","signature":"DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'","since":"","deprecated":false},{"type":"config","name":"DEF.firstdayofweek","signature":"DEF.firstdayofweek = 1","since":"","deprecated":false},{"type":"config","name":"DEF.headers","signature":"DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }","since":"","deprecated":false},{"type":"config","name":"DEF.iconprefix","signature":"DEF.iconprefix = 'ti ti-'","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagekey","signature":"DEF.languagekey = 'language'","since":"","deprecated":false},{"type":"config","name":"DEF.localstorage","signature":"DEF.localstorage = 'jc'","since":"","deprecated":false},{"type":"config","name":"DEF.onstorageread","signature":"DEF.onstorageread = function(callback)","since":"","deprecated":false},{"type":"config","name":"DEF.onstoragesave","signature":"DEF.onstoragesave = function(data)","since":"","deprecated":false},{"type":"config","name":"DEF.path","signature":"DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }","since":"","deprecated":false},{"type":"config","name":"DEF.pipe","signature":"DEF.pipe = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsscomponents","signature":"DEF.prefixcsscomponents = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsslibrary","signature":"DEF.prefixcsslibrary = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format, url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.thousandsseparator","signature":"DEF.thousandsseparator = ' '","since":"","deprecated":false},{"type":"config","name":"DEF.timeformat","signature":"DEF.timeformat = 'HH:mm'","since":"","deprecated":false},{"type":"config","name":"DEF.tmp","signature":"DEF.tmp = {}","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionhtml","signature":"DEF.versionhtml = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionkey","signature":"DEF.versionkey = 'version'","since":"","deprecated":false},{"type":"config","name":"DEF.warnings","signature":"DEF.warnings = false","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcQb5Qd61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/def/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"DEF","summary":"Predvolené nastavenia knižnice.","markdown":"---\ntitle: DEF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/def/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# DEF\n\n> Predvolené nastavenia knižnice.\n\n`DEF` obsahuje predvolené nastavenia knižnice. Hodnoty priraď hneď za skriptom knižnice, aby platili od začiatku. Kam tento kód patrí, ukazuje časť [Začíname](../../guides/getting-started/).\n\n## API\n\n### DEF.api = undefined\n\nType: `config`\n\nAdresa, ktorú používa `TAPI()`.\n\nReturns: `String` Predvolená hodnota: `undefined`.\n\nPriraď ju, ak chceš používať [TAPI()](../globals/).\n\nExample: Nastav endpoint\n```js\nDEF.api = '/admin/api/';\nconsole.log(DEF.api); // /admin/api/\n```\n\n### DEF.baseurl = ''\n\nType: `config`\n\nPrefix, ktorý `String.ROOT()` pridáva k relatívnym adresám.\n\nReturns: `String|Function` Predvolená hodnota: `''`.\n\nFunkcia dostane adresu a vráti výslednú adresu. Prednosť má [DEF.root](../def/). Pozri [String](../string/).\n\nExample: Pridaj k adrese prefix\n```js\nDEF.baseurl = '/app';\nconsole.log('/users/'.ROOT()); // /app/users/\n```\n\n### DEF.cdn = ''\n\nType: `config`\n\nHodnota kľúčového slova `~CDN~` v importovanom obsahu.\n\nReturns: `String` Predvolená hodnota: `''`.\n\nKľúčové slovo nahrádza [ADAPT()](../globals/).\n\nExample: Použi kľúčové slovo\n```js\nDEF.cdn = 'https://cdn.example.com';\nconsole.log(ADAPT(null, null, '~CDN~/logo.png')); // https://cdn.example.com/logo.png\n```\n\n### DEF.cl = {}\n\nType: `config`\n\nNačítané zoznamy kódov.\n\nReturns: `Object` Predvolená hodnota: `{}`.\n\nSem ukazuje prefix path `#`, takže `#countries` je `DEF.cl.countries`. Pozri [CL()](../globals/).\n\nExample: Prečítaj zoznam cez jeho path\n```js\nSET('#colors', ['red']);\nconsole.log(DEF.cl.colors); // [\"red\"]\n```\n\n### DEF.color = '#4285F4'\n\nType: `config`\n\nAkcentová farba aplikácie.\n\nReturns: `String` Predvolená hodnota: `'#4285F4'`.\n\nAktualizuje ju [APPEARANCE()](../globals/).\n\nExample: Zmeň farbu\n```js\nAPPEARANCE({ color: '#FF0000' });\nconsole.log(DEF.color); // #FF0000\n```\n\n### DEF.currencies = {}\n\nType: `config`\n\nFormátovače, ktoré používa `Number.currency()`.\n\nReturns: `Object` Predvolená hodnota: `{}`.\n\nKaždý kľúč je názov meny a každá hodnota je funkcia, ktorá dostane číslo. Pozri [Number](../number/).\n\nExample: Definuj menu\n```js\nDEF.currencies.eur = function(value) {\n\treturn value.format(2) + ' EUR';\n};\n\nconsole.log((10).currency('eur')); // 10.00 EUR\n```\n\n### DEF.currency = ''\n\nType: `config`\n\nPredvolená mena `Number.currency()`.\n\nReturns: `String` Predvolená hodnota: `''`.\n\nExample: Nastav predvolenú menu\n```js\nDEF.currencies.usd = function(value) {\n\treturn '$' + value.format(2);\n};\n\nDEF.currency = 'usd';\nconsole.log((5).currency()); // $5.00\n```\n\n### DEF.dateformat = 'yyyy-MM-dd'\n\nType: `config`\n\nPredvolený formát `Date.format()` a spracovania dátumov.\n\nReturns: `String` Predvolená hodnota: `'yyyy-MM-dd'`.\n\nPozri [Date](../date/).\n\nExample: Zmeň formát\n```js\nDEF.dateformat = 'dd.MM.yyyy';\nconsole.log(new Date(2024, 0, 15).format()); // 15.01.2024\n```\n\n### DEF.dateformatutc = false\n\nType: `config`\n\nFormátuje všetky dátumy v UTC.\n\nReturns: `Boolean` Predvolená hodnota: `false`.\n\nPlatí pre `Date.format()`. Pozri [Date](../date/).\n\nExample: Formátuj v UTC\n```js\nDEF.dateformatutc = true;\nconsole.log(new Date(Date.UTC(2024, 0, 15, 12, 30)).format('HH:mm')); // 12:30\n```\n\n### DEF.decimalseparator = '.'\n\nType: `config`\n\nDesatinný oddeľovač formátovaných čísel.\n\nReturns: `String` Predvolená hodnota: `'.'`.\n\nPoužíva ho `Number.format()` a spracovanie čísel. Pozri [Number](../number/).\n\nExample: Použi desatinnú čiarku\n```js\nDEF.decimalseparator = ',';\nconsole.log((1.5).format(2)); // 1,50\n```\n\n### DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }\n\nType: `config`\n\nRozsahy šírky pre veľkosti zariadení.\n\nReturns: `Object` Predvolená hodnota: `{ xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }`.\n\nRozsahy používa [WIDTH()](../globals/) a triedy `jc-xs`, `jc-sm`, `jc-md` a `jc-lg` elementu body.\n\nExample: Prečítaj rozsah\n```js\nconsole.log(DEF.devices.md); // {\"min\":992,\"max\":1200}\n```\n\n### DEF.dictionary = {}\n\nType: `config`\n\nPreklady načítané cez `LOCALIZE()`.\n\nReturns: `Object` Predvolená hodnota: `{}`.\n\nPozri [Lokalizácia](../../guides/localization/).\n\nExample: Prečítaj slovník\n```js\nLOCALIZE('Tabc : Hola');\nconsole.log(DEF.dictionary.Tabc); // Hola\n```\n\n### DEF.empty = '---'\n\nType: `config`\n\nText zobrazený pre prázdnu hodnotu.\n\nReturns: `String` Predvolená hodnota: `'---'`.\n\nPoužíva ho príkaz `empty` elementu [ui-bind](../ui-bind/) a [helper Tangular](../tangular-helpers/) `empty`.\n\nExample: Prečítaj text\n```js\nconsole.log(DEF.empty); // ---\n```\n\n### DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }\n\nType: `config`\n\nPremenné prostredia.\n\nReturns: `Object` Predvolená hodnota: `{ ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }`.\n\nPremenné sa spravujú cez [ENV()](../globals/). Predvolené hodnoty môžeš použiť ako formáty dátumu, napríklad `[ts]`.\n\nExample: Použi premennú ako formát dátumu\n```js\nvar date = new Date(2024, 0, 15, 8, 5);\nconsole.log(date.format('[ts]')); // 2024-01-15 - 08:05\n```\n\n### DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'\n\nType: `config`\n\nAdresa, z ktorej sa sťahujú neznáme komponenty.\n\nReturns: `String` Predvolená hodnota: `'https://cdn.componentator.com/j-{0}.html'`.\n\nKľúčové slovo `{0}` sa zmení na názov komponentu. Atribút `source` elementu [ui-component](../ui-component/) ju prepíše.\n\nExample: Prečítaj adresu\n```js\nconsole.log(DEF.fallback.format('input')); // https://cdn.componentator.com/j-input.html\n```\n\n### DEF.firstdayofweek = 1\n\nType: `config`\n\nPrvý deň v týždni pre komponenty, ktoré zobrazujú kalendár.\n\nReturns: `Number` Predvolená hodnota: `1`.\n\nHodnota `0` je nedeľa a `1` je pondelok. Knižnica ju iba uchováva.\n\nExample: Začni týždeň nedeľou\n```js\nDEF.firstdayofweek = 0;\nconsole.log(DAYS[DEF.firstdayofweek]); // Sunday\n```\n\n### DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }\n\nType: `config`\n\nHlavičky pridané ku každej požiadavke `AJAX()`.\n\nReturns: `Object` Predvolená hodnota: `{ 'X-Requested-With': 'XMLHttpRequest' }`.\n\nExample: Pridaj hlavičku\n```js\nDEF.headers['x-token'] = '123456';\nconsole.log(DEF.headers['x-token']); // 123456\n```\n\n### DEF.iconprefix = 'ti ti-'\n\nType: `config`\n\nPrefix, ktorý `component.icon()` pridáva k názvom ikon.\n\nReturns: `String` Predvolená hodnota: `'ti ti-'`.\n\nHodnota, ktorá obsahuje medzeru, sa použije tak, ako je. Pozri [Component](../component/).\n\nExample: Zmeň prefix\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tDEF.iconprefix = 'fa fa-';\n\t\tconsole.log(self.icon('home')); // fa fa-home\n\t};\n});\n</script>\n```\n\n### DEF.language = undefined\n\nType: `config`\n\nJazyk pridaný do reťazca dotazu každej požiadavky `AJAX()`.\n\nReturns: `String` Predvolená hodnota: `undefined`.\n\nNázov parametra je v [DEF.languagekey](../def/). Túto hodnotu môže nastaviť [ENVIRONMENT()](../globals/).\n\nExample: Nastav jazyk\n```js\nDEF.language = 'en';\nconsole.log(DEF.language); // en\n```\n\n### DEF.languagekey = 'language'\n\nType: `config`\n\nNázov parametra dotazu, ktorý nesie jazyk.\n\nReturns: `String` Predvolená hodnota: `'language'`.\n\nExample: Prečítaj názov\n```js\nconsole.log(DEF.languagekey); // language\n```\n\n### DEF.localstorage = 'jc'\n\nType: `config`\n\nKľúč cache v `localStorage`.\n\nReturns: `String` Predvolená hodnota: `'jc'`.\n\nTúto hodnotu môže nastaviť [ENVIRONMENT()](../globals/).\n\nExample: Prečítaj kľúč\n```js\nconsole.log(DEF.localstorage); // jc\n```\n\n### DEF.onstorageread = function(callback)\n\nType: `config`\n\nNačíta trvalú cache pri štarte knižnice.\n\nReturns: `Function` Predvolená hodnota: `function(callback)`.\n\nVlastnú funkciu priraď hneď za skriptom knižnice. Musí zavolať `callback` s uloženým objektom. Predvolená funkcia číta `localStorage`.\n\nExample: Poskytni uložené dáta\n```js\nDEF.onstorageread = function(callback) {\n\tcallback({});\n};\n\nON('ready', function() {\n\tconsole.log('loaded'); // loaded\n});\n```\n\n### DEF.onstoragesave = function(data)\n\nType: `config`\n\nUloží trvalú cache.\n\nReturns: `Function` Predvolená hodnota: `function(data)`.\n\nFunkcia dostane objekt so všetkými položkami, ktoré majú nastavenú expiráciu. Predvolená funkcia zapisuje do `localStorage`.\n\nExample: Sleduj ukladanie\n```js\nDEF.onstoragesave = function(data) {\n\tconsole.log(Object.keys(data).length); // 1\n};\n\nON('ready', function() {\n\tCACHE('filter', 1, '1 day');\n});\n```\n\n### DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }\n\nType: `config`\n\nCiele krátkych prefixov path.\n\nReturns: `Object` Predvolená hodnota: `{ common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }`.\n\n`common` je cieľom `*`, `cl` cieľom `#` a `tmp` cieľom `%`. `plugins` obsahuje dáta pluginov s vygenerovanou path. Funkcia `DEF.path.clean(name)` vráti hodnotu bez koncovej bodky. Pozri [Paths](../../guides/paths/).\n\nExample: Prečítaj prefix\n```js\nconsole.log(DEF.path.common); // common.\nconsole.log(DEF.path.clean('common')); // common\n```\n\n### DEF.pipe = undefined\n\nType: `config`\n\nAdresa, ktorú používa `PIPE()`.\n\nReturns: `String` Predvolená hodnota: `undefined`.\n\nPriraď ju, ak chceš používať [PIPE()](../globals/).\n\nExample: Nastav endpoint\n```js\nDEF.pipe = '/pipe/';\nconsole.log(DEF.pipe); // /pipe/\n```\n\n### DEF.prefixcsscomponents = 'ui-'\n\nType: `config`\n\nPrefix CSS triedy, ktorú komponent dostane ako `cls`.\n\nReturns: `String` Predvolená hodnota: `'ui-'`.\n\nExample: Zmeň prefix\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nDEF.prefixcsscomponents = 'my-';\n\nCOMPONENT('box', function(self, config, cls) {\n\tconsole.log(cls); // my-box\n});\n</script>\n```\n\n### DEF.prefixcsslibrary = 'ui-'\n\nType: `config`\n\nPrefix CSS tried, ktoré vytvára knižnica.\n\nReturns: `String` Predvolená hodnota: `'ui-'`.\n\nPoužívajú ho [APPEARANCE()](../globals/) a [SCROLLBAR()](../globals/).\n\nExample: Zmeň prefix\n```js\nDEF.prefixcsslibrary = 'app-';\nAPPEARANCE({ dark: true });\nconsole.log($('body').hclass('app-dark')); // true\n```\n\n### DEF.regexp = { int, float, date, pluralize, format, url, phone, email }\n\nType: `config`\n\nRegulárne výrazy, ktoré používajú helpery.\n\nReturns: `Object` Predvolená hodnota: `{ int, float, date, pluralize, format, url, phone, email }`.\n\nNapríklad `String.isEmail()` používa `DEF.regexp.email`. Pozri [String](../string/).\n\nExample: Zvaliduj e-mailovú adresu\n```js\nconsole.log(DEF.regexp.email.test('info@example.com')); // true\nconsole.log('invalid'.isEmail()); // false\n```\n\n### DEF.root = ''\n\nType: `config`\n\nPrefix, ktorý `String.ROOT()` pridáva ku každej relatívnej adrese.\n\nReturns: `String|Function` Predvolená hodnota: `''`.\n\nMá prednosť pred [DEF.baseurl](../def/) a `ROOT(true)` použije iba túto hodnotu. Pozri [String](../string/).\n\nExample: Pridaj k adrese prefix\n```js\nDEF.root = '/admin';\nconsole.log('/users/'.ROOT()); // /admin/users/\n```\n\n### DEF.scrollbaranimate = true\n\nType: `config`\n\nAnimuje jazdec vlastného posuvníka na okrajoch posúvanej oblasti.\n\nReturns: `Boolean` Predvolená hodnota: `true`.\n\nPozri [SCROLLBAR()](../globals/).\n\nExample: Vypni animáciu\n```js\nDEF.scrollbaranimate = false;\nconsole.log(DEF.scrollbaranimate); // false\n```\n\n### DEF.thousandsseparator = ' '\n\nType: `config`\n\nOddeľovač tisícov formátovaných čísel.\n\nReturns: `String` Predvolená hodnota: `' '`.\n\nPoužíva ho `Number.format()` a spracovanie čísel. Pozri [Number](../number/).\n\nExample: Použi čiarku\n```js\nDEF.thousandsseparator = ',';\nconsole.log((1234567).format(0)); // 1,234,567\n```\n\n### DEF.timeformat = 'HH:mm'\n\nType: `config`\n\nFormát času, ktorý sa pri štarte skopíruje do premenných prostredia.\n\nReturns: `String` Predvolená hodnota: `'HH:mm'`.\n\nAk chceš formát neskôr zmeniť, zapíš premenné `time` a `ts` pomocou [ENV()](../globals/).\n\nExample: Prečítaj formát\n```js\nconsole.log(DEF.timeformat); // HH:mm\nconsole.log(ENV('time')); // HH:mm\n```\n\n### DEF.tmp = {}\n\nType: `config`\n\nÚložisko dočasných paths.\n\nReturns: `Object` Predvolená hodnota: `{}`.\n\nSem smeruje prefix path `%`, takže `%form` znamená `DEF.tmp.form`. Pozri [Paths](../../guides/paths/).\n\nExample: Zapíš dočasnú hodnotu\n```js\nSET('%search', 'phone');\nconsole.log(DEF.tmp.search); // phone\n```\n\n### DEF.version = undefined\n\nType: `config`\n\nVerzia pridávaná k adresám `.html`, ktoré sa žiadajú cez `AJAX()`.\n\nReturns: `String` Predvolená hodnota: `undefined`.\n\nNázov parametra je v [DEF.versionkey](../def/). Túto hodnotu môže nastaviť [ENVIRONMENT()](../globals/).\n\nExample: Nastav verziu\n```js\nDEF.version = '1.0';\nconsole.log(DEF.version); // 1.0\n```\n\n### DEF.versionhtml = undefined\n\nType: `config`\n\nVerzia pre adresy `.html`, keď je `DEF.version` prázdne.\n\nReturns: `String` Predvolená hodnota: `undefined`.\n\nExample: Nastav verziu súborov HTML\n```js\nDEF.versionhtml = '2';\nconsole.log(DEF.versionhtml); // 2\n```\n\n### DEF.versionkey = 'version'\n\nType: `config`\n\nNázov parametra dotazu, ktorý nesie verziu.\n\nReturns: `String` Predvolená hodnota: `'version'`.\n\nExample: Prečítaj názov\n```js\nconsole.log(DEF.versionkey); // version\n```\n\n### DEF.warnings = false\n\nType: `config`\n\nVypisuje upozornenia knižnice do konzoly.\n\nReturns: `Boolean` Predvolená hodnota: `false`.\n\nZapni ho počas vývoja, napríklad aby ťa upozornil na nenájdenú metódu.\n\nExample: Zapni upozornenia\n```js\nDEF.warnings = true;\nconsole.log(DEF.warnings); // true\n```\n","entries":[{"type":"config","name":"DEF.api","signature":"DEF.api = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.baseurl","signature":"DEF.baseurl = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cdn","signature":"DEF.cdn = ''","since":"","deprecated":false},{"type":"config","name":"DEF.cl","signature":"DEF.cl = {}","since":"","deprecated":false},{"type":"config","name":"DEF.color","signature":"DEF.color = '#4285F4'","since":"","deprecated":false},{"type":"config","name":"DEF.currencies","signature":"DEF.currencies = {}","since":"","deprecated":false},{"type":"config","name":"DEF.currency","signature":"DEF.currency = ''","since":"","deprecated":false},{"type":"config","name":"DEF.dateformat","signature":"DEF.dateformat = 'yyyy-MM-dd'","since":"","deprecated":false},{"type":"config","name":"DEF.dateformatutc","signature":"DEF.dateformatutc = false","since":"","deprecated":false},{"type":"config","name":"DEF.decimalseparator","signature":"DEF.decimalseparator = '.'","since":"","deprecated":false},{"type":"config","name":"DEF.devices","signature":"DEF.devices = { xs: { max: 768 }, sm: { min: 768, max: 992 }, md: { min: 992, max: 1200 }, lg: { min: 1200 } }","since":"","deprecated":false},{"type":"config","name":"DEF.dictionary","signature":"DEF.dictionary = {}","since":"","deprecated":false},{"type":"config","name":"DEF.empty","signature":"DEF.empty = '---'","since":"","deprecated":false},{"type":"config","name":"DEF.env","signature":"DEF.env = { ts: 'yyyy-MM-dd - HH:mm', date: 'yyyy-MM-dd', time: 'HH:mm' }","since":"","deprecated":false},{"type":"config","name":"DEF.fallback","signature":"DEF.fallback = 'https://cdn.componentator.com/j-{0}.html'","since":"","deprecated":false},{"type":"config","name":"DEF.firstdayofweek","signature":"DEF.firstdayofweek = 1","since":"","deprecated":false},{"type":"config","name":"DEF.headers","signature":"DEF.headers = { 'X-Requested-With': 'XMLHttpRequest' }","since":"","deprecated":false},{"type":"config","name":"DEF.iconprefix","signature":"DEF.iconprefix = 'ti ti-'","since":"","deprecated":false},{"type":"config","name":"DEF.language","signature":"DEF.language = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.languagekey","signature":"DEF.languagekey = 'language'","since":"","deprecated":false},{"type":"config","name":"DEF.localstorage","signature":"DEF.localstorage = 'jc'","since":"","deprecated":false},{"type":"config","name":"DEF.onstorageread","signature":"DEF.onstorageread = function(callback)","since":"","deprecated":false},{"type":"config","name":"DEF.onstoragesave","signature":"DEF.onstoragesave = function(data)","since":"","deprecated":false},{"type":"config","name":"DEF.path","signature":"DEF.path = { common: 'common.', cl: 'DEF.cl.', plugins: 'jComponent.data.', tmp: 'DEF.tmp.' }","since":"","deprecated":false},{"type":"config","name":"DEF.pipe","signature":"DEF.pipe = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsscomponents","signature":"DEF.prefixcsscomponents = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.prefixcsslibrary","signature":"DEF.prefixcsslibrary = 'ui-'","since":"","deprecated":false},{"type":"config","name":"DEF.regexp","signature":"DEF.regexp = { int, float, date, pluralize, format, url, phone, email }","since":"","deprecated":false},{"type":"config","name":"DEF.root","signature":"DEF.root = ''","since":"","deprecated":false},{"type":"config","name":"DEF.scrollbaranimate","signature":"DEF.scrollbaranimate = true","since":"","deprecated":false},{"type":"config","name":"DEF.thousandsseparator","signature":"DEF.thousandsseparator = ' '","since":"","deprecated":false},{"type":"config","name":"DEF.timeformat","signature":"DEF.timeformat = 'HH:mm'","since":"","deprecated":false},{"type":"config","name":"DEF.tmp","signature":"DEF.tmp = {}","since":"","deprecated":false},{"type":"config","name":"DEF.version","signature":"DEF.version = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionhtml","signature":"DEF.versionhtml = undefined","since":"","deprecated":false},{"type":"config","name":"DEF.versionkey","signature":"DEF.versionkey = 'version'","since":"","deprecated":false},{"type":"config","name":"DEF.warnings","signature":"DEF.warnings = false","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcVG5oo61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/main/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"MAIN","summary":"The main object of the library, with its state and its low-level methods.","markdown":"---\ntitle: MAIN\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/main/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# MAIN\n\n> The main object of the library, with its state and its low-level methods.\n\n`MAIN` is the main object of the library. `M`, `Total` and `jComponent` are other names for the same object. It holds the state of the library and low-level methods that work with any scope. For everyday code, use the [global functions](../globals/) described with [Paths](../../guides/paths/).\n\n## API\n\n### MAIN.Binder\n\nType: `class`\n\nThe class of data bindings.\n\nSee [ui-bind](../ui-bind/).\n\n### MAIN.binders\n\nType: `property`\n\nThe active data bindings.\n\nReturns: `Array` The active data bindings.\n\nSee [ui-bind](../ui-bind/).\n\n### MAIN.caller\n\nType: `property`\n\nThe plugin that was last called through `EXEC()`.\n\nReturns: `Plugin` The plugin that was last called through `EXEC()`.\n\nExample: Read the caller\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.refresh = NOOP;\n});\n\nON('ready', function() {\n\tEXEC('users/refresh');\n\tconsole.log(MAIN.caller.name); // users\n});\n</script>\n```\n\n### MAIN.cl(name, [callback])\n\nType: `method`\n\nThe same function as `CL()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The names of the code lists. |\n| `callback` | `Function` | no |  | A function that runs when the lists are loaded. |\n\nSee [CL()](../globals/).\n\n### MAIN.Component\n\nType: `class`\n\nThe class of components.\n\nSee [Component](../component/).\n\n### MAIN.components\n\nType: `property`\n\nThe active component instances.\n\nReturns: `Array` The active component instances.\n\nSee [Component](../component/).\n\nExample: Count the components\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(MAIN.components.length); // 1\n});\n</script>\n```\n\n### MAIN.data\n\nType: `property`\n\nThe storage of plugins with a generated path.\n\nReturns: `Object` The storage of plugins with a generated path.\n\nSee [DEF.path](../def/).\n\n### MAIN.def\n\nType: `property`\n\nThe same object as `DEF`.\n\nReturns: `Object` The same object as `DEF`.\n\nSee [DEF](../def/).\n\nExample: Compare the objects\n```js\nconsole.log(MAIN.def === DEF); // true\n```\n\n### MAIN.emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nThe same function as `EMIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nSee [EMIT()](../globals/).\n\n### MAIN.events\n\nType: `property`\n\nThe global event handlers, by event name.\n\nReturns: `Object` The global event handlers, by event name.\n\nSee [Events](../events/).\n\n### MAIN.exec(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuns the same logic as `EXEC()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The target of the call. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nSee [EXEC()](../globals/).\n\n### MAIN.find(scope, path, callback)\n\nType: `method`\n\nFinds the components of a path in a scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | The scope, usually `window`. |\n| `path` | `String` | yes |  | The path, optionally with flags. |\n| `callback` | `Function` | yes |  | A function that receives the array of components. |\n\nFlags in the path narrow the result: `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` and `@enabled`.\n\nExample: Find components\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tMAIN.find(window, 'form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### MAIN.flags(flags, [callback])\n\nType: `method`\n\nThe same function as `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | The flags. |\n| `callback` | `Function` | no |  | A function that runs afterwards. |\n\nSee [FLAGS()](../globals/).\n\n### MAIN.free()\n\nType: `method`\n\nThe same function as `FREE()`.\n\nSee [FREE()](../globals/).\n\n### MAIN.get(scope, path)\n\nType: `method`\n\nReads a value from any object by a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | The object to read from. |\n| `path` | `String` | yes |  | The path inside the object. |\n\nReturns: `Object` The value.\n\nExample: Read a nested value\n```js\nvar data = { user: { name: 'Peter' } };\nconsole.log(MAIN.get(data, 'user.name')); // Peter\n```\n\n### MAIN.is20\n\nType: `property`\n\nIdentifies the major version of the library.\n\nReturns: `Boolean` Identifies the major version of the library.\n\nThe value is always `true`.\n\nExample: Read the value\n```js\nconsole.log(MAIN.is20); // true\n```\n\n### MAIN.loaded\n\nType: `property`\n\nBecomes `true` when the persistent cache is loaded.\n\nReturns: `Boolean` Becomes `true` when the persistent cache is loaded.\n\n### MAIN.newbinder(element, path, config, [callback])\n\nType: `method`\n\nCreates a data binding on an element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | The element. |\n| `path` | `String` | yes |  | The path. |\n| `config` | `String` | yes |  | The binding commands. |\n| `callback` | `Function` | no |  | A function that runs when the binding is created. |\n\nSee [NEWUIBIND()](../globals/).\n\n### MAIN.newcomponent(element, name, path, config, [callback])\n\nType: `method`\n\nCreates a component on an element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | The element. |\n| `name` | `String` | yes |  | The name of the component. |\n| `path` | `String` | yes |  | The path. |\n| `config` | `String` | yes |  | The configuration. |\n| `callback` | `Function` | no |  | A function that runs when the component is created. |\n\nExample: Create a component from code\n```html\n<div id=\"target\"></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.path.path); // form.name\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newcomponent($('#target'), 'box', 'form.name', '');\n});\n</script>\n```\n\n### MAIN.newimporter(element, path, config)\n\nType: `method`\n\nImports content into an element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | The element. |\n| `path` | `String` | yes |  | The address. |\n| `config` | `String` | yes |  | The configuration of the import. |\n\nIt works like the [ui-import](../ui-import/) element.\n\nExample: Import a part\n```html\n<div id=\"target\"></div>\n\n<script>\nON('ready', function() {\n\tMAIN.newimporter($('#target'), '/parts/menu.html', '');\n\n\tsetTimeout(function() {\n\t\tconsole.log($('#target').html()); // <b>Menu</b>\n\t}, 400);\n});\n</script>\n```\n\n### MAIN.newplugin(element, path, config, [callback])\n\nType: `method`\n\nCreates a plugin on an element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | The element. |\n| `path` | `String` | yes |  | The name of the plugin. |\n| `config` | `String` | no |  | The configuration. |\n| `callback` | `Function` | no |  | A function that runs when the plugin is created. |\n\nExample: Create a plugin from code\n```html\n<div id=\"target\"></div>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.name); // users\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newplugin($('#target'), 'users');\n});\n</script>\n```\n\n### MAIN.notify(scope, path, [onlyflags])\n\nType: `method`\n\nNotifies the observers of a path in a scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | The scope, usually `window`. |\n| `path` | `String` | yes |  | The path, optionally with flags. |\n| `onlyflags` | `Boolean` | no | `false` | Limits the notification to the state of components. |\n\nWith `onlyflags`, components only refresh their state, and watchers do not run.\n\nExample: Notify a path\n```js\nWATCH('total', function(value) {\n\tconsole.log(value); // 5\n});\n\nwindow.total = 5;\nMAIN.notify(window, 'total');\n```\n\n### MAIN.off(name, [callback])\n\nType: `method`\n\nThe same function as `OFF()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `callback` | `Function` | no |  | The handler to remove. |\n\nSee [OFF()](../globals/).\n\n### MAIN.on(name, callback, [init])\n\nType: `method`\n\nThe same function as `ON()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the event. |\n| `callback` | `Function` | yes |  | The handler. |\n| `init` | `Boolean` | no | `false` | Also calls the handler once. |\n\nSee [ON()](../globals/).\n\n### MAIN.parse(type, value, [format])\n\nType: `method`\n\nConverts a value to a type.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | The type. |\n| `value` | `Object` | yes |  | The value. |\n| `format` | `String` | no |  | The format of a date. |\n\nReturns: `Object` The converted value.\n\nThe types are `number`, `currency`, `float`, `boolean`, `bool`, `date` and `datetime`. Numbers follow [DEF.thousandsseparator](../def/) and [DEF.decimalseparator](../def/), and dates use [DEF.dateformat](../def/) when `format` is not set. A value that cannot be converted returns `null`. Other types return the value as it is.\n\nExample: Convert values\n```js\nconsole.log(MAIN.parse('number', '1 200.5')); // 1200.5\nconsole.log(MAIN.parse('boolean', 'yes')); // true\nconsole.log(MAIN.parse('date', '2024-03-01') instanceof Date); // true\n```\n\n### new MAIN.Path(path)\n\nType: `class`\n\nThe class that parses paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path, optionally with flags. |\n\nSee [Path](../path/).\n\nExample: Parse a path\n```js\nvar path = new MAIN.Path('form.name @change');\nconsole.log(path.path); // form.name\nconsole.log(path.flags); // {\"change\":1}\n```\n\n### MAIN.Plugin\n\nType: `class`\n\nThe class of plugins.\n\nSee [Plugin](../plugin/).\n\n### MAIN.plugins\n\nType: `property`\n\nThe same object as `PLUGINS`.\n\nReturns: `Object` The same object as `PLUGINS`.\n\nSee [PLUGINS](../globals/).\n\n### MAIN.process(scope, value, target)\n\nType: `method`\n\nDelivers a value to a function or a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | The scope of a path. |\n| `value` | `Object` | yes |  | The value. |\n| `target` | `Function|String` | yes |  | A function or a path. |\n\nA function receives the value. A path is written and notified in the scope.\n\nExample: Deliver a value to a path\n```js\nMAIN.process(window, 5, 'stats.total');\nconsole.log(GET('stats.total')); // 5\n```\n\n### MAIN.ready\n\nType: `property`\n\nBecomes `true` when the library has started.\n\nReturns: `Boolean` Becomes `true` when the library has started.\n\nExample: Check the state\n```js\nON('ready', function() {\n\tconsole.log(MAIN.ready); // true\n});\n```\n\n### MAIN.resize()\n\nType: `method`\n\nMeasures the window again.\n\nThe method updates [WW](../globals/) and [WH](../globals/). When the size has changed, it updates the device class on the body and emits the `resize2` [event](../events/).\n\n### MAIN.root\n\nType: `property`\n\nThe `window` object, which is the scope of global paths.\n\nReturns: `Object` The `window` object, which is the scope of global paths.\n\nExample: Compare the objects\n```js\nconsole.log(MAIN.root === window); // true\n```\n\n### MAIN.scrollbars\n\nType: `property`\n\nThe active custom scrollbars.\n\nReturns: `Array` The active custom scrollbars.\n\nSee [SCROLLBAR()](../globals/).\n\n### MAIN.seex(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuns the same logic as `SEEX()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The target. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nSee [SEEX()](../globals/).\n\n### MAIN.set(scope, path, value)\n\nType: `method`\n\nWrites a value to any object by a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | The object to write to. |\n| `path` | `String` | yes |  | The path inside the object. |\n| `value` | `Object` | yes |  | The value. |\n\nMissing objects along the path are created. Nothing is notified.\n\nExample: Write a nested value\n```js\nvar data = {};\nMAIN.set(data, 'user.name', 'Peter');\nconsole.log(data); // {\"user\":{\"name\":\"Peter\"}}\n```\n\n### MAIN.setter(element, name, [a], [b], [c], [d])\n\nType: `method`\n\nRuns `SETTER()` for the components inside an element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Plugin` | yes |  | The element or the plugin that limits the search. |\n| `name` | `String` | yes |  | The selector and the method. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nUse `null` for all components. See [SETTER()](../globals/).\n\nExample: Limit a call to an element\n```html\n<div id=\"a\"><ui-component name=\"box\"></ui-component></div>\n<div id=\"b\"><ui-component name=\"box\"></ui-component></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.mark = function() {\n\t\tconsole.log(self.element.parent().attr('id')); // a\n\t};\n});\n\nON('ready', function() {\n\tMAIN.setter($('#a'), 'box/mark');\n});\n</script>\n```\n\n### MAIN.ua\n\nType: `property`\n\nThe detected environment: `os`, `browser` and `device`.\n\nReturns: `Object` The detected environment: `os`, `browser` and `device`.\n\nThe `device` is `desktop`, `tablet`, `mobile` or `tv`. The value is available from the `ready` event onward.\n\nExample: Read the device\n```js\nON('ready', function() {\n\tconsole.log(Object.keys(MAIN.ua)); // [\"os\",\"browser\",\"device\"]\n});\n```\n\n### MAIN.unwatch(path, [callback])\n\nType: `method`\n\nThe same function as `UNWATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `callback` | `Function` | no |  | The watcher to remove. |\n\nSee [UNWATCH()](../globals/).\n\n### MAIN.version\n\nType: `property`\n\nThe version of the library.\n\nReturns: `Number` The version of the library.\n\nExample: Read the version\n```js\nconsole.log(MAIN.version); // 20.015\n```\n\n### MAIN.watch(path, callback, [init])\n\nType: `method`\n\nThe same function as `WATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `callback` | `Function` | yes |  | The watcher. |\n| `init` | `Boolean` | no | `false` | Also calls the watcher once. |\n\nSee [WATCH()](../globals/).\n\n### MAIN.watchers\n\nType: `property`\n\nThe watchers registered with `WATCH()`.\n\nReturns: `Array` The watchers registered with `WATCH()`.\n\nSee [WATCH()](../globals/).\n","entries":[{"type":"class","name":"MAIN.Binder","signature":"MAIN.Binder","since":"","deprecated":false},{"type":"property","name":"MAIN.binders","signature":"MAIN.binders","since":"","deprecated":false},{"type":"property","name":"MAIN.caller","signature":"MAIN.caller","since":"","deprecated":false},{"type":"method","name":"MAIN.cl()","signature":"MAIN.cl(name, [callback])","since":"","deprecated":false},{"type":"class","name":"MAIN.Component","signature":"MAIN.Component","since":"","deprecated":false},{"type":"property","name":"MAIN.components","signature":"MAIN.components","since":"","deprecated":false},{"type":"property","name":"MAIN.data","signature":"MAIN.data","since":"","deprecated":false},{"type":"property","name":"MAIN.def","signature":"MAIN.def","since":"","deprecated":false},{"type":"method","name":"MAIN.emit()","signature":"MAIN.emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.events","signature":"MAIN.events","since":"","deprecated":false},{"type":"method","name":"MAIN.exec()","signature":"MAIN.exec(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.find()","signature":"MAIN.find(scope, path, callback)","since":"","deprecated":false},{"type":"method","name":"MAIN.flags()","signature":"MAIN.flags(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.free()","signature":"MAIN.free()","since":"","deprecated":false},{"type":"method","name":"MAIN.get()","signature":"MAIN.get(scope, path)","since":"","deprecated":false},{"type":"property","name":"MAIN.is20","signature":"MAIN.is20","since":"","deprecated":false},{"type":"property","name":"MAIN.loaded","signature":"MAIN.loaded","since":"","deprecated":false},{"type":"method","name":"MAIN.newbinder()","signature":"MAIN.newbinder(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newcomponent()","signature":"MAIN.newcomponent(element, name, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newimporter()","signature":"MAIN.newimporter(element, path, config)","since":"","deprecated":false},{"type":"method","name":"MAIN.newplugin()","signature":"MAIN.newplugin(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.notify()","signature":"MAIN.notify(scope, path, [onlyflags])","since":"","deprecated":false},{"type":"method","name":"MAIN.off()","signature":"MAIN.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.on()","signature":"MAIN.on(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"MAIN.parse()","signature":"MAIN.parse(type, value, [format])","since":"","deprecated":false},{"type":"class","name":"MAIN.Path","signature":"new MAIN.Path(path)","since":"","deprecated":false},{"type":"class","name":"MAIN.Plugin","signature":"MAIN.Plugin","since":"","deprecated":false},{"type":"property","name":"MAIN.plugins","signature":"MAIN.plugins","since":"","deprecated":false},{"type":"method","name":"MAIN.process()","signature":"MAIN.process(scope, value, target)","since":"","deprecated":false},{"type":"property","name":"MAIN.ready","signature":"MAIN.ready","since":"","deprecated":false},{"type":"method","name":"MAIN.resize()","signature":"MAIN.resize()","since":"","deprecated":false},{"type":"property","name":"MAIN.root","signature":"MAIN.root","since":"","deprecated":false},{"type":"property","name":"MAIN.scrollbars","signature":"MAIN.scrollbars","since":"","deprecated":false},{"type":"method","name":"MAIN.seex()","signature":"MAIN.seex(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.set()","signature":"MAIN.set(scope, path, value)","since":"","deprecated":false},{"type":"method","name":"MAIN.setter()","signature":"MAIN.setter(element, name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.ua","signature":"MAIN.ua","since":"","deprecated":false},{"type":"method","name":"MAIN.unwatch()","signature":"MAIN.unwatch(path, [callback])","since":"","deprecated":false},{"type":"property","name":"MAIN.version","signature":"MAIN.version","since":"","deprecated":false},{"type":"method","name":"MAIN.watch()","signature":"MAIN.watch(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"MAIN.watchers","signature":"MAIN.watchers","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcVG5oo61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/main/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"MAIN","summary":"Das Hauptobjekt der Bibliothek mit ihrem Zustand und ihren Low-Level-Methoden.","markdown":"---\ntitle: MAIN\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/main/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# MAIN\n\n> Das Hauptobjekt der Bibliothek mit ihrem Zustand und ihren Low-Level-Methoden.\n\n`MAIN` ist das Hauptobjekt der Bibliothek. `M`, `Total` und `jComponent` sind andere Namen für dasselbe Objekt. Es enthält den Zustand der Bibliothek und Low-Level-Methoden, die mit jedem Scope arbeiten. Für alltäglichen Code verwendest du die [globalen Funktionen](../globals/), die zusammen mit [Paths](../../guides/paths/) beschrieben sind.\n\n## API\n\n### MAIN.Binder\n\nType: `class`\n\nDie Klasse der Datenbindungen.\n\nSiehe [ui-bind](../ui-bind/).\n\n### MAIN.binders\n\nType: `property`\n\nDie aktiven Datenbindungen.\n\nReturns: `Array` Die aktiven Datenbindungen.\n\nSiehe [ui-bind](../ui-bind/).\n\n### MAIN.caller\n\nType: `property`\n\nDas Plugin, das zuletzt über `EXEC()` aufgerufen wurde.\n\nReturns: `Plugin` Das Plugin, das zuletzt über `EXEC()` aufgerufen wurde.\n\nExample: Aufrufer lesen\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.refresh = NOOP;\n});\n\nON('ready', function() {\n\tEXEC('users/refresh');\n\tconsole.log(MAIN.caller.name); // users\n});\n</script>\n```\n\n### MAIN.cl(name, [callback])\n\nType: `method`\n\nDieselbe Funktion wie `CL()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Namen der Codelisten. |\n| `callback` | `Function` | no |  | Eine Funktion, die läuft, wenn die Listen geladen sind. |\n\nSiehe [CL()](../globals/).\n\n### MAIN.Component\n\nType: `class`\n\nDie Klasse der Komponenten.\n\nSiehe [Komponente](../component/).\n\n### MAIN.components\n\nType: `property`\n\nDie aktiven Instanzen der Komponenten.\n\nReturns: `Array` Die aktiven Instanzen der Komponenten.\n\nSiehe [Komponente](../component/).\n\nExample: Komponenten zählen\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(MAIN.components.length); // 1\n});\n</script>\n```\n\n### MAIN.data\n\nType: `property`\n\nDer Speicher für Plugins mit einem generierten Path.\n\nReturns: `Object` Der Speicher für Plugins mit einem generierten Path.\n\nSiehe [DEF.path](../def/).\n\n### MAIN.def\n\nType: `property`\n\nDasselbe Objekt wie `DEF`.\n\nReturns: `Object` Dasselbe Objekt wie `DEF`.\n\nSiehe [DEF](../def/).\n\nExample: Die Objekte vergleichen\n```js\nconsole.log(MAIN.def === DEF); // true\n```\n\n### MAIN.emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nDieselbe Funktion wie `EMIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nSiehe [EMIT()](../globals/).\n\n### MAIN.events\n\nType: `property`\n\nDie globalen Event-Handler, nach Event-Namen geordnet.\n\nReturns: `Object` Die globalen Event-Handler, nach Event-Namen geordnet.\n\nSiehe [Events](../events/).\n\n### MAIN.exec(name, [a], [b], [c], [d])\n\nType: `method`\n\nFührt dieselbe Logik wie `EXEC()` aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Das Ziel des Aufrufs. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nSiehe [EXEC()](../globals/).\n\n### MAIN.find(scope, path, callback)\n\nType: `method`\n\nFindet die Komponenten eines Paths in einem Scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Der Scope, normalerweise `window`. |\n| `path` | `String` | yes |  | Der Path, optional mit Flags. |\n| `callback` | `Function` | yes |  | Eine Funktion, die das Array der Komponenten erhält. |\n\nFlags im Path schränken das Ergebnis ein: `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` und `@enabled`.\n\nExample: Komponenten finden\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tMAIN.find(window, 'form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### MAIN.flags(flags, [callback])\n\nType: `method`\n\nDieselbe Funktion wie `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Die Flags. |\n| `callback` | `Function` | no |  | Eine Funktion, die danach läuft. |\n\nSiehe [FLAGS()](../globals/).\n\n### MAIN.free()\n\nType: `method`\n\nDieselbe Funktion wie `FREE()`.\n\nSiehe [FREE()](../globals/).\n\n### MAIN.get(scope, path)\n\nType: `method`\n\nLiest über einen Path einen Wert aus einem beliebigen Objekt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Das Objekt, aus dem gelesen wird. |\n| `path` | `String` | yes |  | Der Path innerhalb des Objekts. |\n\nReturns: `Object` Der Wert.\n\nExample: Verschachtelten Wert lesen\n```js\nvar data = { user: { name: 'Peter' } };\nconsole.log(MAIN.get(data, 'user.name')); // Peter\n```\n\n### MAIN.is20\n\nType: `property`\n\nKennzeichnet die Hauptversion der Bibliothek.\n\nReturns: `Boolean` Kennzeichnet die Hauptversion der Bibliothek.\n\nDer Wert ist immer `true`.\n\nExample: Wert lesen\n```js\nconsole.log(MAIN.is20); // true\n```\n\n### MAIN.loaded\n\nType: `property`\n\nWird `true`, sobald der persistente Cache geladen ist.\n\nReturns: `Boolean` Wird `true`, sobald der persistente Cache geladen ist.\n\n### MAIN.newbinder(element, path, config, [callback])\n\nType: `method`\n\nErstellt eine Datenbindung auf einem Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Das Element. |\n| `path` | `String` | yes |  | Der Path. |\n| `config` | `String` | yes |  | Die Befehle der Bindung. |\n| `callback` | `Function` | no |  | Eine Funktion, die ausgeführt wird, wenn die Bindung erstellt wird. |\n\nSiehe [NEWUIBIND()](../globals/).\n\n### MAIN.newcomponent(element, name, path, config, [callback])\n\nType: `method`\n\nErstellt eine Komponente auf einem Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Das Element. |\n| `name` | `String` | yes |  | Der Name der Komponente. |\n| `path` | `String` | yes |  | Der Path. |\n| `config` | `String` | yes |  | Die Konfiguration. |\n| `callback` | `Function` | no |  | Eine Funktion, die ausgeführt wird, wenn die Komponente erstellt wird. |\n\nExample: Komponente per Code erstellen\n```html\n<div id=\"target\"></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.path.path); // form.name\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newcomponent($('#target'), 'box', 'form.name', '');\n});\n</script>\n```\n\n### MAIN.newimporter(element, path, config)\n\nType: `method`\n\nImportiert Inhalt in ein Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Das Element. |\n| `path` | `String` | yes |  | Die Adresse. |\n| `config` | `String` | yes |  | Die Konfiguration des Imports. |\n\nFunktioniert wie das Element [ui-import](../ui-import/).\n\nExample: Teil importieren\n```html\n<div id=\"target\"></div>\n\n<script>\nON('ready', function() {\n\tMAIN.newimporter($('#target'), '/parts/menu.html', '');\n\n\tsetTimeout(function() {\n\t\tconsole.log($('#target').html()); // <b>Menu</b>\n\t}, 400);\n});\n</script>\n```\n\n### MAIN.newplugin(element, path, config, [callback])\n\nType: `method`\n\nErstellt ein Plugin auf einem Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Das Element. |\n| `path` | `String` | yes |  | Der Name des Plugins. |\n| `config` | `String` | no |  | Die Konfiguration. |\n| `callback` | `Function` | no |  | Eine Funktion, die ausgeführt wird, wenn das Plugin erstellt wird. |\n\nExample: Plugin per Code erstellen\n```html\n<div id=\"target\"></div>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.name); // users\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newplugin($('#target'), 'users');\n});\n</script>\n```\n\n### MAIN.notify(scope, path, [onlyflags])\n\nType: `method`\n\nBenachrichtigt die Beobachter eines Paths in einem Scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Der Scope, normalerweise `window`. |\n| `path` | `String` | yes |  | Der Path, optional mit Flags. |\n| `onlyflags` | `Boolean` | no | `false` | Beschränkt die Benachrichtigung auf den Zustand der Komponenten. |\n\nMit `onlyflags` aktualisieren Komponenten nur ihren Zustand, und Watcher werden nicht ausgeführt.\n\nExample: Path benachrichtigen\n```js\nWATCH('total', function(value) {\n\tconsole.log(value); // 5\n});\n\nwindow.total = 5;\nMAIN.notify(window, 'total');\n```\n\n### MAIN.off(name, [callback])\n\nType: `method`\n\nDieselbe Funktion wie `OFF()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `callback` | `Function` | no |  | Der zu entfernende Handler. |\n\nSiehe [OFF()](../globals/).\n\n### MAIN.on(name, callback, [init])\n\nType: `method`\n\nDieselbe Funktion wie `ON()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Events. |\n| `callback` | `Function` | yes |  | Der Handler. |\n| `init` | `Boolean` | no | `false` | Ruft den Handler zusätzlich einmal auf. |\n\nSiehe [ON()](../globals/).\n\n### MAIN.parse(type, value, [format])\n\nType: `method`\n\nWandelt einen Wert in einen Typ um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | Der Typ. |\n| `value` | `Object` | yes |  | Der Wert. |\n| `format` | `String` | no |  | Das Format eines Datums. |\n\nReturns: `Object` Der umgewandelte Wert.\n\nDie Typen sind `number`, `currency`, `float`, `boolean`, `bool`, `date` und `datetime`. Zahlen richten sich nach [DEF.thousandsseparator](../def/) und [DEF.decimalseparator](../def/), Datumswerte verwenden [DEF.dateformat](../def/), wenn `format` nicht gesetzt ist. Ein Wert, der sich nicht umwandeln lässt, ergibt `null`. Andere Typen geben den Wert unverändert zurück.\n\nExample: Werte umwandeln\n```js\nconsole.log(MAIN.parse('number', '1 200.5')); // 1200.5\nconsole.log(MAIN.parse('boolean', 'yes')); // true\nconsole.log(MAIN.parse('date', '2024-03-01') instanceof Date); // true\n```\n\n### new MAIN.Path(path)\n\nType: `class`\n\nDie Klasse, die Paths parst.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, optional mit Flags. |\n\nSiehe [Path](../path/).\n\nExample: Path parsen\n```js\nvar path = new MAIN.Path('form.name @change');\nconsole.log(path.path); // form.name\nconsole.log(path.flags); // {\"change\":1}\n```\n\n### MAIN.Plugin\n\nType: `class`\n\nDie Klasse der Plugins.\n\nSiehe [Plugin](../plugin/).\n\n### MAIN.plugins\n\nType: `property`\n\nDasselbe Objekt wie `PLUGINS`.\n\nReturns: `Object` Dasselbe Objekt wie `PLUGINS`.\n\nSiehe [PLUGINS](../globals/).\n\n### MAIN.process(scope, value, target)\n\nType: `method`\n\nÜbergibt einen Wert an eine Funktion oder einen Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Der Scope eines Paths. |\n| `value` | `Object` | yes |  | Der Wert. |\n| `target` | `Function|String` | yes |  | Eine Funktion oder ein Path. |\n\nEine Funktion erhält den Wert. Ein Path wird im Scope geschrieben und benachrichtigt.\n\nExample: Wert an einen Path übergeben\n```js\nMAIN.process(window, 5, 'stats.total');\nconsole.log(GET('stats.total')); // 5\n```\n\n### MAIN.ready\n\nType: `property`\n\nWird `true`, sobald die Bibliothek gestartet ist.\n\nReturns: `Boolean` Wird `true`, sobald die Bibliothek gestartet ist.\n\nExample: Zustand prüfen\n```js\nON('ready', function() {\n\tconsole.log(MAIN.ready); // true\n});\n```\n\n### MAIN.resize()\n\nType: `method`\n\nMisst das Fenster neu aus.\n\nDie Methode aktualisiert [WW](../globals/) und [WH](../globals/). Hat sich die Größe geändert, aktualisiert sie die Geräteklasse am Body und löst das [Event](../events/) `resize2` aus.\n\n### MAIN.root\n\nType: `property`\n\nDas `window`-Objekt, also der Scope globaler Paths.\n\nReturns: `Object` Das `window`-Objekt, also der Scope globaler Paths.\n\nExample: Die Objekte vergleichen\n```js\nconsole.log(MAIN.root === window); // true\n```\n\n### MAIN.scrollbars\n\nType: `property`\n\nDie aktiven benutzerdefinierten Scrollbars.\n\nReturns: `Array` Die aktiven benutzerdefinierten Scrollbars.\n\nSiehe [SCROLLBAR()](../globals/).\n\n### MAIN.seex(name, [a], [b], [c], [d])\n\nType: `method`\n\nFührt dieselbe Logik wie `SEEX()` aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Das Ziel. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nSiehe [SEEX()](../globals/).\n\n### MAIN.set(scope, path, value)\n\nType: `method`\n\nSchreibt über einen Path einen Wert in ein beliebiges Objekt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Das Objekt, in das geschrieben wird. |\n| `path` | `String` | yes |  | Der Path innerhalb des Objekts. |\n| `value` | `Object` | yes |  | Der Wert. |\n\nFehlende Objekte entlang des Paths werden angelegt. Es wird nichts benachrichtigt.\n\nExample: Verschachtelten Wert schreiben\n```js\nvar data = {};\nMAIN.set(data, 'user.name', 'Peter');\nconsole.log(data); // {\"user\":{\"name\":\"Peter\"}}\n```\n\n### MAIN.setter(element, name, [a], [b], [c], [d])\n\nType: `method`\n\nFührt `SETTER()` für die Komponenten innerhalb eines Elements aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Plugin` | yes |  | Das Element oder das Plugin, das die Suche eingrenzt. |\n| `name` | `String` | yes |  | Der Selektor und die Methode. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nVerwende `null` für alle Komponenten. Siehe [SETTER()](../globals/).\n\nExample: Aufruf auf ein Element beschränken\n```html\n<div id=\"a\"><ui-component name=\"box\"></ui-component></div>\n<div id=\"b\"><ui-component name=\"box\"></ui-component></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.mark = function() {\n\t\tconsole.log(self.element.parent().attr('id')); // a\n\t};\n});\n\nON('ready', function() {\n\tMAIN.setter($('#a'), 'box/mark');\n});\n</script>\n```\n\n### MAIN.ua\n\nType: `property`\n\nDie erkannte Umgebung: `os`, `browser` und `device`.\n\nReturns: `Object` Die erkannte Umgebung: `os`, `browser` und `device`.\n\n`device` ist `desktop`, `tablet`, `mobile` oder `tv`. Der Wert steht ab dem Event `ready` zur Verfügung.\n\nExample: Gerät lesen\n```js\nON('ready', function() {\n\tconsole.log(Object.keys(MAIN.ua)); // [\"os\",\"browser\",\"device\"]\n});\n```\n\n### MAIN.unwatch(path, [callback])\n\nType: `method`\n\nDieselbe Funktion wie `UNWATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `callback` | `Function` | no |  | Der zu entfernende Watcher. |\n\nSiehe [UNWATCH()](../globals/).\n\n### MAIN.version\n\nType: `property`\n\nDie Version der Bibliothek.\n\nReturns: `Number` Die Version der Bibliothek.\n\nExample: Version lesen\n```js\nconsole.log(MAIN.version); // 20.015\n```\n\n### MAIN.watch(path, callback, [init])\n\nType: `method`\n\nDieselbe Funktion wie `WATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `callback` | `Function` | yes |  | Der Watcher. |\n| `init` | `Boolean` | no | `false` | Ruft den Watcher zusätzlich einmal auf. |\n\nSiehe [WATCH()](../globals/).\n\n### MAIN.watchers\n\nType: `property`\n\nDie mit `WATCH()` registrierten Watcher.\n\nReturns: `Array` Die mit `WATCH()` registrierten Watcher.\n\nSiehe [WATCH()](../globals/).\n","entries":[{"type":"class","name":"MAIN.Binder","signature":"MAIN.Binder","since":"","deprecated":false},{"type":"property","name":"MAIN.binders","signature":"MAIN.binders","since":"","deprecated":false},{"type":"property","name":"MAIN.caller","signature":"MAIN.caller","since":"","deprecated":false},{"type":"method","name":"MAIN.cl()","signature":"MAIN.cl(name, [callback])","since":"","deprecated":false},{"type":"class","name":"MAIN.Component","signature":"MAIN.Component","since":"","deprecated":false},{"type":"property","name":"MAIN.components","signature":"MAIN.components","since":"","deprecated":false},{"type":"property","name":"MAIN.data","signature":"MAIN.data","since":"","deprecated":false},{"type":"property","name":"MAIN.def","signature":"MAIN.def","since":"","deprecated":false},{"type":"method","name":"MAIN.emit()","signature":"MAIN.emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.events","signature":"MAIN.events","since":"","deprecated":false},{"type":"method","name":"MAIN.exec()","signature":"MAIN.exec(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.find()","signature":"MAIN.find(scope, path, callback)","since":"","deprecated":false},{"type":"method","name":"MAIN.flags()","signature":"MAIN.flags(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.free()","signature":"MAIN.free()","since":"","deprecated":false},{"type":"method","name":"MAIN.get()","signature":"MAIN.get(scope, path)","since":"","deprecated":false},{"type":"property","name":"MAIN.is20","signature":"MAIN.is20","since":"","deprecated":false},{"type":"property","name":"MAIN.loaded","signature":"MAIN.loaded","since":"","deprecated":false},{"type":"method","name":"MAIN.newbinder()","signature":"MAIN.newbinder(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newcomponent()","signature":"MAIN.newcomponent(element, name, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newimporter()","signature":"MAIN.newimporter(element, path, config)","since":"","deprecated":false},{"type":"method","name":"MAIN.newplugin()","signature":"MAIN.newplugin(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.notify()","signature":"MAIN.notify(scope, path, [onlyflags])","since":"","deprecated":false},{"type":"method","name":"MAIN.off()","signature":"MAIN.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.on()","signature":"MAIN.on(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"MAIN.parse()","signature":"MAIN.parse(type, value, [format])","since":"","deprecated":false},{"type":"class","name":"MAIN.Path","signature":"new MAIN.Path(path)","since":"","deprecated":false},{"type":"class","name":"MAIN.Plugin","signature":"MAIN.Plugin","since":"","deprecated":false},{"type":"property","name":"MAIN.plugins","signature":"MAIN.plugins","since":"","deprecated":false},{"type":"method","name":"MAIN.process()","signature":"MAIN.process(scope, value, target)","since":"","deprecated":false},{"type":"property","name":"MAIN.ready","signature":"MAIN.ready","since":"","deprecated":false},{"type":"method","name":"MAIN.resize()","signature":"MAIN.resize()","since":"","deprecated":false},{"type":"property","name":"MAIN.root","signature":"MAIN.root","since":"","deprecated":false},{"type":"property","name":"MAIN.scrollbars","signature":"MAIN.scrollbars","since":"","deprecated":false},{"type":"method","name":"MAIN.seex()","signature":"MAIN.seex(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.set()","signature":"MAIN.set(scope, path, value)","since":"","deprecated":false},{"type":"method","name":"MAIN.setter()","signature":"MAIN.setter(element, name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.ua","signature":"MAIN.ua","since":"","deprecated":false},{"type":"method","name":"MAIN.unwatch()","signature":"MAIN.unwatch(path, [callback])","since":"","deprecated":false},{"type":"property","name":"MAIN.version","signature":"MAIN.version","since":"","deprecated":false},{"type":"method","name":"MAIN.watch()","signature":"MAIN.watch(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"MAIN.watchers","signature":"MAIN.watchers","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcVG5oo61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/main/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"MAIN","summary":"El objeto principal de la biblioteca, con su estado y sus métodos de bajo nivel.","markdown":"---\ntitle: MAIN\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/main/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# MAIN\n\n> El objeto principal de la biblioteca, con su estado y sus métodos de bajo nivel.\n\n`MAIN` es el objeto principal de la biblioteca. `M`, `Total` y `jComponent` son otros nombres del mismo objeto. Contiene el estado de la biblioteca y métodos de bajo nivel que funcionan con cualquier scope. Para el código del día a día, usa las [funciones globales](../globals/) descritas en [Paths](../../guides/paths/).\n\n## API\n\n### MAIN.Binder\n\nType: `class`\n\nLa clase de los enlaces de datos.\n\nConsulta [ui-bind](../ui-bind/).\n\n### MAIN.binders\n\nType: `property`\n\nLos enlaces de datos activos.\n\nReturns: `Array` Los enlaces de datos activos.\n\nConsulta [ui-bind](../ui-bind/).\n\n### MAIN.caller\n\nType: `property`\n\nEl último plugin llamado mediante `EXEC()`.\n\nReturns: `Plugin` El último plugin llamado mediante `EXEC()`.\n\nExample: Leer quién hizo la llamada\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.refresh = NOOP;\n});\n\nON('ready', function() {\n\tEXEC('users/refresh');\n\tconsole.log(MAIN.caller.name); // users\n});\n</script>\n```\n\n### MAIN.cl(name, [callback])\n\nType: `method`\n\nLa misma función que `CL()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Los nombres de las listas de códigos. |\n| `callback` | `Function` | no |  | Una función que se ejecuta cuando se han cargado las listas. |\n\nConsulta [CL()](../globals/).\n\n### MAIN.Component\n\nType: `class`\n\nLa clase de los componentes.\n\nConsulta [Component](../component/).\n\n### MAIN.components\n\nType: `property`\n\nLas instancias de componentes activas.\n\nReturns: `Array` Las instancias de componentes activas.\n\nConsulta [Component](../component/).\n\nExample: Contar los componentes\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(MAIN.components.length); // 1\n});\n</script>\n```\n\n### MAIN.data\n\nType: `property`\n\nEl almacén de los plugins con un path generado.\n\nReturns: `Object` El almacén de los plugins con un path generado.\n\nConsulta [DEF.path](../def/).\n\n### MAIN.def\n\nType: `property`\n\nEl mismo objeto que `DEF`.\n\nReturns: `Object` El mismo objeto que `DEF`.\n\nConsulta [DEF](../def/).\n\nExample: Comparar los objetos\n```js\nconsole.log(MAIN.def === DEF); // true\n```\n\n### MAIN.emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nLa misma función que `EMIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nConsulta [EMIT()](../globals/).\n\n### MAIN.events\n\nType: `property`\n\nLos manejadores de eventos globales, por nombre de evento.\n\nReturns: `Object` Los manejadores de eventos globales, por nombre de evento.\n\nConsulta [Eventos](../events/).\n\n### MAIN.exec(name, [a], [b], [c], [d])\n\nType: `method`\n\nEjecuta la misma lógica que `EXEC()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El destino de la llamada. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nConsulta [EXEC()](../globals/).\n\n### MAIN.find(scope, path, callback)\n\nType: `method`\n\nBusca los componentes de un path en un scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | El scope, normalmente `window`. |\n| `path` | `String` | yes |  | El path, opcionalmente con flags. |\n| `callback` | `Function` | yes |  | Una función que recibe el array de componentes. |\n\nLos flags del path acotan el resultado: `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` y `@enabled`.\n\nExample: Buscar componentes\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tMAIN.find(window, 'form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### MAIN.flags(flags, [callback])\n\nType: `method`\n\nLa misma función que `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Los flags. |\n| `callback` | `Function` | no |  | Una función que se ejecuta después. |\n\nConsulta [FLAGS()](../globals/).\n\n### MAIN.free()\n\nType: `method`\n\nLa misma función que `FREE()`.\n\nConsulta [FREE()](../globals/).\n\n### MAIN.get(scope, path)\n\nType: `method`\n\nLee un valor de cualquier objeto mediante un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | El objeto del que se lee. |\n| `path` | `String` | yes |  | El path dentro del objeto. |\n\nReturns: `Object` El valor.\n\nExample: Leer un valor anidado\n```js\nvar data = { user: { name: 'Peter' } };\nconsole.log(MAIN.get(data, 'user.name')); // Peter\n```\n\n### MAIN.is20\n\nType: `property`\n\nIdentifica la versión mayor de la biblioteca.\n\nReturns: `Boolean` Identifica la versión mayor de la biblioteca.\n\nEl valor siempre es `true`.\n\nExample: Leer el valor\n```js\nconsole.log(MAIN.is20); // true\n```\n\n### MAIN.loaded\n\nType: `property`\n\nPasa a ser `true` cuando se carga la caché persistente.\n\nReturns: `Boolean` Pasa a ser `true` cuando se carga la caché persistente.\n\n### MAIN.newbinder(element, path, config, [callback])\n\nType: `method`\n\nCrea un enlace de datos en un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | El elemento. |\n| `path` | `String` | yes |  | El path. |\n| `config` | `String` | yes |  | Los comandos del enlace. |\n| `callback` | `Function` | no |  | Una función que se ejecuta cuando se crea el enlace. |\n\nConsulta [NEWUIBIND()](../globals/).\n\n### MAIN.newcomponent(element, name, path, config, [callback])\n\nType: `method`\n\nCrea un componente en un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | El elemento. |\n| `name` | `String` | yes |  | El nombre del componente. |\n| `path` | `String` | yes |  | El path. |\n| `config` | `String` | yes |  | La configuración. |\n| `callback` | `Function` | no |  | Una función que se ejecuta cuando se crea el componente. |\n\nExample: Crear un componente desde el código\n```html\n<div id=\"target\"></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.path.path); // form.name\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newcomponent($('#target'), 'box', 'form.name', '');\n});\n</script>\n```\n\n### MAIN.newimporter(element, path, config)\n\nType: `method`\n\nImporta contenido en un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | El elemento. |\n| `path` | `String` | yes |  | La dirección. |\n| `config` | `String` | yes |  | La configuración de la importación. |\n\nFunciona como el elemento [ui-import](../ui-import/).\n\nExample: Importar una parte\n```html\n<div id=\"target\"></div>\n\n<script>\nON('ready', function() {\n\tMAIN.newimporter($('#target'), '/parts/menu.html', '');\n\n\tsetTimeout(function() {\n\t\tconsole.log($('#target').html()); // <b>Menu</b>\n\t}, 400);\n});\n</script>\n```\n\n### MAIN.newplugin(element, path, config, [callback])\n\nType: `method`\n\nCrea un plugin en un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | El elemento. |\n| `path` | `String` | yes |  | El nombre del plugin. |\n| `config` | `String` | no |  | La configuración. |\n| `callback` | `Function` | no |  | Una función que se ejecuta cuando se crea el plugin. |\n\nExample: Crear un plugin desde el código\n```html\n<div id=\"target\"></div>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.name); // users\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newplugin($('#target'), 'users');\n});\n</script>\n```\n\n### MAIN.notify(scope, path, [onlyflags])\n\nType: `method`\n\nNotifica a los observadores de un path en un scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | El scope, normalmente `window`. |\n| `path` | `String` | yes |  | El path, opcionalmente con flags. |\n| `onlyflags` | `Boolean` | no | `false` | Limita la notificación al estado de los componentes. |\n\nCon `onlyflags`, los componentes solo actualizan su estado y los observadores no se ejecutan.\n\nExample: Notificar un path\n```js\nWATCH('total', function(value) {\n\tconsole.log(value); // 5\n});\n\nwindow.total = 5;\nMAIN.notify(window, 'total');\n```\n\n### MAIN.off(name, [callback])\n\nType: `method`\n\nLa misma función que `OFF()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `callback` | `Function` | no |  | El manejador que se va a eliminar. |\n\nConsulta [OFF()](../globals/).\n\n### MAIN.on(name, callback, [init])\n\nType: `method`\n\nLa misma función que `ON()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `callback` | `Function` | yes |  | El manejador. |\n| `init` | `Boolean` | no | `false` | Además, llama al manejador una vez. |\n\nConsulta [ON()](../globals/).\n\n### MAIN.parse(type, value, [format])\n\nType: `method`\n\nConvierte un valor a un tipo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | El tipo. |\n| `value` | `Object` | yes |  | El valor. |\n| `format` | `String` | no |  | El formato de una fecha. |\n\nReturns: `Object` El valor convertido.\n\nLos tipos son `number`, `currency`, `float`, `boolean`, `bool`, `date` y `datetime`. Los números siguen [DEF.thousandsseparator](../def/) y [DEF.decimalseparator](../def/), y las fechas usan [DEF.dateformat](../def/) cuando `format` no está definido. Un valor que no se puede convertir devuelve `null`. Los demás tipos devuelven el valor tal cual.\n\nExample: Convertir valores\n```js\nconsole.log(MAIN.parse('number', '1 200.5')); // 1200.5\nconsole.log(MAIN.parse('boolean', 'yes')); // true\nconsole.log(MAIN.parse('date', '2024-03-01') instanceof Date); // true\n```\n\n### new MAIN.Path(path)\n\nType: `class`\n\nLa clase que analiza los paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path, opcionalmente con flags. |\n\nConsulta [Path](../path/).\n\nExample: Analizar un path\n```js\nvar path = new MAIN.Path('form.name @change');\nconsole.log(path.path); // form.name\nconsole.log(path.flags); // {\"change\":1}\n```\n\n### MAIN.Plugin\n\nType: `class`\n\nLa clase de los plugins.\n\nConsulta [Plugin](../plugin/).\n\n### MAIN.plugins\n\nType: `property`\n\nEl mismo objeto que `PLUGINS`.\n\nReturns: `Object` El mismo objeto que `PLUGINS`.\n\nConsulta [PLUGINS](../globals/).\n\n### MAIN.process(scope, value, target)\n\nType: `method`\n\nEntrega un valor a una función o a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | El scope de un path. |\n| `value` | `Object` | yes |  | El valor. |\n| `target` | `Function|String` | yes |  | Una función o un path. |\n\nUna función recibe el valor. Un path se escribe y se notifica en el scope.\n\nExample: Entregar un valor a un path\n```js\nMAIN.process(window, 5, 'stats.total');\nconsole.log(GET('stats.total')); // 5\n```\n\n### MAIN.ready\n\nType: `property`\n\nPasa a ser `true` cuando la biblioteca ha arrancado.\n\nReturns: `Boolean` Pasa a ser `true` cuando la biblioteca ha arrancado.\n\nExample: Comprobar el estado\n```js\nON('ready', function() {\n\tconsole.log(MAIN.ready); // true\n});\n```\n\n### MAIN.resize()\n\nType: `method`\n\nVuelve a medir la ventana.\n\nEl método actualiza [WW](../globals/) y [WH](../globals/). Cuando el tamaño ha cambiado, actualiza la clase de dispositivo del body y emite el [evento](../events/) `resize2`.\n\n### MAIN.root\n\nType: `property`\n\nEl objeto `window`, que es el scope de los paths globales.\n\nReturns: `Object` El objeto `window`, que es el scope de los paths globales.\n\nExample: Comparar los objetos\n```js\nconsole.log(MAIN.root === window); // true\n```\n\n### MAIN.scrollbars\n\nType: `property`\n\nLas barras de desplazamiento personalizadas activas.\n\nReturns: `Array` Las barras de desplazamiento personalizadas activas.\n\nConsulta [SCROLLBAR()](../globals/).\n\n### MAIN.seex(name, [a], [b], [c], [d])\n\nType: `method`\n\nEjecuta la misma lógica que `SEEX()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El destino. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nConsulta [SEEX()](../globals/).\n\n### MAIN.set(scope, path, value)\n\nType: `method`\n\nEscribe un valor en cualquier objeto mediante un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | El objeto en el que se escribe. |\n| `path` | `String` | yes |  | El path dentro del objeto. |\n| `value` | `Object` | yes |  | El valor. |\n\nLos objetos que faltan a lo largo del path se crean. No se notifica nada.\n\nExample: Escribir un valor anidado\n```js\nvar data = {};\nMAIN.set(data, 'user.name', 'Peter');\nconsole.log(data); // {\"user\":{\"name\":\"Peter\"}}\n```\n\n### MAIN.setter(element, name, [a], [b], [c], [d])\n\nType: `method`\n\nEjecuta `SETTER()` para los componentes que hay dentro de un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Plugin` | yes |  | El elemento o el plugin que limita la búsqueda. |\n| `name` | `String` | yes |  | El selector y el método. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nUsa `null` para todos los componentes. Consulta [SETTER()](../globals/).\n\nExample: Limitar una llamada a un elemento\n```html\n<div id=\"a\"><ui-component name=\"box\"></ui-component></div>\n<div id=\"b\"><ui-component name=\"box\"></ui-component></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.mark = function() {\n\t\tconsole.log(self.element.parent().attr('id')); // a\n\t};\n});\n\nON('ready', function() {\n\tMAIN.setter($('#a'), 'box/mark');\n});\n</script>\n```\n\n### MAIN.ua\n\nType: `property`\n\nEl entorno detectado: `os`, `browser` y `device`.\n\nReturns: `Object` El entorno detectado: `os`, `browser` y `device`.\n\n`device` es `desktop`, `tablet`, `mobile` o `tv`. El valor está disponible a partir del evento `ready`.\n\nExample: Leer el dispositivo\n```js\nON('ready', function() {\n\tconsole.log(Object.keys(MAIN.ua)); // [\"os\",\"browser\",\"device\"]\n});\n```\n\n### MAIN.unwatch(path, [callback])\n\nType: `method`\n\nLa misma función que `UNWATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `callback` | `Function` | no |  | El observador que se va a eliminar. |\n\nConsulta [UNWATCH()](../globals/).\n\n### MAIN.version\n\nType: `property`\n\nLa versión de la biblioteca.\n\nReturns: `Number` La versión de la biblioteca.\n\nExample: Leer la versión\n```js\nconsole.log(MAIN.version); // 20.015\n```\n\n### MAIN.watch(path, callback, [init])\n\nType: `method`\n\nLa misma función que `WATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `callback` | `Function` | yes |  | El observador. |\n| `init` | `Boolean` | no | `false` | Además, llama al observador una vez. |\n\nConsulta [WATCH()](../globals/).\n\n### MAIN.watchers\n\nType: `property`\n\nLos observadores registrados con `WATCH()`.\n\nReturns: `Array` Los observadores registrados con `WATCH()`.\n\nConsulta [WATCH()](../globals/).\n","entries":[{"type":"class","name":"MAIN.Binder","signature":"MAIN.Binder","since":"","deprecated":false},{"type":"property","name":"MAIN.binders","signature":"MAIN.binders","since":"","deprecated":false},{"type":"property","name":"MAIN.caller","signature":"MAIN.caller","since":"","deprecated":false},{"type":"method","name":"MAIN.cl()","signature":"MAIN.cl(name, [callback])","since":"","deprecated":false},{"type":"class","name":"MAIN.Component","signature":"MAIN.Component","since":"","deprecated":false},{"type":"property","name":"MAIN.components","signature":"MAIN.components","since":"","deprecated":false},{"type":"property","name":"MAIN.data","signature":"MAIN.data","since":"","deprecated":false},{"type":"property","name":"MAIN.def","signature":"MAIN.def","since":"","deprecated":false},{"type":"method","name":"MAIN.emit()","signature":"MAIN.emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.events","signature":"MAIN.events","since":"","deprecated":false},{"type":"method","name":"MAIN.exec()","signature":"MAIN.exec(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.find()","signature":"MAIN.find(scope, path, callback)","since":"","deprecated":false},{"type":"method","name":"MAIN.flags()","signature":"MAIN.flags(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.free()","signature":"MAIN.free()","since":"","deprecated":false},{"type":"method","name":"MAIN.get()","signature":"MAIN.get(scope, path)","since":"","deprecated":false},{"type":"property","name":"MAIN.is20","signature":"MAIN.is20","since":"","deprecated":false},{"type":"property","name":"MAIN.loaded","signature":"MAIN.loaded","since":"","deprecated":false},{"type":"method","name":"MAIN.newbinder()","signature":"MAIN.newbinder(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newcomponent()","signature":"MAIN.newcomponent(element, name, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newimporter()","signature":"MAIN.newimporter(element, path, config)","since":"","deprecated":false},{"type":"method","name":"MAIN.newplugin()","signature":"MAIN.newplugin(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.notify()","signature":"MAIN.notify(scope, path, [onlyflags])","since":"","deprecated":false},{"type":"method","name":"MAIN.off()","signature":"MAIN.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.on()","signature":"MAIN.on(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"MAIN.parse()","signature":"MAIN.parse(type, value, [format])","since":"","deprecated":false},{"type":"class","name":"MAIN.Path","signature":"new MAIN.Path(path)","since":"","deprecated":false},{"type":"class","name":"MAIN.Plugin","signature":"MAIN.Plugin","since":"","deprecated":false},{"type":"property","name":"MAIN.plugins","signature":"MAIN.plugins","since":"","deprecated":false},{"type":"method","name":"MAIN.process()","signature":"MAIN.process(scope, value, target)","since":"","deprecated":false},{"type":"property","name":"MAIN.ready","signature":"MAIN.ready","since":"","deprecated":false},{"type":"method","name":"MAIN.resize()","signature":"MAIN.resize()","since":"","deprecated":false},{"type":"property","name":"MAIN.root","signature":"MAIN.root","since":"","deprecated":false},{"type":"property","name":"MAIN.scrollbars","signature":"MAIN.scrollbars","since":"","deprecated":false},{"type":"method","name":"MAIN.seex()","signature":"MAIN.seex(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.set()","signature":"MAIN.set(scope, path, value)","since":"","deprecated":false},{"type":"method","name":"MAIN.setter()","signature":"MAIN.setter(element, name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.ua","signature":"MAIN.ua","since":"","deprecated":false},{"type":"method","name":"MAIN.unwatch()","signature":"MAIN.unwatch(path, [callback])","since":"","deprecated":false},{"type":"property","name":"MAIN.version","signature":"MAIN.version","since":"","deprecated":false},{"type":"method","name":"MAIN.watch()","signature":"MAIN.watch(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"MAIN.watchers","signature":"MAIN.watchers","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcVG5oo61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/main/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"MAIN","summary":"L'objet principal de la bibliothèque, avec son état et ses méthodes de bas niveau.","markdown":"---\ntitle: MAIN\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/main/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# MAIN\n\n> L'objet principal de la bibliothèque, avec son état et ses méthodes de bas niveau.\n\n`MAIN` est l'objet principal de la bibliothèque. `M`, `Total` et `jComponent` sont d'autres noms du même objet. Il contient l'état de la bibliothèque et des méthodes de bas niveau qui fonctionnent avec n'importe quel scope. Pour le code courant, utilise les [fonctions globales](../globals/) décrites avec les [Paths](../../guides/paths/).\n\n## API\n\n### MAIN.Binder\n\nType: `class`\n\nLa classe des liaisons de données.\n\nVoir [ui-bind](../ui-bind/).\n\n### MAIN.binders\n\nType: `property`\n\nLes liaisons de données actives.\n\nReturns: `Array` Les liaisons de données actives.\n\nVoir [ui-bind](../ui-bind/).\n\n### MAIN.caller\n\nType: `property`\n\nLe plugin appelé en dernier via `EXEC()`.\n\nReturns: `Plugin` Le plugin appelé en dernier via `EXEC()`.\n\nExample: Lire l'appelant\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.refresh = NOOP;\n});\n\nON('ready', function() {\n\tEXEC('users/refresh');\n\tconsole.log(MAIN.caller.name); // users\n});\n</script>\n```\n\n### MAIN.cl(name, [callback])\n\nType: `method`\n\nLa même fonction que `CL()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Les noms des listes de codes. |\n| `callback` | `Function` | no |  | Une fonction qui s'exécute quand les listes sont chargées. |\n\nVoir [CL()](../globals/).\n\n### MAIN.Component\n\nType: `class`\n\nLa classe des composants.\n\nVoir [Component](../component/).\n\n### MAIN.components\n\nType: `property`\n\nLes instances de composants actives.\n\nReturns: `Array` Les instances de composants actives.\n\nVoir [Component](../component/).\n\nExample: Compter les composants\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(MAIN.components.length); // 1\n});\n</script>\n```\n\n### MAIN.data\n\nType: `property`\n\nLe stockage des plugins dont le path est généré.\n\nReturns: `Object` Le stockage des plugins dont le path est généré.\n\nVoir [DEF.path](../def/).\n\n### MAIN.def\n\nType: `property`\n\nLe même objet que `DEF`.\n\nReturns: `Object` Le même objet que `DEF`.\n\nVoir [DEF](../def/).\n\nExample: Comparer les objets\n```js\nconsole.log(MAIN.def === DEF); // true\n```\n\n### MAIN.emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nLa même fonction que `EMIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nVoir [EMIT()](../globals/).\n\n### MAIN.events\n\nType: `property`\n\nLes gestionnaires d'événements globaux, par nom d'événement.\n\nReturns: `Object` Les gestionnaires d'événements globaux, par nom d'événement.\n\nVoir [Événements](../events/).\n\n### MAIN.exec(name, [a], [b], [c], [d])\n\nType: `method`\n\nExécute la même logique que `EXEC()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La cible de l'appel. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nVoir [EXEC()](../globals/).\n\n### MAIN.find(scope, path, callback)\n\nType: `method`\n\nTrouve les composants d'un path dans un scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Le scope, en général `window`. |\n| `path` | `String` | yes |  | Le path, éventuellement avec des flags. |\n| `callback` | `Function` | yes |  | Une fonction qui reçoit le tableau des composants. |\n\nLes flags du path affinent le résultat : `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` et `@enabled`.\n\nExample: Trouver des composants\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tMAIN.find(window, 'form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### MAIN.flags(flags, [callback])\n\nType: `method`\n\nLa même fonction que `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Les flags. |\n| `callback` | `Function` | no |  | Une fonction qui s'exécute ensuite. |\n\nVoir [FLAGS()](../globals/).\n\n### MAIN.free()\n\nType: `method`\n\nLa même fonction que `FREE()`.\n\nVoir [FREE()](../globals/).\n\n### MAIN.get(scope, path)\n\nType: `method`\n\nLit une valeur dans n'importe quel objet à partir d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'objet à lire. |\n| `path` | `String` | yes |  | Le path à l'intérieur de l'objet. |\n\nReturns: `Object` La valeur.\n\nExample: Lire une valeur imbriquée\n```js\nvar data = { user: { name: 'Peter' } };\nconsole.log(MAIN.get(data, 'user.name')); // Peter\n```\n\n### MAIN.is20\n\nType: `property`\n\nIdentifie la version majeure de la bibliothèque.\n\nReturns: `Boolean` Identifie la version majeure de la bibliothèque.\n\nLa valeur est toujours `true`.\n\nExample: Lire la valeur\n```js\nconsole.log(MAIN.is20); // true\n```\n\n### MAIN.loaded\n\nType: `property`\n\nPasse à `true` quand le cache persistant est chargé.\n\nReturns: `Boolean` Passe à `true` quand le cache persistant est chargé.\n\n### MAIN.newbinder(element, path, config, [callback])\n\nType: `method`\n\nCrée une liaison de données sur un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'élément. |\n| `path` | `String` | yes |  | Le path. |\n| `config` | `String` | yes |  | Les commandes de liaison. |\n| `callback` | `Function` | no |  | Une fonction qui s'exécute quand la liaison est créée. |\n\nVoir [NEWUIBIND()](../globals/).\n\n### MAIN.newcomponent(element, name, path, config, [callback])\n\nType: `method`\n\nCrée un composant sur un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'élément. |\n| `name` | `String` | yes |  | Le nom du composant. |\n| `path` | `String` | yes |  | Le path. |\n| `config` | `String` | yes |  | La configuration. |\n| `callback` | `Function` | no |  | Une fonction qui s'exécute quand le composant est créé. |\n\nExample: Créer un composant depuis le code\n```html\n<div id=\"target\"></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.path.path); // form.name\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newcomponent($('#target'), 'box', 'form.name', '');\n});\n</script>\n```\n\n### MAIN.newimporter(element, path, config)\n\nType: `method`\n\nImporte du contenu dans un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'élément. |\n| `path` | `String` | yes |  | L'adresse. |\n| `config` | `String` | yes |  | La configuration de l'import. |\n\nFonctionne comme l'élément [ui-import](../ui-import/).\n\nExample: Importer une partie\n```html\n<div id=\"target\"></div>\n\n<script>\nON('ready', function() {\n\tMAIN.newimporter($('#target'), '/parts/menu.html', '');\n\n\tsetTimeout(function() {\n\t\tconsole.log($('#target').html()); // <b>Menu</b>\n\t}, 400);\n});\n</script>\n```\n\n### MAIN.newplugin(element, path, config, [callback])\n\nType: `method`\n\nCrée un plugin sur un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'élément. |\n| `path` | `String` | yes |  | Le nom du plugin. |\n| `config` | `String` | no |  | La configuration. |\n| `callback` | `Function` | no |  | Une fonction qui s'exécute quand le plugin est créé. |\n\nExample: Créer un plugin depuis le code\n```html\n<div id=\"target\"></div>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.name); // users\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newplugin($('#target'), 'users');\n});\n</script>\n```\n\n### MAIN.notify(scope, path, [onlyflags])\n\nType: `method`\n\nNotifie les observateurs d'un path dans un scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Le scope, en général `window`. |\n| `path` | `String` | yes |  | Le path, éventuellement avec des flags. |\n| `onlyflags` | `Boolean` | no | `false` | Limite la notification à l'état des composants. |\n\nAvec `onlyflags`, les composants actualisent seulement leur état et les observateurs ne s'exécutent pas.\n\nExample: Notifier un path\n```js\nWATCH('total', function(value) {\n\tconsole.log(value); // 5\n});\n\nwindow.total = 5;\nMAIN.notify(window, 'total');\n```\n\n### MAIN.off(name, [callback])\n\nType: `method`\n\nLa même fonction que `OFF()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `callback` | `Function` | no |  | Le gestionnaire à supprimer. |\n\nVoir [OFF()](../globals/).\n\n### MAIN.on(name, callback, [init])\n\nType: `method`\n\nLa même fonction que `ON()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `callback` | `Function` | yes |  | Le gestionnaire. |\n| `init` | `Boolean` | no | `false` | Appelle aussi le gestionnaire une fois. |\n\nVoir [ON()](../globals/).\n\n### MAIN.parse(type, value, [format])\n\nType: `method`\n\nConvertit une valeur vers un type.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | Le type. |\n| `value` | `Object` | yes |  | La valeur. |\n| `format` | `String` | no |  | Le format d'une date. |\n\nReturns: `Object` La valeur convertie.\n\nLes types sont `number`, `currency`, `float`, `boolean`, `bool`, `date` et `datetime`. Les nombres suivent [DEF.thousandsseparator](../def/) et [DEF.decimalseparator](../def/), et les dates utilisent [DEF.dateformat](../def/) quand `format` n'est pas défini. Une valeur impossible à convertir renvoie `null`. Les autres types renvoient la valeur telle quelle.\n\nExample: Convertir des valeurs\n```js\nconsole.log(MAIN.parse('number', '1 200.5')); // 1200.5\nconsole.log(MAIN.parse('boolean', 'yes')); // true\nconsole.log(MAIN.parse('date', '2024-03-01') instanceof Date); // true\n```\n\n### new MAIN.Path(path)\n\nType: `class`\n\nLa classe qui analyse les paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path, éventuellement avec des flags. |\n\nVoir [Path](../path/).\n\nExample: Analyser un path\n```js\nvar path = new MAIN.Path('form.name @change');\nconsole.log(path.path); // form.name\nconsole.log(path.flags); // {\"change\":1}\n```\n\n### MAIN.Plugin\n\nType: `class`\n\nLa classe des plugins.\n\nVoir [Plugin](../plugin/).\n\n### MAIN.plugins\n\nType: `property`\n\nLe même objet que `PLUGINS`.\n\nReturns: `Object` Le même objet que `PLUGINS`.\n\nVoir [PLUGINS](../globals/).\n\n### MAIN.process(scope, value, target)\n\nType: `method`\n\nTransmet une valeur à une fonction ou à un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Le scope d'un path. |\n| `value` | `Object` | yes |  | La valeur. |\n| `target` | `Function|String` | yes |  | Une fonction ou un path. |\n\nUne fonction reçoit la valeur. Un path est écrit et notifié dans le scope.\n\nExample: Transmettre une valeur à un path\n```js\nMAIN.process(window, 5, 'stats.total');\nconsole.log(GET('stats.total')); // 5\n```\n\n### MAIN.ready\n\nType: `property`\n\nPasse à `true` quand la bibliothèque a démarré.\n\nReturns: `Boolean` Passe à `true` quand la bibliothèque a démarré.\n\nExample: Vérifier l'état\n```js\nON('ready', function() {\n\tconsole.log(MAIN.ready); // true\n});\n```\n\n### MAIN.resize()\n\nType: `method`\n\nMesure à nouveau la fenêtre.\n\nLa méthode met à jour [WW](../globals/) et [WH](../globals/). Quand la taille a changé, elle met à jour la classe d'appareil sur le body et émet l'[événement](../events/) `resize2`.\n\n### MAIN.root\n\nType: `property`\n\nL'objet `window`, qui est le scope des paths globaux.\n\nReturns: `Object` L'objet `window`, qui est le scope des paths globaux.\n\nExample: Comparer les objets\n```js\nconsole.log(MAIN.root === window); // true\n```\n\n### MAIN.scrollbars\n\nType: `property`\n\nLes barres de défilement personnalisées actives.\n\nReturns: `Array` Les barres de défilement personnalisées actives.\n\nConsulte [SCROLLBAR()](../globals/).\n\n### MAIN.seex(name, [a], [b], [c], [d])\n\nType: `method`\n\nExécute la même logique que `SEEX()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La cible. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nVoir [SEEX()](../globals/).\n\n### MAIN.set(scope, path, value)\n\nType: `method`\n\nÉcrit une valeur dans n'importe quel objet à partir d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'objet dans lequel écrire. |\n| `path` | `String` | yes |  | Le path à l'intérieur de l'objet. |\n| `value` | `Object` | yes |  | La valeur. |\n\nLes objets manquants le long du path sont créés. Rien n'est notifié.\n\nExample: Écrire une valeur imbriquée\n```js\nvar data = {};\nMAIN.set(data, 'user.name', 'Peter');\nconsole.log(data); // {\"user\":{\"name\":\"Peter\"}}\n```\n\n### MAIN.setter(element, name, [a], [b], [c], [d])\n\nType: `method`\n\nExécute `SETTER()` pour les composants situés dans un élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Plugin` | yes |  | L'élément ou le plugin qui limite la recherche. |\n| `name` | `String` | yes |  | Le sélecteur et la méthode. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nUtilise `null` pour tous les composants. Voir [SETTER()](../globals/).\n\nExample: Limiter un appel à un élément\n```html\n<div id=\"a\"><ui-component name=\"box\"></ui-component></div>\n<div id=\"b\"><ui-component name=\"box\"></ui-component></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.mark = function() {\n\t\tconsole.log(self.element.parent().attr('id')); // a\n\t};\n});\n\nON('ready', function() {\n\tMAIN.setter($('#a'), 'box/mark');\n});\n</script>\n```\n\n### MAIN.ua\n\nType: `property`\n\nL'environnement détecté : `os`, `browser` et `device`.\n\nReturns: `Object` L'environnement détecté : `os`, `browser` et `device`.\n\n`device` vaut `desktop`, `tablet`, `mobile` ou `tv`. La valeur est disponible à partir de l'événement `ready`.\n\nExample: Lire l'appareil\n```js\nON('ready', function() {\n\tconsole.log(Object.keys(MAIN.ua)); // [\"os\",\"browser\",\"device\"]\n});\n```\n\n### MAIN.unwatch(path, [callback])\n\nType: `method`\n\nLa même fonction que `UNWATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `callback` | `Function` | no |  | L'observateur à retirer. |\n\nVoir [UNWATCH()](../globals/).\n\n### MAIN.version\n\nType: `property`\n\nLa version de la bibliothèque.\n\nReturns: `Number` La version de la bibliothèque.\n\nExample: Lire la version\n```js\nconsole.log(MAIN.version); // 20.015\n```\n\n### MAIN.watch(path, callback, [init])\n\nType: `method`\n\nLa même fonction que `WATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `callback` | `Function` | yes |  | L'observateur. |\n| `init` | `Boolean` | no | `false` | Appelle aussi l'observateur une fois. |\n\nVoir [WATCH()](../globals/).\n\n### MAIN.watchers\n\nType: `property`\n\nLes observateurs enregistrés avec `WATCH()`.\n\nReturns: `Array` Les observateurs enregistrés avec `WATCH()`.\n\nVoir [WATCH()](../globals/).\n","entries":[{"type":"class","name":"MAIN.Binder","signature":"MAIN.Binder","since":"","deprecated":false},{"type":"property","name":"MAIN.binders","signature":"MAIN.binders","since":"","deprecated":false},{"type":"property","name":"MAIN.caller","signature":"MAIN.caller","since":"","deprecated":false},{"type":"method","name":"MAIN.cl()","signature":"MAIN.cl(name, [callback])","since":"","deprecated":false},{"type":"class","name":"MAIN.Component","signature":"MAIN.Component","since":"","deprecated":false},{"type":"property","name":"MAIN.components","signature":"MAIN.components","since":"","deprecated":false},{"type":"property","name":"MAIN.data","signature":"MAIN.data","since":"","deprecated":false},{"type":"property","name":"MAIN.def","signature":"MAIN.def","since":"","deprecated":false},{"type":"method","name":"MAIN.emit()","signature":"MAIN.emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.events","signature":"MAIN.events","since":"","deprecated":false},{"type":"method","name":"MAIN.exec()","signature":"MAIN.exec(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.find()","signature":"MAIN.find(scope, path, callback)","since":"","deprecated":false},{"type":"method","name":"MAIN.flags()","signature":"MAIN.flags(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.free()","signature":"MAIN.free()","since":"","deprecated":false},{"type":"method","name":"MAIN.get()","signature":"MAIN.get(scope, path)","since":"","deprecated":false},{"type":"property","name":"MAIN.is20","signature":"MAIN.is20","since":"","deprecated":false},{"type":"property","name":"MAIN.loaded","signature":"MAIN.loaded","since":"","deprecated":false},{"type":"method","name":"MAIN.newbinder()","signature":"MAIN.newbinder(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newcomponent()","signature":"MAIN.newcomponent(element, name, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newimporter()","signature":"MAIN.newimporter(element, path, config)","since":"","deprecated":false},{"type":"method","name":"MAIN.newplugin()","signature":"MAIN.newplugin(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.notify()","signature":"MAIN.notify(scope, path, [onlyflags])","since":"","deprecated":false},{"type":"method","name":"MAIN.off()","signature":"MAIN.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.on()","signature":"MAIN.on(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"MAIN.parse()","signature":"MAIN.parse(type, value, [format])","since":"","deprecated":false},{"type":"class","name":"MAIN.Path","signature":"new MAIN.Path(path)","since":"","deprecated":false},{"type":"class","name":"MAIN.Plugin","signature":"MAIN.Plugin","since":"","deprecated":false},{"type":"property","name":"MAIN.plugins","signature":"MAIN.plugins","since":"","deprecated":false},{"type":"method","name":"MAIN.process()","signature":"MAIN.process(scope, value, target)","since":"","deprecated":false},{"type":"property","name":"MAIN.ready","signature":"MAIN.ready","since":"","deprecated":false},{"type":"method","name":"MAIN.resize()","signature":"MAIN.resize()","since":"","deprecated":false},{"type":"property","name":"MAIN.root","signature":"MAIN.root","since":"","deprecated":false},{"type":"property","name":"MAIN.scrollbars","signature":"MAIN.scrollbars","since":"","deprecated":false},{"type":"method","name":"MAIN.seex()","signature":"MAIN.seex(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.set()","signature":"MAIN.set(scope, path, value)","since":"","deprecated":false},{"type":"method","name":"MAIN.setter()","signature":"MAIN.setter(element, name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.ua","signature":"MAIN.ua","since":"","deprecated":false},{"type":"method","name":"MAIN.unwatch()","signature":"MAIN.unwatch(path, [callback])","since":"","deprecated":false},{"type":"property","name":"MAIN.version","signature":"MAIN.version","since":"","deprecated":false},{"type":"method","name":"MAIN.watch()","signature":"MAIN.watch(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"MAIN.watchers","signature":"MAIN.watchers","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcVG5oo61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/main/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"MAIN","summary":"L'oggetto principale della libreria, con il suo stato e i suoi metodi di basso livello.","markdown":"---\ntitle: MAIN\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/main/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# MAIN\n\n> L'oggetto principale della libreria, con il suo stato e i suoi metodi di basso livello.\n\n`MAIN` è l'oggetto principale della libreria. `M`, `Total` e `jComponent` sono altri nomi dello stesso oggetto. Contiene lo stato della libreria e metodi di basso livello che funzionano con qualsiasi scope. Per il codice di tutti i giorni, usa le [funzioni globali](../globals/) descritte in [Path](../../guides/paths/).\n\n## API\n\n### MAIN.Binder\n\nType: `class`\n\nLa classe delle associazioni dei dati.\n\nVedi [ui-bind](../ui-bind/).\n\n### MAIN.binders\n\nType: `property`\n\nLe associazioni dei dati attive.\n\nReturns: `Array` Le associazioni dei dati attive.\n\nVedi [ui-bind](../ui-bind/).\n\n### MAIN.caller\n\nType: `property`\n\nL'ultimo plugin chiamato tramite `EXEC()`.\n\nReturns: `Plugin` L'ultimo plugin chiamato tramite `EXEC()`.\n\nExample: Leggi il chiamante\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.refresh = NOOP;\n});\n\nON('ready', function() {\n\tEXEC('users/refresh');\n\tconsole.log(MAIN.caller.name); // users\n});\n</script>\n```\n\n### MAIN.cl(name, [callback])\n\nType: `method`\n\nLa stessa funzione di `CL()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | I nomi degli elenchi di codici. |\n| `callback` | `Function` | no |  | Una funzione eseguita quando gli elenchi sono stati caricati. |\n\nVedi [CL()](../globals/).\n\n### MAIN.Component\n\nType: `class`\n\nLa classe dei componenti.\n\nVedi [Componente](../component/).\n\n### MAIN.components\n\nType: `property`\n\nLe istanze attive dei componenti.\n\nReturns: `Array` Le istanze attive dei componenti.\n\nVedi [Componente](../component/).\n\nExample: Conta i componenti\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(MAIN.components.length); // 1\n});\n</script>\n```\n\n### MAIN.data\n\nType: `property`\n\nL'archivio dei plugin con un path generato.\n\nReturns: `Object` L'archivio dei plugin con un path generato.\n\nVedi [DEF.path](../def/).\n\n### MAIN.def\n\nType: `property`\n\nLo stesso oggetto di `DEF`.\n\nReturns: `Object` Lo stesso oggetto di `DEF`.\n\nVedi [DEF](../def/).\n\nExample: Confronta gli oggetti\n```js\nconsole.log(MAIN.def === DEF); // true\n```\n\n### MAIN.emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nLa stessa funzione di `EMIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nVedi [EMIT()](../globals/).\n\n### MAIN.events\n\nType: `property`\n\nI gestori degli eventi globali, per nome dell'evento.\n\nReturns: `Object` I gestori degli eventi globali, per nome dell'evento.\n\nVedi [Eventi](../events/).\n\n### MAIN.exec(name, [a], [b], [c], [d])\n\nType: `method`\n\nEsegue la stessa logica di `EXEC()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La destinazione della chiamata. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nVedi [EXEC()](../globals/).\n\n### MAIN.find(scope, path, callback)\n\nType: `method`\n\nTrova i componenti di un path in uno scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Lo scope, di solito `window`. |\n| `path` | `String` | yes |  | Il path, eventualmente con dei flag. |\n| `callback` | `Function` | yes |  | Una funzione che riceve l'array dei componenti. |\n\nI flag nel path restringono il risultato: `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` e `@enabled`.\n\nExample: Trova i componenti\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tMAIN.find(window, 'form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### MAIN.flags(flags, [callback])\n\nType: `method`\n\nLa stessa funzione di `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | I flag. |\n| `callback` | `Function` | no |  | Una funzione eseguita al termine. |\n\nVedi [FLAGS()](../globals/).\n\n### MAIN.free()\n\nType: `method`\n\nLa stessa funzione di `FREE()`.\n\nVedi [FREE()](../globals/).\n\n### MAIN.get(scope, path)\n\nType: `method`\n\nLegge un valore da qualsiasi oggetto tramite un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'oggetto da cui leggere. |\n| `path` | `String` | yes |  | Il path all'interno dell'oggetto. |\n\nReturns: `Object` Il valore.\n\nExample: Leggi un valore annidato\n```js\nvar data = { user: { name: 'Peter' } };\nconsole.log(MAIN.get(data, 'user.name')); // Peter\n```\n\n### MAIN.is20\n\nType: `property`\n\nIdentifica la versione principale della libreria.\n\nReturns: `Boolean` Identifica la versione principale della libreria.\n\nIl valore è sempre `true`.\n\nExample: Leggi il valore\n```js\nconsole.log(MAIN.is20); // true\n```\n\n### MAIN.loaded\n\nType: `property`\n\nDiventa `true` quando la cache persistente è caricata.\n\nReturns: `Boolean` Diventa `true` quando la cache persistente è caricata.\n\n### MAIN.newbinder(element, path, config, [callback])\n\nType: `method`\n\nCrea un'associazione dei dati su un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'elemento. |\n| `path` | `String` | yes |  | Il path. |\n| `config` | `String` | yes |  | I comandi di associazione. |\n| `callback` | `Function` | no |  | Una funzione eseguita quando viene creata l'associazione. |\n\nVedi [NEWUIBIND()](../globals/).\n\n### MAIN.newcomponent(element, name, path, config, [callback])\n\nType: `method`\n\nCrea un componente su un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'elemento. |\n| `name` | `String` | yes |  | Il nome del componente. |\n| `path` | `String` | yes |  | Il path. |\n| `config` | `String` | yes |  | La configurazione. |\n| `callback` | `Function` | no |  | Una funzione eseguita quando viene creato il componente. |\n\nExample: Crea un componente dal codice\n```html\n<div id=\"target\"></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.path.path); // form.name\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newcomponent($('#target'), 'box', 'form.name', '');\n});\n</script>\n```\n\n### MAIN.newimporter(element, path, config)\n\nType: `method`\n\nImporta contenuti in un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'elemento. |\n| `path` | `String` | yes |  | L'indirizzo. |\n| `config` | `String` | yes |  | La configurazione dell'importazione. |\n\nFunziona come l'elemento [ui-import](../ui-import/).\n\nExample: Importa una parte\n```html\n<div id=\"target\"></div>\n\n<script>\nON('ready', function() {\n\tMAIN.newimporter($('#target'), '/parts/menu.html', '');\n\n\tsetTimeout(function() {\n\t\tconsole.log($('#target').html()); // <b>Menu</b>\n\t}, 400);\n});\n</script>\n```\n\n### MAIN.newplugin(element, path, config, [callback])\n\nType: `method`\n\nCrea un plugin su un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | L'elemento. |\n| `path` | `String` | yes |  | Il nome del plugin. |\n| `config` | `String` | no |  | La configurazione. |\n| `callback` | `Function` | no |  | Una funzione eseguita quando viene creato il plugin. |\n\nExample: Crea un plugin dal codice\n```html\n<div id=\"target\"></div>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.name); // users\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newplugin($('#target'), 'users');\n});\n</script>\n```\n\n### MAIN.notify(scope, path, [onlyflags])\n\nType: `method`\n\nNotifica gli osservatori di un path in uno scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Lo scope, di solito `window`. |\n| `path` | `String` | yes |  | Il path, eventualmente con dei flag. |\n| `onlyflags` | `Boolean` | no | `false` | Limita la notifica allo stato dei componenti. |\n\nCon `onlyflags`, i componenti aggiornano solo il proprio stato e gli osservatori non vengono eseguiti.\n\nExample: Notifica un path\n```js\nWATCH('total', function(value) {\n\tconsole.log(value); // 5\n});\n\nwindow.total = 5;\nMAIN.notify(window, 'total');\n```\n\n### MAIN.off(name, [callback])\n\nType: `method`\n\nLa stessa funzione di `OFF()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `callback` | `Function` | no |  | Il gestore da rimuovere. |\n\nVedi [OFF()](../globals/).\n\n### MAIN.on(name, callback, [init])\n\nType: `method`\n\nLa stessa funzione di `ON()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `callback` | `Function` | yes |  | Il gestore. |\n| `init` | `Boolean` | no | `false` | Chiama anche il gestore una volta. |\n\nVedi [ON()](../globals/).\n\n### MAIN.parse(type, value, [format])\n\nType: `method`\n\nConverte un valore in un tipo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | Il tipo. |\n| `value` | `Object` | yes |  | Il valore. |\n| `format` | `String` | no |  | Il formato di una data. |\n\nReturns: `Object` Il valore convertito.\n\nI tipi sono `number`, `currency`, `float`, `boolean`, `bool`, `date` e `datetime`. I numeri seguono [DEF.thousandsseparator](../def/) e [DEF.decimalseparator](../def/), mentre le date usano [DEF.dateformat](../def/) quando `format` non è impostato. Un valore che non può essere convertito restituisce `null`. Gli altri tipi restituiscono il valore così com'è.\n\nExample: Converti i valori\n```js\nconsole.log(MAIN.parse('number', '1 200.5')); // 1200.5\nconsole.log(MAIN.parse('boolean', 'yes')); // true\nconsole.log(MAIN.parse('date', '2024-03-01') instanceof Date); // true\n```\n\n### new MAIN.Path(path)\n\nType: `class`\n\nLa classe che analizza i path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path, eventualmente con dei flag. |\n\nVedi [Path](../path/).\n\nExample: Analizza un path\n```js\nvar path = new MAIN.Path('form.name @change');\nconsole.log(path.path); // form.name\nconsole.log(path.flags); // {\"change\":1}\n```\n\n### MAIN.Plugin\n\nType: `class`\n\nLa classe dei plugin.\n\nVedi [Plugin](../plugin/).\n\n### MAIN.plugins\n\nType: `property`\n\nLo stesso oggetto di `PLUGINS`.\n\nReturns: `Object` Lo stesso oggetto di `PLUGINS`.\n\nVedi [PLUGINS](../globals/).\n\n### MAIN.process(scope, value, target)\n\nType: `method`\n\nConsegna un valore a una funzione o a un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Lo scope di un path. |\n| `value` | `Object` | yes |  | Il valore. |\n| `target` | `Function|String` | yes |  | Una funzione o un path. |\n\nUna funzione riceve il valore. Un path viene scritto e notificato nello scope.\n\nExample: Consegna un valore a un path\n```js\nMAIN.process(window, 5, 'stats.total');\nconsole.log(GET('stats.total')); // 5\n```\n\n### MAIN.ready\n\nType: `property`\n\nDiventa `true` quando la libreria è stata avviata.\n\nReturns: `Boolean` Diventa `true` quando la libreria è stata avviata.\n\nExample: Controlla lo stato\n```js\nON('ready', function() {\n\tconsole.log(MAIN.ready); // true\n});\n```\n\n### MAIN.resize()\n\nType: `method`\n\nMisura di nuovo la finestra.\n\nIl metodo aggiorna [WW](../globals/) e [WH](../globals/). Quando le dimensioni sono cambiate, aggiorna la classe del dispositivo sul body ed emette l'[evento](../events/) `resize2`.\n\n### MAIN.root\n\nType: `property`\n\nL'oggetto `window`, che è lo scope dei path globali.\n\nReturns: `Object` L'oggetto `window`, che è lo scope dei path globali.\n\nExample: Confronta gli oggetti\n```js\nconsole.log(MAIN.root === window); // true\n```\n\n### MAIN.scrollbars\n\nType: `property`\n\nLe barre di scorrimento personalizzate attive.\n\nReturns: `Array` Le barre di scorrimento personalizzate attive.\n\nConsulta [SCROLLBAR()](../globals/).\n\n### MAIN.seex(name, [a], [b], [c], [d])\n\nType: `method`\n\nEsegue la stessa logica di `SEEX()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La destinazione. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nVedi [SEEX()](../globals/).\n\n### MAIN.set(scope, path, value)\n\nType: `method`\n\nScrive un valore in qualsiasi oggetto tramite un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'oggetto in cui scrivere. |\n| `path` | `String` | yes |  | Il path all'interno dell'oggetto. |\n| `value` | `Object` | yes |  | Il valore. |\n\nGli oggetti mancanti lungo il path vengono creati. Non viene notificato nulla.\n\nExample: Scrivi un valore annidato\n```js\nvar data = {};\nMAIN.set(data, 'user.name', 'Peter');\nconsole.log(data); // {\"user\":{\"name\":\"Peter\"}}\n```\n\n### MAIN.setter(element, name, [a], [b], [c], [d])\n\nType: `method`\n\nEsegue `SETTER()` per i componenti all'interno di un elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Plugin` | yes |  | L'elemento o il plugin che limita la ricerca. |\n| `name` | `String` | yes |  | Il selettore e il metodo. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nUsa `null` per tutti i componenti. Vedi [SETTER()](../globals/).\n\nExample: Limita una chiamata a un elemento\n```html\n<div id=\"a\"><ui-component name=\"box\"></ui-component></div>\n<div id=\"b\"><ui-component name=\"box\"></ui-component></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.mark = function() {\n\t\tconsole.log(self.element.parent().attr('id')); // a\n\t};\n});\n\nON('ready', function() {\n\tMAIN.setter($('#a'), 'box/mark');\n});\n</script>\n```\n\n### MAIN.ua\n\nType: `property`\n\nL'ambiente rilevato: `os`, `browser` e `device`.\n\nReturns: `Object` L'ambiente rilevato: `os`, `browser` e `device`.\n\n`device` può essere `desktop`, `tablet`, `mobile` o `tv`. Il valore è disponibile a partire dall'evento `ready`.\n\nExample: Leggi il dispositivo\n```js\nON('ready', function() {\n\tconsole.log(Object.keys(MAIN.ua)); // [\"os\",\"browser\",\"device\"]\n});\n```\n\n### MAIN.unwatch(path, [callback])\n\nType: `method`\n\nLa stessa funzione di `UNWATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `callback` | `Function` | no |  | L'osservatore da rimuovere. |\n\nVedi [UNWATCH()](../globals/).\n\n### MAIN.version\n\nType: `property`\n\nLa versione della libreria.\n\nReturns: `Number` La versione della libreria.\n\nExample: Leggi la versione\n```js\nconsole.log(MAIN.version); // 20.015\n```\n\n### MAIN.watch(path, callback, [init])\n\nType: `method`\n\nLa stessa funzione di `WATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `callback` | `Function` | yes |  | L'osservatore. |\n| `init` | `Boolean` | no | `false` | Chiama anche l'osservatore una volta. |\n\nVedi [WATCH()](../globals/).\n\n### MAIN.watchers\n\nType: `property`\n\nGli osservatori registrati con `WATCH()`.\n\nReturns: `Array` Gli osservatori registrati con `WATCH()`.\n\nVedi [WATCH()](../globals/).\n","entries":[{"type":"class","name":"MAIN.Binder","signature":"MAIN.Binder","since":"","deprecated":false},{"type":"property","name":"MAIN.binders","signature":"MAIN.binders","since":"","deprecated":false},{"type":"property","name":"MAIN.caller","signature":"MAIN.caller","since":"","deprecated":false},{"type":"method","name":"MAIN.cl()","signature":"MAIN.cl(name, [callback])","since":"","deprecated":false},{"type":"class","name":"MAIN.Component","signature":"MAIN.Component","since":"","deprecated":false},{"type":"property","name":"MAIN.components","signature":"MAIN.components","since":"","deprecated":false},{"type":"property","name":"MAIN.data","signature":"MAIN.data","since":"","deprecated":false},{"type":"property","name":"MAIN.def","signature":"MAIN.def","since":"","deprecated":false},{"type":"method","name":"MAIN.emit()","signature":"MAIN.emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.events","signature":"MAIN.events","since":"","deprecated":false},{"type":"method","name":"MAIN.exec()","signature":"MAIN.exec(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.find()","signature":"MAIN.find(scope, path, callback)","since":"","deprecated":false},{"type":"method","name":"MAIN.flags()","signature":"MAIN.flags(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.free()","signature":"MAIN.free()","since":"","deprecated":false},{"type":"method","name":"MAIN.get()","signature":"MAIN.get(scope, path)","since":"","deprecated":false},{"type":"property","name":"MAIN.is20","signature":"MAIN.is20","since":"","deprecated":false},{"type":"property","name":"MAIN.loaded","signature":"MAIN.loaded","since":"","deprecated":false},{"type":"method","name":"MAIN.newbinder()","signature":"MAIN.newbinder(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newcomponent()","signature":"MAIN.newcomponent(element, name, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newimporter()","signature":"MAIN.newimporter(element, path, config)","since":"","deprecated":false},{"type":"method","name":"MAIN.newplugin()","signature":"MAIN.newplugin(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.notify()","signature":"MAIN.notify(scope, path, [onlyflags])","since":"","deprecated":false},{"type":"method","name":"MAIN.off()","signature":"MAIN.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.on()","signature":"MAIN.on(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"MAIN.parse()","signature":"MAIN.parse(type, value, [format])","since":"","deprecated":false},{"type":"class","name":"MAIN.Path","signature":"new MAIN.Path(path)","since":"","deprecated":false},{"type":"class","name":"MAIN.Plugin","signature":"MAIN.Plugin","since":"","deprecated":false},{"type":"property","name":"MAIN.plugins","signature":"MAIN.plugins","since":"","deprecated":false},{"type":"method","name":"MAIN.process()","signature":"MAIN.process(scope, value, target)","since":"","deprecated":false},{"type":"property","name":"MAIN.ready","signature":"MAIN.ready","since":"","deprecated":false},{"type":"method","name":"MAIN.resize()","signature":"MAIN.resize()","since":"","deprecated":false},{"type":"property","name":"MAIN.root","signature":"MAIN.root","since":"","deprecated":false},{"type":"property","name":"MAIN.scrollbars","signature":"MAIN.scrollbars","since":"","deprecated":false},{"type":"method","name":"MAIN.seex()","signature":"MAIN.seex(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.set()","signature":"MAIN.set(scope, path, value)","since":"","deprecated":false},{"type":"method","name":"MAIN.setter()","signature":"MAIN.setter(element, name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.ua","signature":"MAIN.ua","since":"","deprecated":false},{"type":"method","name":"MAIN.unwatch()","signature":"MAIN.unwatch(path, [callback])","since":"","deprecated":false},{"type":"property","name":"MAIN.version","signature":"MAIN.version","since":"","deprecated":false},{"type":"method","name":"MAIN.watch()","signature":"MAIN.watch(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"MAIN.watchers","signature":"MAIN.watchers","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcVG5oo61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/main/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"MAIN","summary":"Hlavný objekt knižnice s jej stavom a nízkoúrovňovými metódami.","markdown":"---\ntitle: MAIN\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/main/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# MAIN\n\n> Hlavný objekt knižnice s jej stavom a nízkoúrovňovými metódami.\n\n`MAIN` je hlavný objekt knižnice. `M`, `Total` a `jComponent` sú ďalšie názvy toho istého objektu. Uchováva stav knižnice a nízkoúrovňové metódy, ktoré fungujú s ľubovoľným scope. V bežnom kóde používaj [globálne funkcie](../globals/) opísané v časti [Paths](../../guides/paths/).\n\n## API\n\n### MAIN.Binder\n\nType: `class`\n\nTrieda dátových väzieb.\n\nPozri [ui-bind](../ui-bind/).\n\n### MAIN.binders\n\nType: `property`\n\nAktívne dátové väzby.\n\nReturns: `Array` Aktívne dátové väzby.\n\nPozri [ui-bind](../ui-bind/).\n\n### MAIN.caller\n\nType: `property`\n\nPlugin, ktorý bol naposledy zavolaný cez `EXEC()`.\n\nReturns: `Plugin` Plugin, ktorý bol naposledy zavolaný cez `EXEC()`.\n\nExample: Prečítaj volajúceho\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.refresh = NOOP;\n});\n\nON('ready', function() {\n\tEXEC('users/refresh');\n\tconsole.log(MAIN.caller.name); // users\n});\n</script>\n```\n\n### MAIN.cl(name, [callback])\n\nType: `method`\n\nTá istá funkcia ako `CL()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názvy zoznamov kódov. |\n| `callback` | `Function` | no |  | Funkcia, ktorá sa spustí po načítaní zoznamov. |\n\nPozri [CL()](../globals/).\n\n### MAIN.Component\n\nType: `class`\n\nTrieda komponentov.\n\nPozri [Component](../component/).\n\n### MAIN.components\n\nType: `property`\n\nAktívne inštancie komponentov.\n\nReturns: `Array` Aktívne inštancie komponentov.\n\nPozri [Component](../component/).\n\nExample: Spočítaj komponenty\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(MAIN.components.length); // 1\n});\n</script>\n```\n\n### MAIN.data\n\nType: `property`\n\nÚložisko pluginov s vygenerovaným path.\n\nReturns: `Object` Úložisko pluginov s vygenerovaným path.\n\nPozri [DEF.path](../def/).\n\n### MAIN.def\n\nType: `property`\n\nTen istý objekt ako `DEF`.\n\nReturns: `Object` Ten istý objekt ako `DEF`.\n\nPozri [DEF](../def/).\n\nExample: Porovnaj objekty\n```js\nconsole.log(MAIN.def === DEF); // true\n```\n\n### MAIN.emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nTá istá funkcia ako `EMIT()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nPozri [EMIT()](../globals/).\n\n### MAIN.events\n\nType: `property`\n\nGlobálne obslužné funkcie udalostí podľa názvu udalosti.\n\nReturns: `Object` Globálne obslužné funkcie udalostí podľa názvu udalosti.\n\nPozri [Udalosti](../events/).\n\n### MAIN.exec(name, [a], [b], [c], [d])\n\nType: `method`\n\nVykoná rovnakú logiku ako `EXEC()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Cieľ volania. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nPozri [EXEC()](../globals/).\n\n### MAIN.find(scope, path, callback)\n\nType: `method`\n\nNájde komponenty daného path v scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Scope, zvyčajne `window`. |\n| `path` | `String` | yes |  | Path, voliteľne s flagmi. |\n| `callback` | `Function` | yes |  | Funkcia, ktorá dostane pole komponentov. |\n\nVýsledok zúžia flagy v path: `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` a `@enabled`.\n\nExample: Nájdi komponenty\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nON('ready', function() {\n\tMAIN.find(window, 'form', function(components) {\n\t\tconsole.log(components.length); // 1\n\t});\n});\n</script>\n```\n\n### MAIN.flags(flags, [callback])\n\nType: `method`\n\nTá istá funkcia ako `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Flagy. |\n| `callback` | `Function` | no |  | Funkcia, ktorá sa spustí potom. |\n\nPozri [FLAGS()](../globals/).\n\n### MAIN.free()\n\nType: `method`\n\nTá istá funkcia ako `FREE()`.\n\nPozri [FREE()](../globals/).\n\n### MAIN.get(scope, path)\n\nType: `method`\n\nPrečíta hodnotu z ľubovoľného objektu podľa path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Objekt, z ktorého sa číta. |\n| `path` | `String` | yes |  | Path vnútri objektu. |\n\nReturns: `Object` Hodnota.\n\nExample: Prečítaj vnorenú hodnotu\n```js\nvar data = { user: { name: 'Peter' } };\nconsole.log(MAIN.get(data, 'user.name')); // Peter\n```\n\n### MAIN.is20\n\nType: `property`\n\nOznačuje hlavnú verziu knižnice.\n\nReturns: `Boolean` Označuje hlavnú verziu knižnice.\n\nHodnota je vždy `true`.\n\nExample: Prečítaj hodnotu\n```js\nconsole.log(MAIN.is20); // true\n```\n\n### MAIN.loaded\n\nType: `property`\n\nZmení sa na `true`, keď je načítaná trvalá cache.\n\nReturns: `Boolean` Zmení sa na `true`, keď je načítaná trvalá cache.\n\n### MAIN.newbinder(element, path, config, [callback])\n\nType: `method`\n\nVytvorí dátovú väzbu na elemente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Element. |\n| `path` | `String` | yes |  | Path. |\n| `config` | `String` | yes |  | Príkazy väzby. |\n| `callback` | `Function` | no |  | Funkcia, ktorá sa spustí po vytvorení väzby. |\n\nPozri [NEWUIBIND()](../globals/).\n\n### MAIN.newcomponent(element, name, path, config, [callback])\n\nType: `method`\n\nVytvorí komponent na elemente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Element. |\n| `name` | `String` | yes |  | Názov komponentu. |\n| `path` | `String` | yes |  | Path. |\n| `config` | `String` | yes |  | Konfigurácia. |\n| `callback` | `Function` | no |  | Funkcia, ktorá sa spustí po vytvorení komponentu. |\n\nExample: Vytvor komponent z kódu\n```html\n<div id=\"target\"></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.path.path); // form.name\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newcomponent($('#target'), 'box', 'form.name', '');\n});\n</script>\n```\n\n### MAIN.newimporter(element, path, config)\n\nType: `method`\n\nImportuje obsah do elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Element. |\n| `path` | `String` | yes |  | Adresa. |\n| `config` | `String` | yes |  | Konfigurácia importu. |\n\nFunguje ako element [ui-import](../ui-import/).\n\nExample: Importuj časť\n```html\n<div id=\"target\"></div>\n\n<script>\nON('ready', function() {\n\tMAIN.newimporter($('#target'), '/parts/menu.html', '');\n\n\tsetTimeout(function() {\n\t\tconsole.log($('#target').html()); // <b>Menu</b>\n\t}, 400);\n});\n</script>\n```\n\n### MAIN.newplugin(element, path, config, [callback])\n\nType: `method`\n\nVytvorí plugin na elemente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery` | yes |  | Element. |\n| `path` | `String` | yes |  | Názov pluginu. |\n| `config` | `String` | no |  | Konfigurácia. |\n| `callback` | `Function` | no |  | Funkcia, ktorá sa spustí po vytvorení pluginu. |\n\nExample: Vytvor plugin z kódu\n```html\n<div id=\"target\"></div>\n\n<script>\nPLUGIN('users', function(self) {\n\tself.make = function() {\n\t\tconsole.log(self.name); // users\n\t};\n});\n\nON('ready', function() {\n\tMAIN.newplugin($('#target'), 'users');\n});\n</script>\n```\n\n### MAIN.notify(scope, path, [onlyflags])\n\nType: `method`\n\nUpozorní pozorovateľov path v scope.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Scope, zvyčajne `window`. |\n| `path` | `String` | yes |  | Path, voliteľne s flagmi. |\n| `onlyflags` | `Boolean` | no | `false` | Obmedzí upozornenie na stav komponentov. |\n\nS `onlyflags` si komponenty iba obnovia svoj stav a sledovače sa nespustia.\n\nExample: Upozorni na zmenu path\n```js\nWATCH('total', function(value) {\n\tconsole.log(value); // 5\n});\n\nwindow.total = 5;\nMAIN.notify(window, 'total');\n```\n\n### MAIN.off(name, [callback])\n\nType: `method`\n\nTá istá funkcia ako `OFF()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | no |  | Obslužná funkcia na odstránenie. |\n\nPozri [OFF()](../globals/).\n\n### MAIN.on(name, callback, [init])\n\nType: `method`\n\nTá istá funkcia ako `ON()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | yes |  | Obslužná funkcia. |\n| `init` | `Boolean` | no | `false` | Obslužnú funkciu navyše raz zavolá. |\n\nPozri [ON()](../globals/).\n\n### MAIN.parse(type, value, [format])\n\nType: `method`\n\nPrevedie hodnotu na daný typ.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | yes |  | Typ. |\n| `value` | `Object` | yes |  | Hodnota. |\n| `format` | `String` | no |  | Formát dátumu. |\n\nReturns: `Object` Prevedená hodnota.\n\nTypy sú `number`, `currency`, `float`, `boolean`, `bool`, `date` a `datetime`. Čísla sa riadia podľa [DEF.thousandsseparator](../def/) a [DEF.decimalseparator](../def/) a dátumy používajú [DEF.dateformat](../def/), keď nie je nastavený `format`. Hodnota, ktorú nemožno previesť, vráti `null`. Ostatné typy vrátia hodnotu nezmenenú.\n\nExample: Preveď hodnoty\n```js\nconsole.log(MAIN.parse('number', '1 200.5')); // 1200.5\nconsole.log(MAIN.parse('boolean', 'yes')); // true\nconsole.log(MAIN.parse('date', '2024-03-01') instanceof Date); // true\n```\n\n### new MAIN.Path(path)\n\nType: `class`\n\nTrieda, ktorá analyzuje paths.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, voliteľne s flagmi. |\n\nPozri [Path](../path/).\n\nExample: Analyzuj path\n```js\nvar path = new MAIN.Path('form.name @change');\nconsole.log(path.path); // form.name\nconsole.log(path.flags); // {\"change\":1}\n```\n\n### MAIN.Plugin\n\nType: `class`\n\nTrieda pluginov.\n\nPozri [Plugin](../plugin/).\n\n### MAIN.plugins\n\nType: `property`\n\nTen istý objekt ako `PLUGINS`.\n\nReturns: `Object` Ten istý objekt ako `PLUGINS`.\n\nPozri [PLUGINS](../globals/).\n\n### MAIN.process(scope, value, target)\n\nType: `method`\n\nDoručí hodnotu funkcii alebo na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Scope pre path. |\n| `value` | `Object` | yes |  | Hodnota. |\n| `target` | `Function|String` | yes |  | Funkcia alebo path. |\n\nFunkcia dostane hodnotu. Path sa v scope zapíše a upozorní sa na jeho zmenu.\n\nExample: Doruč hodnotu na path\n```js\nMAIN.process(window, 5, 'stats.total');\nconsole.log(GET('stats.total')); // 5\n```\n\n### MAIN.ready\n\nType: `property`\n\nZmení sa na `true`, keď sa knižnica spustila.\n\nReturns: `Boolean` Zmení sa na `true`, keď sa knižnica spustila.\n\nExample: Skontroluj stav\n```js\nON('ready', function() {\n\tconsole.log(MAIN.ready); // true\n});\n```\n\n### MAIN.resize()\n\nType: `method`\n\nZnova zmeria okno.\n\nMetóda aktualizuje [WW](../globals/) a [WH](../globals/). Keď sa veľkosť zmenila, aktualizuje triedu zariadenia na elemente body a vyšle [udalosť](../events/) `resize2`.\n\n### MAIN.root\n\nType: `property`\n\nObjekt `window`, ktorý je scope globálnych paths.\n\nReturns: `Object` Objekt `window`, ktorý je scope globálnych paths.\n\nExample: Porovnaj objekty\n```js\nconsole.log(MAIN.root === window); // true\n```\n\n### MAIN.scrollbars\n\nType: `property`\n\nAktívne vlastné posuvníky.\n\nReturns: `Array` Aktívne vlastné posuvníky.\n\nPozri [SCROLLBAR()](../globals/).\n\n### MAIN.seex(name, [a], [b], [c], [d])\n\nType: `method`\n\nVykoná rovnakú logiku ako `SEEX()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Cieľ. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nPozri [SEEX()](../globals/).\n\n### MAIN.set(scope, path, value)\n\nType: `method`\n\nZapíše hodnotu do ľubovoľného objektu podľa path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Objekt, do ktorého sa zapisuje. |\n| `path` | `String` | yes |  | Path vnútri objektu. |\n| `value` | `Object` | yes |  | Hodnota. |\n\nChýbajúce objekty pozdĺž path sa vytvoria. Na zmenu sa neupozorňuje.\n\nExample: Zapíš vnorenú hodnotu\n```js\nvar data = {};\nMAIN.set(data, 'user.name', 'Peter');\nconsole.log(data); // {\"user\":{\"name\":\"Peter\"}}\n```\n\n### MAIN.setter(element, name, [a], [b], [c], [d])\n\nType: `method`\n\nSpustí `SETTER()` pre komponenty vnútri elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `element` | `jQuery|Plugin` | yes |  | Element alebo plugin, ktorý obmedzuje vyhľadávanie. |\n| `name` | `String` | yes |  | Selektor a metóda. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nPre všetky komponenty použi `null`. Pozri [SETTER()](../globals/).\n\nExample: Obmedz volanie na element\n```html\n<div id=\"a\"><ui-component name=\"box\"></ui-component></div>\n<div id=\"b\"><ui-component name=\"box\"></ui-component></div>\n\n<script>\nCOMPONENT('box', function(self) {\n\tself.mark = function() {\n\t\tconsole.log(self.element.parent().attr('id')); // a\n\t};\n});\n\nON('ready', function() {\n\tMAIN.setter($('#a'), 'box/mark');\n});\n</script>\n```\n\n### MAIN.ua\n\nType: `property`\n\nZistené prostredie: `os`, `browser` a `device`.\n\nReturns: `Object` Zistené prostredie: `os`, `browser` a `device`.\n\nHodnota `device` je `desktop`, `tablet`, `mobile` alebo `tv`. K dispozícii je od udalosti `ready`.\n\nExample: Prečítaj zariadenie\n```js\nON('ready', function() {\n\tconsole.log(Object.keys(MAIN.ua)); // [\"os\",\"browser\",\"device\"]\n});\n```\n\n### MAIN.unwatch(path, [callback])\n\nType: `method`\n\nTá istá funkcia ako `UNWATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `callback` | `Function` | no |  | Sledovač na odstránenie. |\n\nPozri [UNWATCH()](../globals/).\n\n### MAIN.version\n\nType: `property`\n\nVerzia knižnice.\n\nReturns: `Number` Verzia knižnice.\n\nExample: Prečítaj verziu\n```js\nconsole.log(MAIN.version); // 20.015\n```\n\n### MAIN.watch(path, callback, [init])\n\nType: `method`\n\nTá istá funkcia ako `WATCH()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `callback` | `Function` | yes |  | Sledovač. |\n| `init` | `Boolean` | no | `false` | Sledovač navyše raz zavolá. |\n\nPozri [WATCH()](../globals/).\n\n### MAIN.watchers\n\nType: `property`\n\nSledovače zaregistrované pomocou `WATCH()`.\n\nReturns: `Array` Sledovače zaregistrované pomocou `WATCH()`.\n\nPozri [WATCH()](../globals/).\n","entries":[{"type":"class","name":"MAIN.Binder","signature":"MAIN.Binder","since":"","deprecated":false},{"type":"property","name":"MAIN.binders","signature":"MAIN.binders","since":"","deprecated":false},{"type":"property","name":"MAIN.caller","signature":"MAIN.caller","since":"","deprecated":false},{"type":"method","name":"MAIN.cl()","signature":"MAIN.cl(name, [callback])","since":"","deprecated":false},{"type":"class","name":"MAIN.Component","signature":"MAIN.Component","since":"","deprecated":false},{"type":"property","name":"MAIN.components","signature":"MAIN.components","since":"","deprecated":false},{"type":"property","name":"MAIN.data","signature":"MAIN.data","since":"","deprecated":false},{"type":"property","name":"MAIN.def","signature":"MAIN.def","since":"","deprecated":false},{"type":"method","name":"MAIN.emit()","signature":"MAIN.emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.events","signature":"MAIN.events","since":"","deprecated":false},{"type":"method","name":"MAIN.exec()","signature":"MAIN.exec(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.find()","signature":"MAIN.find(scope, path, callback)","since":"","deprecated":false},{"type":"method","name":"MAIN.flags()","signature":"MAIN.flags(flags, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.free()","signature":"MAIN.free()","since":"","deprecated":false},{"type":"method","name":"MAIN.get()","signature":"MAIN.get(scope, path)","since":"","deprecated":false},{"type":"property","name":"MAIN.is20","signature":"MAIN.is20","since":"","deprecated":false},{"type":"property","name":"MAIN.loaded","signature":"MAIN.loaded","since":"","deprecated":false},{"type":"method","name":"MAIN.newbinder()","signature":"MAIN.newbinder(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newcomponent()","signature":"MAIN.newcomponent(element, name, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.newimporter()","signature":"MAIN.newimporter(element, path, config)","since":"","deprecated":false},{"type":"method","name":"MAIN.newplugin()","signature":"MAIN.newplugin(element, path, config, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.notify()","signature":"MAIN.notify(scope, path, [onlyflags])","since":"","deprecated":false},{"type":"method","name":"MAIN.off()","signature":"MAIN.off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"MAIN.on()","signature":"MAIN.on(name, callback, [init])","since":"","deprecated":false},{"type":"method","name":"MAIN.parse()","signature":"MAIN.parse(type, value, [format])","since":"","deprecated":false},{"type":"class","name":"MAIN.Path","signature":"new MAIN.Path(path)","since":"","deprecated":false},{"type":"class","name":"MAIN.Plugin","signature":"MAIN.Plugin","since":"","deprecated":false},{"type":"property","name":"MAIN.plugins","signature":"MAIN.plugins","since":"","deprecated":false},{"type":"method","name":"MAIN.process()","signature":"MAIN.process(scope, value, target)","since":"","deprecated":false},{"type":"property","name":"MAIN.ready","signature":"MAIN.ready","since":"","deprecated":false},{"type":"method","name":"MAIN.resize()","signature":"MAIN.resize()","since":"","deprecated":false},{"type":"property","name":"MAIN.root","signature":"MAIN.root","since":"","deprecated":false},{"type":"property","name":"MAIN.scrollbars","signature":"MAIN.scrollbars","since":"","deprecated":false},{"type":"method","name":"MAIN.seex()","signature":"MAIN.seex(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"MAIN.set()","signature":"MAIN.set(scope, path, value)","since":"","deprecated":false},{"type":"method","name":"MAIN.setter()","signature":"MAIN.setter(element, name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"property","name":"MAIN.ua","signature":"MAIN.ua","since":"","deprecated":false},{"type":"method","name":"MAIN.unwatch()","signature":"MAIN.unwatch(path, [callback])","since":"","deprecated":false},{"type":"property","name":"MAIN.version","signature":"MAIN.version","since":"","deprecated":false},{"type":"method","name":"MAIN.watch()","signature":"MAIN.watch(path, callback, [init])","since":"","deprecated":false},{"type":"property","name":"MAIN.watchers","signature":"MAIN.watchers","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcY79Eo61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/pref/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"PREF","summary":"Persistent user preferences.","markdown":"---\ntitle: PREF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/pref/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# PREF\n\n> Persistent user preferences.\n\n`PREF` keeps user preferences, such as a theme or a language, between visits. The values are saved in the persistent cache described in [CACHE()](../globals/). The stored values are available from the `ready` [event](../events/) onward.\n\n## API\n\n### PREF.get(key)\n\nType: `method`\n\nReads a preference.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The name of the preference. |\n\nReturns: `Object` The value.\n\nExample: Read a preference\n```js\nON('ready', function() {\n\tPREF.set('theme', 'dark');\n\tconsole.log(PREF.get('theme')); // dark\n});\n```\n\n### PREF.set(key, value)\n\nType: `method`\n\nWrites a preference and saves all preferences for one year.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The name of the preference. |\n| `value` | `Object` | yes |  | The value. |\n\nReturns: `Object` The written value.\n\nWrite preferences from the `ready` [event](../events/) onward, when the stored values are loaded. The key `set` is reserved and is ignored.\n\nExample: Write a preference\n```js\nON('ready', function() {\n\tconsole.log(PREF.set('language', 'en')); // en\n\tconsole.log(PREF.language); // en\n});\n```\n\n### PREF.{key}\n\nType: `property`\n\nEach stored preference is also a property of the object.\n\nReturns: `Object` The value of the preference.\n\nStored values are restored when the library starts. Reading a property is equal to calling [PREF.get()](../pref/). To save a change, use [PREF.set()](../pref/).\n\nExample: Restore a stored value\n```js\nDEF.onstorageread = function(callback) {\n\tvar stored = {};\n\tstored['ui' + HASH('PREF').toString(36)] = { value: { theme: 'dark' }, expire: new Date(Date.now() + 60000) };\n\tcallback(stored);\n};\n\nON('ready', function() {\n\tconsole.log(PREF.theme); // dark\n});\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key)","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, value)","since":"","deprecated":false},{"type":"property","name":"PREF.{key}","signature":"PREF.{key}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcY79Eo61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/pref/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"PREF","summary":"Persistente Benutzereinstellungen.","markdown":"---\ntitle: PREF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/pref/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# PREF\n\n> Persistente Benutzereinstellungen.\n\n`PREF` bewahrt Benutzereinstellungen wie ein Theme oder eine Sprache über mehrere Besuche hinweg auf. Die Werte werden im persistenten Cache gespeichert, der bei [CACHE()](../globals/) beschrieben ist. Die gespeicherten Werte stehen ab dem [Event](../events/) `ready` zur Verfügung.\n\n## API\n\n### PREF.get(key)\n\nType: `method`\n\nLiest eine Einstellung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Name der Einstellung. |\n\nReturns: `Object` Der Wert.\n\nExample: Einstellung lesen\n```js\nON('ready', function() {\n\tPREF.set('theme', 'dark');\n\tconsole.log(PREF.get('theme')); // dark\n});\n```\n\n### PREF.set(key, value)\n\nType: `method`\n\nSchreibt eine Einstellung und speichert alle Einstellungen für ein Jahr.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Name der Einstellung. |\n| `value` | `Object` | yes |  | Der Wert. |\n\nReturns: `Object` Der geschriebene Wert.\n\nSchreibe Einstellungen erst ab dem [Event](../events/) `ready`, wenn die gespeicherten Werte geladen sind. Der Schlüssel `set` ist reserviert und wird ignoriert.\n\nExample: Einstellung schreiben\n```js\nON('ready', function() {\n\tconsole.log(PREF.set('language', 'en')); // en\n\tconsole.log(PREF.language); // en\n});\n```\n\n### PREF.{key}\n\nType: `property`\n\nJede gespeicherte Einstellung ist auch eine Eigenschaft des Objekts.\n\nReturns: `Object` Der Wert der Einstellung.\n\nGespeicherte Werte werden beim Start der Bibliothek wiederhergestellt. Eine Eigenschaft zu lesen entspricht dem Aufruf von [PREF.get()](../pref/). Um eine Änderung zu speichern, verwende [PREF.set()](../pref/).\n\nExample: Gespeicherten Wert wiederherstellen\n```js\nDEF.onstorageread = function(callback) {\n\tvar stored = {};\n\tstored['ui' + HASH('PREF').toString(36)] = { value: { theme: 'dark' }, expire: new Date(Date.now() + 60000) };\n\tcallback(stored);\n};\n\nON('ready', function() {\n\tconsole.log(PREF.theme); // dark\n});\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key)","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, value)","since":"","deprecated":false},{"type":"property","name":"PREF.{key}","signature":"PREF.{key}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcY79Eo61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/pref/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"PREF","summary":"Preferencias persistentes del usuario.","markdown":"---\ntitle: PREF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/pref/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# PREF\n\n> Preferencias persistentes del usuario.\n\n`PREF` conserva las preferencias del usuario, como un tema o un idioma, entre visitas. Los valores se guardan en la caché persistente descrita en [CACHE()](../globals/). Los valores almacenados están disponibles a partir del [evento](../events/) `ready`.\n\n## API\n\n### PREF.get(key)\n\nType: `method`\n\nLee una preferencia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | El nombre de la preferencia. |\n\nReturns: `Object` El valor.\n\nExample: Leer una preferencia\n```js\nON('ready', function() {\n\tPREF.set('theme', 'dark');\n\tconsole.log(PREF.get('theme')); // dark\n});\n```\n\n### PREF.set(key, value)\n\nType: `method`\n\nEscribe una preferencia y guarda todas las preferencias durante un año.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | El nombre de la preferencia. |\n| `value` | `Object` | yes |  | El valor. |\n\nReturns: `Object` El valor escrito.\n\nEscribe las preferencias a partir del [evento](../events/) `ready`, cuando los valores almacenados ya están cargados. La clave `set` está reservada y se ignora.\n\nExample: Escribir una preferencia\n```js\nON('ready', function() {\n\tconsole.log(PREF.set('language', 'en')); // en\n\tconsole.log(PREF.language); // en\n});\n```\n\n### PREF.{key}\n\nType: `property`\n\nCada preferencia almacenada es también una propiedad del objeto.\n\nReturns: `Object` El valor de la preferencia.\n\nLos valores almacenados se restauran cuando arranca la biblioteca. Leer una propiedad equivale a llamar a [PREF.get()](../pref/). Para guardar un cambio, usa [PREF.set()](../pref/).\n\nExample: Restaurar un valor almacenado\n```js\nDEF.onstorageread = function(callback) {\n\tvar stored = {};\n\tstored['ui' + HASH('PREF').toString(36)] = { value: { theme: 'dark' }, expire: new Date(Date.now() + 60000) };\n\tcallback(stored);\n};\n\nON('ready', function() {\n\tconsole.log(PREF.theme); // dark\n});\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key)","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, value)","since":"","deprecated":false},{"type":"property","name":"PREF.{key}","signature":"PREF.{key}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcY79Eo61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/pref/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"PREF","summary":"Les préférences persistantes de l'utilisateur.","markdown":"---\ntitle: PREF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/pref/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# PREF\n\n> Les préférences persistantes de l'utilisateur.\n\n`PREF` conserve les préférences de l'utilisateur, comme un thème ou une langue, d'une visite à l'autre. Les valeurs sont enregistrées dans le cache persistant décrit dans [CACHE()](../globals/). Les valeurs stockées sont disponibles à partir de l'[événement](../events/) `ready`.\n\n## API\n\n### PREF.get(key)\n\nType: `method`\n\nLit une préférence.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Le nom de la préférence. |\n\nReturns: `Object` La valeur.\n\nExample: Lire une préférence\n```js\nON('ready', function() {\n\tPREF.set('theme', 'dark');\n\tconsole.log(PREF.get('theme')); // dark\n});\n```\n\n### PREF.set(key, value)\n\nType: `method`\n\nÉcrit une préférence et enregistre toutes les préférences pour un an.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Le nom de la préférence. |\n| `value` | `Object` | yes |  | La valeur. |\n\nReturns: `Object` La valeur écrite.\n\nÉcris les préférences à partir de l'[événement](../events/) `ready`, quand les valeurs stockées sont chargées. La clé `set` est réservée et ignorée.\n\nExample: Écrire une préférence\n```js\nON('ready', function() {\n\tconsole.log(PREF.set('language', 'en')); // en\n\tconsole.log(PREF.language); // en\n});\n```\n\n### PREF.{key}\n\nType: `property`\n\nChaque préférence stockée est aussi une propriété de l'objet.\n\nReturns: `Object` La valeur de la préférence.\n\nLes valeurs stockées sont restaurées au démarrage de la bibliothèque. Lire une propriété revient à appeler [PREF.get()](../pref/). Pour enregistrer une modification, utilise [PREF.set()](../pref/).\n\nExample: Restaurer une valeur stockée\n```js\nDEF.onstorageread = function(callback) {\n\tvar stored = {};\n\tstored['ui' + HASH('PREF').toString(36)] = { value: { theme: 'dark' }, expire: new Date(Date.now() + 60000) };\n\tcallback(stored);\n};\n\nON('ready', function() {\n\tconsole.log(PREF.theme); // dark\n});\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key)","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, value)","since":"","deprecated":false},{"type":"property","name":"PREF.{key}","signature":"PREF.{key}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcY79Eo61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/pref/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"PREF","summary":"Le preferenze persistenti dell'utente.","markdown":"---\ntitle: PREF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/pref/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# PREF\n\n> Le preferenze persistenti dell'utente.\n\n`PREF` conserva le preferenze dell'utente, come un tema o una lingua, tra una visita e l'altra. I valori vengono salvati nella cache persistente descritta in [CACHE()](../globals/). I valori memorizzati sono disponibili a partire dall'[evento](../events/) `ready`.\n\n## API\n\n### PREF.get(key)\n\nType: `method`\n\nLegge una preferenza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Il nome della preferenza. |\n\nReturns: `Object` Il valore.\n\nExample: Leggi una preferenza\n```js\nON('ready', function() {\n\tPREF.set('theme', 'dark');\n\tconsole.log(PREF.get('theme')); // dark\n});\n```\n\n### PREF.set(key, value)\n\nType: `method`\n\nScrive una preferenza e salva tutte le preferenze per un anno.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Il nome della preferenza. |\n| `value` | `Object` | yes |  | Il valore. |\n\nReturns: `Object` Il valore scritto.\n\nScrivi le preferenze a partire dall'[evento](../events/) `ready`, quando i valori memorizzati sono caricati. La chiave `set` è riservata e viene ignorata.\n\nExample: Scrivi una preferenza\n```js\nON('ready', function() {\n\tconsole.log(PREF.set('language', 'en')); // en\n\tconsole.log(PREF.language); // en\n});\n```\n\n### PREF.{key}\n\nType: `property`\n\nOgni preferenza memorizzata è anche una proprietà dell'oggetto.\n\nReturns: `Object` Il valore della preferenza.\n\nI valori memorizzati vengono ripristinati all'avvio della libreria. Leggere una proprietà equivale a chiamare [PREF.get()](../pref/). Per salvare una modifica, usa [PREF.set()](../pref/).\n\nExample: Ripristina un valore memorizzato\n```js\nDEF.onstorageread = function(callback) {\n\tvar stored = {};\n\tstored['ui' + HASH('PREF').toString(36)] = { value: { theme: 'dark' }, expire: new Date(Date.now() + 60000) };\n\tcallback(stored);\n};\n\nON('ready', function() {\n\tconsole.log(PREF.theme); // dark\n});\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key)","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, value)","since":"","deprecated":false},{"type":"property","name":"PREF.{key}","signature":"PREF.{key}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcY79Eo61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/pref/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"PREF","summary":"Trvalé používateľské preferencie.","markdown":"---\ntitle: PREF\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/pref/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# PREF\n\n> Trvalé používateľské preferencie.\n\n`PREF` uchováva používateľské predvoľby, napríklad tému alebo jazyk, medzi návštevami. Hodnoty sa ukladajú do trvalej cache opísanej v [CACHE()](../globals/). Uložené hodnoty sú k dispozícii od [udalosti](../events/) `ready`.\n\n## API\n\n### PREF.get(key)\n\nType: `method`\n\nPrečíta predvoľbu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Názov predvoľby. |\n\nReturns: `Object` Hodnota.\n\nExample: Prečítaj predvoľbu\n```js\nON('ready', function() {\n\tPREF.set('theme', 'dark');\n\tconsole.log(PREF.get('theme')); // dark\n});\n```\n\n### PREF.set(key, value)\n\nType: `method`\n\nZapíše predvoľbu a uloží všetky predvoľby na jeden rok.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Názov predvoľby. |\n| `value` | `Object` | yes |  | Hodnota. |\n\nReturns: `Object` Zapísaná hodnota.\n\nPredvoľby zapisuj až od [udalosti](../events/) `ready`, keď sú uložené hodnoty načítané. Kľúč `set` je rezervovaný a ignoruje sa.\n\nExample: Zapíš predvoľbu\n```js\nON('ready', function() {\n\tconsole.log(PREF.set('language', 'en')); // en\n\tconsole.log(PREF.language); // en\n});\n```\n\n### PREF.{key}\n\nType: `property`\n\nKaždá uložená predvoľba je zároveň vlastnosťou objektu.\n\nReturns: `Object` Hodnota predvoľby.\n\nUložené hodnoty sa obnovia pri štarte knižnice. Čítanie vlastnosti je to isté ako volanie [PREF.get()](../pref/). Ak chceš zmenu uložiť, použi [PREF.set()](../pref/).\n\nExample: Obnov uloženú hodnotu\n```js\nDEF.onstorageread = function(callback) {\n\tvar stored = {};\n\tstored['ui' + HASH('PREF').toString(36)] = { value: { theme: 'dark' }, expire: new Date(Date.now() + 60000) };\n\tcallback(stored);\n};\n\nON('ready', function() {\n\tconsole.log(PREF.theme); // dark\n});\n```\n","entries":[{"type":"method","name":"PREF.get()","signature":"PREF.get(key)","since":"","deprecated":false},{"type":"method","name":"PREF.set()","signature":"PREF.set(key, value)","since":"","deprecated":false},{"type":"property","name":"PREF.{key}","signature":"PREF.{key}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcRc6ed61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/events/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"Events","summary":"The events emitted by the library.","markdown":"---\ntitle: Events\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/events/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Events\n\n> The events emitted by the library.\n\nThe library emits these events. Capture them with [ON()](../globals/) and emit your own with [EMIT()](../globals/). [Components](../component/) and [plugins](../plugin/) can capture the same events with their own `on()` method.\n\n## API\n\n### ON('@flag name', function(path) {})\n\nType: `event`\n\nRuns when a flag is used in a path, a call or `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path that carries the flag. It is empty when there is none. |\n\nReplace `name` with the name of the flag. See [Flags and path modifiers](../../guides/flags/).\n\nExample: Show a loading indicator\n```js\nON('@flag loading', function() {\n\tconsole.log('loading'); // loading\n});\n\nSET('form.name @loading', 'Peter');\n```\n\n### ON('bind', function(binder) {})\n\nType: `event`\n\nRuns when a data binding is created.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | The binding. |\n\nSee [ui-bind](../ui-bind/).\n\nExample: Count the bindings\n```html\n<ui-bind path=\"form.name\" config=\"text:value\"><span></span></ui-bind>\n\n<script>\nON('bind', function() {\n\tconsole.log(MAIN.binders.length); // 1\n});\n</script>\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nRuns when a component is created.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | The instance. |\n\nSee [Component](../component/).\n\nExample: Log the created components\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('component', function(component) {\n\tconsole.log(component.name); // box\n});\n</script>\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nRuns when `ENV()` writes a variable.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the variable. |\n| `value` | `Object` | yes |  | The new value. |\n\nA handler that writes one variable sees the new value in its arguments.\n\nExample: Observe a variable\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // title Demo\n});\n\nENV('title', 'Demo');\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nRuns when a response holds an error.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object|String` | yes |  | The response or the status. |\n\nThe event is emitted by [ERROR()](../globals/) and by [AJAX()](../globals/) with the `ERROR` keyword. For a failed request without a body, the argument is the HTTP status as a string.\n\nExample: Handle errors in one place\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid name\n});\n\nERROR([{ error: 'Invalid name' }]);\n```\n\nExample: A failed request\n```js\nON('ERROR', function(status) {\n\tconsole.log(status); // 500\n});\n\nAJAX('GET /api/fail/ ERROR', NOOP);\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nRuns when `IMPORT()` has loaded content.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The address. |\n| `target` | `jQuery|String` | yes |  | The script or link element, or the target of HTML content. |\n\nExample: Observe imports\n```html\n<div id=\"menu\"></div>\n\n<script>\nON('import', function(url, target) {\n\tconsole.log(url, target); // /parts/menu.html #menu\n});\n\nIMPORT('/parts/menu.html', '#menu');\n</script>\n```\n\n### ON('init', function() {})\n\nType: `event`\n\nRuns first while the library starts.\n\nThe persistent cache is not loaded yet. A handler registered after the start runs immediately.\n\nExample: Prepare the app\n```js\nON('init', function() {\n\tconsole.log(MAIN.ready); // false\n});\n```\n\n### ON('knockknock', function(counter) {})\n\nType: `event`\n\nRuns every minute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | The number of minutes from the start of the page. |\n\nIt runs right after the `service` event.\n\nExample: Run a periodic task\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('plugin', function(plugin) {})\n\nType: `event`\n\nRuns when a plugin is created.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | The instance. |\n\nSee [Plugin](../plugin/).\n\nExample: Log the created plugins\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n</script>\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nRuns when the library and the components on the page are ready.\n\nA handler registered after that moment runs immediately.\n\nExample: Start the app\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('box').name); // box\n});\n</script>\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nRuns for every `AJAX()` call, ahead of sending the request.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | The request: `id`, `method`, `url`, `headers`, `data`, `scope`, `cancel`, `respond()` and, once the request is sent, `xhr`. |\n\nThe handler can change `options.url`, `options.method`, `options.headers` and `options.data`. Set `options.cancel = true` to stop the request. In that case, the callback does not run. Call `options.respond(value)` to answer the call without sending a request: the callback receives `value`. Once the request is sent, `options.xhr` holds its `XMLHttpRequest`.\n\nExample: Add a token to each request\n```js\nON('request', function(options) {\n\toptions.headers['x-token'] = '123';\n\tconsole.log(options.method, options.url); // GET /api/users/\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\nExample: Answer without a request\n```js\nON('request', function(options) {\n\tif (options.url === '/api/config/')\n\t\toptions.respond({ theme: 'dark' });\n});\n\nAJAX('GET /api/config/', function(response) {\n\tconsole.log(response.theme); // dark\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nRuns when the size of the window has changed.\n\nThe values of [WW](../globals/) and [WH](../globals/) are already updated.\n\nExample: React to a new size\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('response', function(options) {})\n\nType: `event`\n\nRuns for every `AJAX()` response, ahead of the callback.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | The request together with `status`, `text`, `response`, `iserror`, `duration` and `headers`. |\n\nThe handler can change `options.response`. Set `options.cancel = true` to skip the callback.\n\nExample: Log the responses\n```js\nON('response', function(options) {\n\tconsole.log(options.status, options.iserror); // 200 false\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nRuns when scrolling starts in a custom scrollbar.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | The scrolling element. |\n\nSee [SCROLLBAR()](../globals/).\n\nExample: Detect scrolling\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scroll', function(area) {\n\tconsole.log(area instanceof jQuery); // true\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nRuns when scrolling in a custom scrollbar has stopped.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | The scrolling element. |\n\nThe event comes 700 milliseconds after the last movement.\n\nExample: Detect the end of scrolling\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scrollidle', function(area) {\n\tconsole.log(area.scrollTop()); // 20\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nRuns every minute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | The number of minutes from the start of the page. |\n\nThe library refreshes [NOW](../globals/), removes expired cache items and clears [TEMP](../globals/) first.\n\nExample: Run a periodic task\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nRuns when the page moves to the background or returns from it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `visible` | `Boolean` | yes |  | `true` when the page is visible. |\n\nExample: Pause work in the background\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n```\n","entries":[{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path) {})","since":"","deprecated":false},{"type":"event","name":"bind","signature":"ON('bind', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(options) {})","since":"","deprecated":false},{"type":"event","name":"scroll","signature":"ON('scroll', function(area) {})","since":"","deprecated":false},{"type":"event","name":"scrollidle","signature":"ON('scrollidle', function(area) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcRc6ed61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/events/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"Events","summary":"Die Events, die die Bibliothek auslöst.","markdown":"---\ntitle: Events\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/events/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Events\n\n> Die Events, die die Bibliothek auslöst.\n\nDie Bibliothek löst diese Events aus. Fange sie mit [ON()](../globals/) ab und löse mit [EMIT()](../globals/) eigene aus. [Komponenten](../component/) und [Plugins](../plugin/) können dieselben Events mit ihrer eigenen Methode `on()` abfangen.\n\n## API\n\n### ON('@flag name', function(path) {})\n\nType: `event`\n\nWird ausgeführt, wenn ein Flag in einem Path, einem Aufruf oder `FLAGS()` verwendet wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path, der das Flag trägt. Er ist leer, wenn es keinen gibt. |\n\nErsetze `name` durch den Namen des Flags. Siehe [Flags und Path-Modifikatoren](../../guides/flags/).\n\nExample: Ladeanzeige einblenden\n```js\nON('@flag loading', function() {\n\tconsole.log('loading'); // loading\n});\n\nSET('form.name @loading', 'Peter');\n```\n\n### ON('bind', function(binder) {})\n\nType: `event`\n\nWird ausgeführt, wenn eine Datenbindung erstellt wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | Die Bindung. |\n\nSiehe [ui-bind](../ui-bind/).\n\nExample: Bindungen zählen\n```html\n<ui-bind path=\"form.name\" config=\"text:value\"><span></span></ui-bind>\n\n<script>\nON('bind', function() {\n\tconsole.log(MAIN.binders.length); // 1\n});\n</script>\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nWird ausgeführt, wenn eine Komponente erstellt wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Die Instanz. |\n\nSiehe [Komponente](../component/).\n\nExample: Erstellte Komponenten protokollieren\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('component', function(component) {\n\tconsole.log(component.name); // box\n});\n</script>\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nWird ausgeführt, wenn `ENV()` eine Variable schreibt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Variable. |\n| `value` | `Object` | yes |  | Der neue Wert. |\n\nEin Handler, der eine Variable schreibt, sieht den neuen Wert in seinen Argumenten.\n\nExample: Variable beobachten\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // title Demo\n});\n\nENV('title', 'Demo');\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nWird ausgeführt, wenn eine Antwort einen Fehler enthält.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object|String` | yes |  | Die Antwort oder der Status. |\n\nDas Event wird von [ERROR()](../globals/) und von [AJAX()](../globals/) mit dem Schlüsselwort `ERROR` ausgelöst. Bei einer fehlgeschlagenen Anfrage ohne Body ist das Argument der HTTP-Status als String.\n\nExample: Fehler an einer Stelle behandeln\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid name\n});\n\nERROR([{ error: 'Invalid name' }]);\n```\n\nExample: Eine fehlgeschlagene Anfrage\n```js\nON('ERROR', function(status) {\n\tconsole.log(status); // 500\n});\n\nAJAX('GET /api/fail/ ERROR', NOOP);\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nWird ausgeführt, wenn `IMPORT()` Inhalt geladen hat.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die Adresse. |\n| `target` | `jQuery|String` | yes |  | Das Script- oder Link-Element oder das Ziel von HTML-Inhalt. |\n\nExample: Importe beobachten\n```html\n<div id=\"menu\"></div>\n\n<script>\nON('import', function(url, target) {\n\tconsole.log(url, target); // /parts/menu.html #menu\n});\n\nIMPORT('/parts/menu.html', '#menu');\n</script>\n```\n\n### ON('init', function() {})\n\nType: `event`\n\nWird beim Start der Bibliothek als Erstes ausgeführt.\n\nDer persistente Cache ist noch nicht geladen. Ein Handler, der nach dem Start registriert wird, läuft sofort.\n\nExample: App vorbereiten\n```js\nON('init', function() {\n\tconsole.log(MAIN.ready); // false\n});\n```\n\n### ON('knockknock', function(counter) {})\n\nType: `event`\n\nWird jede Minute ausgeführt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Die Anzahl der Minuten seit dem Start der Seite. |\n\nEs läuft direkt nach dem Event `service`.\n\nExample: Regelmäßige Aufgabe ausführen\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('plugin', function(plugin) {})\n\nType: `event`\n\nWird ausgeführt, wenn ein Plugin erstellt wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | Die Instanz. |\n\nSiehe [Plugin](../plugin/).\n\nExample: Erstellte Plugins protokollieren\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n</script>\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nWird ausgeführt, wenn die Bibliothek und die Komponenten der Seite bereit sind.\n\nEin Handler, der nach diesem Zeitpunkt registriert wird, läuft sofort.\n\nExample: App starten\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('box').name); // box\n});\n</script>\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nWird bei jedem `AJAX()`-Aufruf ausgeführt, bevor die Anfrage gesendet wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Die Anfrage: `id`, `method`, `url`, `headers`, `data`, `scope`, `cancel`, `respond()` und, sobald die Anfrage gesendet ist, `xhr`. |\n\nDer Handler kann `options.url`, `options.method`, `options.headers` und `options.data` ändern. Setze `options.cancel = true`, um die Anfrage abzubrechen. In diesem Fall wird der Callback nicht ausgeführt. Rufe `options.respond(value)` auf, um den Aufruf ohne Anfrage zu beantworten: Der Callback erhält `value`. Sobald die Anfrage gesendet ist, enthält `options.xhr` ihren `XMLHttpRequest`.\n\nExample: Jeder Anfrage ein Token hinzufügen\n```js\nON('request', function(options) {\n\toptions.headers['x-token'] = '123';\n\tconsole.log(options.method, options.url); // GET /api/users/\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\nExample: Ohne Anfrage antworten\n```js\nON('request', function(options) {\n\tif (options.url === '/api/config/')\n\t\toptions.respond({ theme: 'dark' });\n});\n\nAJAX('GET /api/config/', function(response) {\n\tconsole.log(response.theme); // dark\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nWird ausgeführt, wenn sich die Fenstergröße geändert hat.\n\nDie Werte von [WW](../globals/) und [WH](../globals/) sind bereits aktualisiert.\n\nExample: Auf eine neue Größe reagieren\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('response', function(options) {})\n\nType: `event`\n\nWird bei jeder `AJAX()`-Antwort ausgeführt, vor dem Callback.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Die Anfrage zusammen mit `status`, `text`, `response`, `iserror`, `duration` und `headers`. |\n\nDer Handler kann `options.response` ändern. Setze `options.cancel = true`, um den Callback zu überspringen.\n\nExample: Antworten protokollieren\n```js\nON('response', function(options) {\n\tconsole.log(options.status, options.iserror); // 200 false\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nWird ausgeführt, wenn das Scrollen in einer benutzerdefinierten Scrollbar beginnt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | Das scrollende Element. |\n\nSiehe [SCROLLBAR()](../globals/).\n\nExample: Scrollen erkennen\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scroll', function(area) {\n\tconsole.log(area instanceof jQuery); // true\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nWird ausgeführt, wenn das Scrollen in einer benutzerdefinierten Scrollbar aufgehört hat.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | Das scrollende Element. |\n\nDas Event kommt 700 Millisekunden nach der letzten Bewegung.\n\nExample: Ende des Scrollens erkennen\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scrollidle', function(area) {\n\tconsole.log(area.scrollTop()); // 20\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nWird jede Minute ausgeführt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Die Anzahl der Minuten seit dem Start der Seite. |\n\nDie Bibliothek aktualisiert zuerst [NOW](../globals/), entfernt abgelaufene Cache-Einträge und leert [TEMP](../globals/).\n\nExample: Regelmäßige Aufgabe ausführen\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nWird ausgeführt, wenn die Seite in den Hintergrund wechselt oder aus ihm zurückkehrt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `visible` | `Boolean` | yes |  | `true`, wenn die Seite sichtbar ist. |\n\nExample: Arbeit im Hintergrund pausieren\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n```\n","entries":[{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path) {})","since":"","deprecated":false},{"type":"event","name":"bind","signature":"ON('bind', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(options) {})","since":"","deprecated":false},{"type":"event","name":"scroll","signature":"ON('scroll', function(area) {})","since":"","deprecated":false},{"type":"event","name":"scrollidle","signature":"ON('scrollidle', function(area) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcRc6ed61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/events/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Eventos","summary":"Los eventos que emite la biblioteca.","markdown":"---\ntitle: Eventos\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/events/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Eventos\n\n> Los eventos que emite la biblioteca.\n\nLa biblioteca emite estos eventos. Captúralos con [ON()](../globals/) y emite los tuyos con [EMIT()](../globals/). Los [componentes](../component/) y los [plugins](../plugin/) pueden capturar los mismos eventos con su propio método `on()`.\n\n## API\n\n### ON('@flag name', function(path) {})\n\nType: `event`\n\nSe ejecuta cuando se usa un flag en un path, en una llamada o en `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path que lleva el flag. Está vacío cuando no hay ninguno. |\n\nSustituye `name` por el nombre del flag. Consulta [Flags y modificadores de path](../../guides/flags/).\n\nExample: Mostrar un indicador de carga\n```js\nON('@flag loading', function() {\n\tconsole.log('loading'); // loading\n});\n\nSET('form.name @loading', 'Peter');\n```\n\n### ON('bind', function(binder) {})\n\nType: `event`\n\nSe ejecuta cuando se crea un enlace de datos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | El enlace. |\n\nConsulta [ui-bind](../ui-bind/).\n\nExample: Contar los enlaces\n```html\n<ui-bind path=\"form.name\" config=\"text:value\"><span></span></ui-bind>\n\n<script>\nON('bind', function() {\n\tconsole.log(MAIN.binders.length); // 1\n});\n</script>\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nSe ejecuta cuando se crea un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | La instancia. |\n\nConsulta [Component](../component/).\n\nExample: Registrar los componentes creados\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('component', function(component) {\n\tconsole.log(component.name); // box\n});\n</script>\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nSe ejecuta cuando `ENV()` escribe una variable.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la variable. |\n| `value` | `Object` | yes |  | El nuevo valor. |\n\nUn manejador que escribe una variable ve el nuevo valor en sus argumentos.\n\nExample: Observar una variable\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // title Demo\n});\n\nENV('title', 'Demo');\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nSe ejecuta cuando una respuesta contiene un error.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object|String` | yes |  | La respuesta o el estado. |\n\nEl evento lo emiten [ERROR()](../globals/) y [AJAX()](../globals/) con la palabra clave `ERROR`. En una petición fallida sin cuerpo, el argumento es el estado HTTP como cadena.\n\nExample: Gestionar los errores en un solo lugar\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid name\n});\n\nERROR([{ error: 'Invalid name' }]);\n```\n\nExample: Una petición fallida\n```js\nON('ERROR', function(status) {\n\tconsole.log(status); // 500\n});\n\nAJAX('GET /api/fail/ ERROR', NOOP);\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nSe ejecuta cuando `IMPORT()` ha cargado el contenido.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La dirección. |\n| `target` | `jQuery|String` | yes |  | El elemento script o link, o el destino del contenido HTML. |\n\nExample: Observar las importaciones\n```html\n<div id=\"menu\"></div>\n\n<script>\nON('import', function(url, target) {\n\tconsole.log(url, target); // /parts/menu.html #menu\n});\n\nIMPORT('/parts/menu.html', '#menu');\n</script>\n```\n\n### ON('init', function() {})\n\nType: `event`\n\nSe ejecuta primero mientras arranca la biblioteca.\n\nLa caché persistente todavía no está cargada. Un manejador registrado después del arranque se ejecuta de inmediato.\n\nExample: Preparar la aplicación\n```js\nON('init', function() {\n\tconsole.log(MAIN.ready); // false\n});\n```\n\n### ON('knockknock', function(counter) {})\n\nType: `event`\n\nSe ejecuta cada minuto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | El número de minutos desde el inicio de la página. |\n\nSe ejecuta justo después del evento `service`.\n\nExample: Ejecutar una tarea periódica\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('plugin', function(plugin) {})\n\nType: `event`\n\nSe ejecuta cuando se crea un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | La instancia. |\n\nConsulta [Plugin](../plugin/).\n\nExample: Registrar los plugins creados\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n</script>\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nSe ejecuta cuando la biblioteca y los componentes de la página están listos.\n\nUn manejador registrado después de ese momento se ejecuta de inmediato.\n\nExample: Iniciar la aplicación\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('box').name); // box\n});\n</script>\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nSe ejecuta en cada llamada a `AJAX()`, antes de enviar la petición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | La petición: `id`, `method`, `url`, `headers`, `data`, `scope`, `cancel`, `respond()` y, una vez enviada la petición, `xhr`. |\n\nEl manejador puede cambiar `options.url`, `options.method`, `options.headers` y `options.data`. Establece `options.cancel = true` para detener la petición. En ese caso, el callback no se ejecuta. Llama a `options.respond(value)` para responder a la llamada sin enviar ninguna petición: el callback recibe `value`. Una vez enviada la petición, `options.xhr` contiene su `XMLHttpRequest`.\n\nExample: Añadir un token a cada petición\n```js\nON('request', function(options) {\n\toptions.headers['x-token'] = '123';\n\tconsole.log(options.method, options.url); // GET /api/users/\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\nExample: Responder sin una petición\n```js\nON('request', function(options) {\n\tif (options.url === '/api/config/')\n\t\toptions.respond({ theme: 'dark' });\n});\n\nAJAX('GET /api/config/', function(response) {\n\tconsole.log(response.theme); // dark\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nSe ejecuta cuando ha cambiado el tamaño de la ventana.\n\nLos valores de [WW](../globals/) y [WH](../globals/) ya están actualizados.\n\nExample: Reaccionar a un nuevo tamaño\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('response', function(options) {})\n\nType: `event`\n\nSe ejecuta en cada respuesta de `AJAX()`, antes del callback.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | La petición junto con `status`, `text`, `response`, `iserror`, `duration` y `headers`. |\n\nEl manejador puede cambiar `options.response`. Establece `options.cancel = true` para omitir el callback.\n\nExample: Registrar las respuestas\n```js\nON('response', function(options) {\n\tconsole.log(options.status, options.iserror); // 200 false\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nSe ejecuta cuando empieza el desplazamiento en una barra de desplazamiento personalizada.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | El elemento que se desplaza. |\n\nConsulta [SCROLLBAR()](../globals/).\n\nExample: Detectar el desplazamiento\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scroll', function(area) {\n\tconsole.log(area instanceof jQuery); // true\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nSe ejecuta cuando se ha detenido el desplazamiento en una barra de desplazamiento personalizada.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | El elemento que se desplaza. |\n\nEl evento llega 700 milisegundos después del último movimiento.\n\nExample: Detectar el final del desplazamiento\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scrollidle', function(area) {\n\tconsole.log(area.scrollTop()); // 20\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nSe ejecuta cada minuto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | El número de minutos desde el inicio de la página. |\n\nLa biblioteca actualiza primero [NOW](../globals/), elimina los elementos caducados de la caché y vacía [TEMP](../globals/).\n\nExample: Ejecutar una tarea periódica\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nSe ejecuta cuando la página pasa a segundo plano o vuelve de él.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `visible` | `Boolean` | yes |  | `true` cuando la página está visible. |\n\nExample: Pausar el trabajo en segundo plano\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n```\n","entries":[{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path) {})","since":"","deprecated":false},{"type":"event","name":"bind","signature":"ON('bind', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(options) {})","since":"","deprecated":false},{"type":"event","name":"scroll","signature":"ON('scroll', function(area) {})","since":"","deprecated":false},{"type":"event","name":"scrollidle","signature":"ON('scrollidle', function(area) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcRc6ed61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/events/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Événements","summary":"Les événements émis par la bibliothèque.","markdown":"---\ntitle: \"Événements\"\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/events/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Événements\n\n> Les événements émis par la bibliothèque.\n\nLa bibliothèque émet ces événements. Capture-les avec [ON()](../globals/) et émets les tiens avec [EMIT()](../globals/). Les [composants](../component/) et les [plugins](../plugin/) peuvent capturer les mêmes événements avec leur propre méthode `on()`.\n\n## API\n\n### ON('@flag name', function(path) {})\n\nType: `event`\n\nS'exécute quand un flag est utilisé dans un path, un appel ou `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path qui porte le flag. Il est vide s'il n'y en a pas. |\n\nRemplace `name` par le nom du flag. Voir [Flags et modificateurs de path](../../guides/flags/).\n\nExample: Afficher un indicateur de chargement\n```js\nON('@flag loading', function() {\n\tconsole.log('loading'); // loading\n});\n\nSET('form.name @loading', 'Peter');\n```\n\n### ON('bind', function(binder) {})\n\nType: `event`\n\nS'exécute quand une liaison de données est créée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | La liaison. |\n\nVoir [ui-bind](../ui-bind/).\n\nExample: Compter les liaisons\n```html\n<ui-bind path=\"form.name\" config=\"text:value\"><span></span></ui-bind>\n\n<script>\nON('bind', function() {\n\tconsole.log(MAIN.binders.length); // 1\n});\n</script>\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nS'exécute quand un composant est créé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | L'instance. |\n\nVoir [Component](../component/).\n\nExample: Journaliser les composants créés\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('component', function(component) {\n\tconsole.log(component.name); // box\n});\n</script>\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nS'exécute quand `ENV()` écrit une variable.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la variable. |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n\nUn gestionnaire qui écrit une variable voit la nouvelle valeur dans ses arguments.\n\nExample: Observer une variable\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // title Demo\n});\n\nENV('title', 'Demo');\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nS'exécute quand une réponse contient une erreur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object|String` | yes |  | La réponse ou le statut. |\n\nL'événement est émis par [ERROR()](../globals/) et par [AJAX()](../globals/) avec le mot-clé `ERROR`. Pour une requête échouée sans corps, l'argument est le statut HTTP sous forme de chaîne.\n\nExample: Gérer les erreurs au même endroit\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid name\n});\n\nERROR([{ error: 'Invalid name' }]);\n```\n\nExample: Une requête échouée\n```js\nON('ERROR', function(status) {\n\tconsole.log(status); // 500\n});\n\nAJAX('GET /api/fail/ ERROR', NOOP);\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nS'exécute quand `IMPORT()` a chargé du contenu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'adresse. |\n| `target` | `jQuery|String` | yes |  | L'élément script ou link, ou la cible du contenu HTML. |\n\nExample: Observer les imports\n```html\n<div id=\"menu\"></div>\n\n<script>\nON('import', function(url, target) {\n\tconsole.log(url, target); // /parts/menu.html #menu\n});\n\nIMPORT('/parts/menu.html', '#menu');\n</script>\n```\n\n### ON('init', function() {})\n\nType: `event`\n\nS'exécute en premier pendant le démarrage de la bibliothèque.\n\nLe cache persistant n'est pas encore chargé. Un gestionnaire enregistré après le démarrage s'exécute immédiatement.\n\nExample: Préparer l'application\n```js\nON('init', function() {\n\tconsole.log(MAIN.ready); // false\n});\n```\n\n### ON('knockknock', function(counter) {})\n\nType: `event`\n\nS'exécute chaque minute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Le nombre de minutes écoulées depuis le chargement de la page. |\n\nIl s'exécute juste après l'événement `service`.\n\nExample: Exécuter une tâche périodique\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('plugin', function(plugin) {})\n\nType: `event`\n\nS'exécute quand un plugin est créé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | L'instance. |\n\nVoir [Plugin](../plugin/).\n\nExample: Journaliser les plugins créés\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n</script>\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nS'exécute quand la bibliothèque et les composants de la page sont prêts.\n\nUn gestionnaire enregistré après ce moment s'exécute immédiatement.\n\nExample: Démarrer l'application\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('box').name); // box\n});\n</script>\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nS'exécute à chaque appel de `AJAX()`, avant l'envoi de la requête.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | La requête : `id`, `method`, `url`, `headers`, `data`, `scope`, `cancel`, `respond()` et, une fois la requête envoyée, `xhr`. |\n\nLe gestionnaire peut modifier `options.url`, `options.method`, `options.headers` et `options.data`. Définis `options.cancel = true` pour arrêter la requête. Dans ce cas, le callback ne s'exécute pas. Appelle `options.respond(value)` pour répondre à l'appel sans envoyer de requête : le callback reçoit `value`. Une fois la requête envoyée, `options.xhr` contient son `XMLHttpRequest`.\n\nExample: Ajouter un jeton à chaque requête\n```js\nON('request', function(options) {\n\toptions.headers['x-token'] = '123';\n\tconsole.log(options.method, options.url); // GET /api/users/\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\nExample: Répondre sans requête\n```js\nON('request', function(options) {\n\tif (options.url === '/api/config/')\n\t\toptions.respond({ theme: 'dark' });\n});\n\nAJAX('GET /api/config/', function(response) {\n\tconsole.log(response.theme); // dark\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nS'exécute quand la taille de la fenêtre a changé.\n\nLes valeurs de [WW](../globals/) et [WH](../globals/) sont déjà à jour.\n\nExample: Réagir à une nouvelle taille\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('response', function(options) {})\n\nType: `event`\n\nS'exécute à chaque réponse de `AJAX()`, avant le callback.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | La requête avec `status`, `text`, `response`, `iserror`, `duration` et `headers`. |\n\nLe gestionnaire peut modifier `options.response`. Définis `options.cancel = true` pour ignorer le callback.\n\nExample: Journaliser les réponses\n```js\nON('response', function(options) {\n\tconsole.log(options.status, options.iserror); // 200 false\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nS'exécute quand le défilement commence dans une barre de défilement personnalisée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | L'élément qui défile. |\n\nConsulte [SCROLLBAR()](../globals/).\n\nExample: Détecter le défilement\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scroll', function(area) {\n\tconsole.log(area instanceof jQuery); // true\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nS'exécute quand le défilement s'est arrêté dans une barre de défilement personnalisée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | L'élément qui défile. |\n\nL'événement arrive 700 millisecondes après le dernier mouvement.\n\nExample: Détecter la fin du défilement\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scrollidle', function(area) {\n\tconsole.log(area.scrollTop()); // 20\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nS'exécute chaque minute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Le nombre de minutes écoulées depuis le chargement de la page. |\n\nLa bibliothèque commence par actualiser [NOW](../globals/), supprimer les éléments expirés du cache et vider [TEMP](../globals/).\n\nExample: Exécuter une tâche périodique\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nS'exécute quand la page passe en arrière-plan ou en revient.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `visible` | `Boolean` | yes |  | `true` quand la page est visible. |\n\nExample: Mettre le travail en pause en arrière-plan\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n```\n","entries":[{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path) {})","since":"","deprecated":false},{"type":"event","name":"bind","signature":"ON('bind', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(options) {})","since":"","deprecated":false},{"type":"event","name":"scroll","signature":"ON('scroll', function(area) {})","since":"","deprecated":false},{"type":"event","name":"scrollidle","signature":"ON('scrollidle', function(area) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcRc6ed61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/events/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Eventi","summary":"Gli eventi emessi dalla libreria.","markdown":"---\ntitle: Eventi\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/events/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Eventi\n\n> Gli eventi emessi dalla libreria.\n\nLa libreria emette questi eventi. Puoi catturarli con [ON()](../globals/) ed emettere i tuoi con [EMIT()](../globals/). Anche i [componenti](../component/) e i [plugin](../plugin/) possono catturare gli stessi eventi con il proprio metodo `on()`.\n\n## API\n\n### ON('@flag name', function(path) {})\n\nType: `event`\n\nViene eseguito quando un flag è usato in un path, in una chiamata o in `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path che contiene il flag. È vuoto quando non ce n'è nessuno. |\n\nSostituisci `name` con il nome del flag. Vedi [Flag e modificatori di path](../../guides/flags/).\n\nExample: Mostra un indicatore di caricamento\n```js\nON('@flag loading', function() {\n\tconsole.log('loading'); // loading\n});\n\nSET('form.name @loading', 'Peter');\n```\n\n### ON('bind', function(binder) {})\n\nType: `event`\n\nViene eseguito quando viene creata un'associazione dei dati.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | L'associazione. |\n\nVedi [ui-bind](../ui-bind/).\n\nExample: Conta le associazioni\n```html\n<ui-bind path=\"form.name\" config=\"text:value\"><span></span></ui-bind>\n\n<script>\nON('bind', function() {\n\tconsole.log(MAIN.binders.length); // 1\n});\n</script>\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nViene eseguito quando viene creato un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | L'istanza. |\n\nVedi [Componente](../component/).\n\nExample: Registra nel log i componenti creati\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('component', function(component) {\n\tconsole.log(component.name); // box\n});\n</script>\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nViene eseguito quando `ENV()` scrive una variabile.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome della variabile. |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n\nUn gestore che scrive una variabile vede il nuovo valore nei propri argomenti.\n\nExample: Osserva una variabile\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // title Demo\n});\n\nENV('title', 'Demo');\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nViene eseguito quando una risposta contiene un errore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object|String` | yes |  | La risposta o lo stato. |\n\nL'evento viene emesso da [ERROR()](../globals/) e da [AJAX()](../globals/) con la parola chiave `ERROR`. Per una richiesta fallita senza corpo, l'argomento è lo stato HTTP sotto forma di stringa.\n\nExample: Gestisci gli errori in un unico punto\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid name\n});\n\nERROR([{ error: 'Invalid name' }]);\n```\n\nExample: Una richiesta fallita\n```js\nON('ERROR', function(status) {\n\tconsole.log(status); // 500\n});\n\nAJAX('GET /api/fail/ ERROR', NOOP);\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nViene eseguito quando `IMPORT()` ha caricato i contenuti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'indirizzo. |\n| `target` | `jQuery|String` | yes |  | L'elemento script o link, oppure la destinazione dei contenuti HTML. |\n\nExample: Osserva le importazioni\n```html\n<div id=\"menu\"></div>\n\n<script>\nON('import', function(url, target) {\n\tconsole.log(url, target); // /parts/menu.html #menu\n});\n\nIMPORT('/parts/menu.html', '#menu');\n</script>\n```\n\n### ON('init', function() {})\n\nType: `event`\n\nViene eseguito per primo durante l'avvio della libreria.\n\nLa cache persistente non è ancora caricata. Un gestore registrato dopo l'avvio viene eseguito immediatamente.\n\nExample: Prepara l'app\n```js\nON('init', function() {\n\tconsole.log(MAIN.ready); // false\n});\n```\n\n### ON('knockknock', function(counter) {})\n\nType: `event`\n\nViene eseguito ogni minuto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Il numero di minuti dall'apertura della pagina. |\n\nViene eseguito subito dopo l'evento `service`.\n\nExample: Esegui un'attività periodica\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('plugin', function(plugin) {})\n\nType: `event`\n\nViene eseguito quando viene creato un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | L'istanza. |\n\nVedi [Plugin](../plugin/).\n\nExample: Registra nel log i plugin creati\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n</script>\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nViene eseguito quando la libreria e i componenti della pagina sono pronti.\n\nUn gestore registrato dopo quel momento viene eseguito immediatamente.\n\nExample: Avvia l'app\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('box').name); // box\n});\n</script>\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nViene eseguito per ogni chiamata `AJAX()`, prima dell'invio della richiesta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | La richiesta: `id`, `method`, `url`, `headers`, `data`, `scope`, `cancel`, `respond()` e, una volta inviata la richiesta, `xhr`. |\n\nIl gestore può modificare `options.url`, `options.method`, `options.headers` e `options.data`. Imposta `options.cancel = true` per bloccare la richiesta. In questo caso, il callback non viene eseguito. Chiama `options.respond(value)` per rispondere alla chiamata senza inviare una richiesta: il callback riceve `value`. Una volta inviata la richiesta, `options.xhr` contiene il suo `XMLHttpRequest`.\n\nExample: Aggiungi un token a ogni richiesta\n```js\nON('request', function(options) {\n\toptions.headers['x-token'] = '123';\n\tconsole.log(options.method, options.url); // GET /api/users/\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\nExample: Rispondi senza una richiesta\n```js\nON('request', function(options) {\n\tif (options.url === '/api/config/')\n\t\toptions.respond({ theme: 'dark' });\n});\n\nAJAX('GET /api/config/', function(response) {\n\tconsole.log(response.theme); // dark\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nViene eseguito quando le dimensioni della finestra sono cambiate.\n\nI valori di [WW](../globals/) e [WH](../globals/) sono già aggiornati.\n\nExample: Reagisci alle nuove dimensioni\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('response', function(options) {})\n\nType: `event`\n\nViene eseguito per ogni risposta di `AJAX()`, prima del callback.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | La richiesta insieme a `status`, `text`, `response`, `iserror`, `duration` e `headers`. |\n\nIl gestore può modificare `options.response`. Imposta `options.cancel = true` per saltare il callback.\n\nExample: Registra nel log le risposte\n```js\nON('response', function(options) {\n\tconsole.log(options.status, options.iserror); // 200 false\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nViene eseguito quando inizia lo scorrimento in una barra di scorrimento personalizzata.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | L'elemento che scorre. |\n\nConsulta [SCROLLBAR()](../globals/).\n\nExample: Rileva lo scorrimento\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scroll', function(area) {\n\tconsole.log(area instanceof jQuery); // true\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nViene eseguito quando lo scorrimento in una barra di scorrimento personalizzata si è fermato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | L'elemento che scorre. |\n\nL'evento arriva 700 millisecondi dopo l'ultimo movimento.\n\nExample: Rileva la fine dello scorrimento\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scrollidle', function(area) {\n\tconsole.log(area.scrollTop()); // 20\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nViene eseguito ogni minuto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Il numero di minuti dall'apertura della pagina. |\n\nLa libreria aggiorna prima [NOW](../globals/), rimuove gli elementi scaduti della cache e svuota [TEMP](../globals/).\n\nExample: Esegui un'attività periodica\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nViene eseguito quando la pagina passa in background o ne ritorna.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `visible` | `Boolean` | yes |  | `true` quando la pagina è visibile. |\n\nExample: Sospendi il lavoro in background\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n```\n","entries":[{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path) {})","since":"","deprecated":false},{"type":"event","name":"bind","signature":"ON('bind', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(options) {})","since":"","deprecated":false},{"type":"event","name":"scroll","signature":"ON('scroll', function(area) {})","since":"","deprecated":false},{"type":"event","name":"scrollidle","signature":"ON('scrollidle', function(area) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcRc6ed61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/events/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Udalosti","summary":"Udalosti, ktoré vysiela knižnica.","markdown":"---\ntitle: Udalosti\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/events/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Udalosti\n\n> Udalosti, ktoré vysiela knižnica.\n\nKnižnica vysiela tieto udalosti. Zachytíš ich pomocou [ON()](../globals/) a vlastné vyšleš pomocou [EMIT()](../globals/). [Komponenty](../component/) a [pluginy](../plugin/) môžu tie isté udalosti zachytávať vlastnou metódou `on()`.\n\n## API\n\n### ON('@flag name', function(path) {})\n\nType: `event`\n\nSpustí sa, keď sa flag použije v path, vo volaní alebo vo `FLAGS()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, ktorý nesie flag. Ak taký nie je, je prázdny. |\n\nNahraď `name` názvom flagu. Pozri [Flagy a modifikátory path](../../guides/flags/).\n\nExample: Zobraz indikátor načítania\n```js\nON('@flag loading', function() {\n\tconsole.log('loading'); // loading\n});\n\nSET('form.name @loading', 'Peter');\n```\n\n### ON('bind', function(binder) {})\n\nType: `event`\n\nSpustí sa pri vytvorení dátovej väzby.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `binder` | `Object` | yes |  | Väzba. |\n\nPozri [ui-bind](../ui-bind/).\n\nExample: Spočítaj väzby\n```html\n<ui-bind path=\"form.name\" config=\"text:value\"><span></span></ui-bind>\n\n<script>\nON('bind', function() {\n\tconsole.log(MAIN.binders.length); // 1\n});\n</script>\n```\n\n### ON('component', function(component) {})\n\nType: `event`\n\nSpustí sa pri vytvorení komponentu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Inštancia. |\n\nPozri [Component](../component/).\n\nExample: Zaznamenaj vytvorené komponenty\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('component', function(component) {\n\tconsole.log(component.name); // box\n});\n</script>\n```\n\n### ON('env', function(name, value) {})\n\nType: `event`\n\nSpustí sa, keď `ENV()` zapíše premennú.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov premennej. |\n| `value` | `Object` | yes |  | Nová hodnota. |\n\nObslužná funkcia, ktorá zapíše jednu premennú, vidí novú hodnotu vo svojich argumentoch.\n\nExample: Sleduj premennú\n```js\nON('env', function(name, value) {\n\tconsole.log(name, value); // title Demo\n});\n\nENV('title', 'Demo');\n```\n\n### ON('ERROR', function(response) {})\n\nType: `event`\n\nSpustí sa, keď odpoveď obsahuje chybu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `response` | `Object|String` | yes |  | Odpoveď alebo stav. |\n\nUdalosť vysiela [ERROR()](../globals/) a [AJAX()](../globals/) s kľúčovým slovom `ERROR`. Pri neúspešnej požiadavke bez tela je argumentom stav HTTP ako reťazec.\n\nExample: Spracuj chyby na jednom mieste\n```js\nON('ERROR', function(response) {\n\tconsole.log(response[0].error); // Invalid name\n});\n\nERROR([{ error: 'Invalid name' }]);\n```\n\nExample: Neúspešná požiadavka\n```js\nON('ERROR', function(status) {\n\tconsole.log(status); // 500\n});\n\nAJAX('GET /api/fail/ ERROR', NOOP);\n```\n\n### ON('import', function(url, target) {})\n\nType: `event`\n\nSpustí sa, keď `IMPORT()` načíta obsah.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Adresa. |\n| `target` | `jQuery|String` | yes |  | Element script alebo link, prípadne cieľ obsahu HTML. |\n\nExample: Sleduj importy\n```html\n<div id=\"menu\"></div>\n\n<script>\nON('import', function(url, target) {\n\tconsole.log(url, target); // /parts/menu.html #menu\n});\n\nIMPORT('/parts/menu.html', '#menu');\n</script>\n```\n\n### ON('init', function() {})\n\nType: `event`\n\nSpustí sa ako prvá pri štarte knižnice.\n\nTrvalá cache ešte nie je načítaná. Obslužná funkcia zaregistrovaná po štarte sa spustí okamžite.\n\nExample: Priprav aplikáciu\n```js\nON('init', function() {\n\tconsole.log(MAIN.ready); // false\n});\n```\n\n### ON('knockknock', function(counter) {})\n\nType: `event`\n\nSpustí sa každú minútu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Počet minút od načítania stránky. |\n\nSpustí sa hneď po udalosti `service`.\n\nExample: Spusti periodickú úlohu\n```js\nON('knockknock', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('plugin', function(plugin) {})\n\nType: `event`\n\nSpustí sa pri vytvorení pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `plugin` | `Plugin` | yes |  | Inštancia. |\n\nPozri [Plugin](../plugin/).\n\nExample: Zaznamenaj vytvorené pluginy\n```html\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('users', function(self) {});\n\nON('plugin', function(plugin) {\n\tconsole.log(plugin.name); // users\n});\n</script>\n```\n\n### ON('ready', function() {})\n\nType: `event`\n\nSpustí sa, keď sú knižnica a komponenty na stránke pripravené.\n\nObslužná funkcia zaregistrovaná po tomto okamihu sa spustí okamžite.\n\nExample: Spusti aplikáciu\n```html\n<ui-component name=\"box\"></ui-component>\n\n<script>\nCOMPONENT('box', function(self) {});\n\nON('ready', function() {\n\tconsole.log(FIND('box').name); // box\n});\n</script>\n```\n\n### ON('request', function(options) {})\n\nType: `event`\n\nSpustí sa pri každom volaní `AJAX()` pred odoslaním požiadavky.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Požiadavka: `id`, `method`, `url`, `headers`, `data`, `scope`, `cancel`, `respond()` a po odoslaní požiadavky aj `xhr`. |\n\nObslužná funkcia môže zmeniť `options.url`, `options.method`, `options.headers` a `options.data`. Ak chceš požiadavku zastaviť, nastav `options.cancel = true`. V takom prípade sa callback nespustí. Ak chceš na volanie odpovedať bez odoslania požiadavky, zavolaj `options.respond(value)`: callback dostane `value`. Po odoslaní požiadavky obsahuje `options.xhr` jej `XMLHttpRequest`.\n\nExample: Pridaj token ku každej požiadavke\n```js\nON('request', function(options) {\n\toptions.headers['x-token'] = '123';\n\tconsole.log(options.method, options.url); // GET /api/users/\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\nExample: Odpovedz bez požiadavky\n```js\nON('request', function(options) {\n\tif (options.url === '/api/config/')\n\t\toptions.respond({ theme: 'dark' });\n});\n\nAJAX('GET /api/config/', function(response) {\n\tconsole.log(response.theme); // dark\n});\n```\n\n### ON('resize2', function() {})\n\nType: `event`\n\nSpustí sa, keď sa zmenila veľkosť okna.\n\nHodnoty [WW](../globals/) a [WH](../globals/) sú už aktualizované.\n\nExample: Zareaguj na novú veľkosť\n```js\nON('resize2', function() {\n\tconsole.log(typeof(WW)); // number\n});\n```\n\n### ON('response', function(options) {})\n\nType: `event`\n\nSpustí sa pri každej odpovedi `AJAX()` pred callbackom.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `options` | `Object` | yes |  | Požiadavka spolu so `status`, `text`, `response`, `iserror`, `duration` a `headers`. |\n\nObslužná funkcia môže zmeniť `options.response`. Ak chceš callback preskočiť, nastav `options.cancel = true`.\n\nExample: Zaznamenaj odpovede\n```js\nON('response', function(options) {\n\tconsole.log(options.status, options.iserror); // 200 false\n});\n\nAJAX('GET /api/users/', NOOP);\n```\n\n### ON('scroll', function(area) {})\n\nType: `event`\n\nSpustí sa, keď sa vo vlastnom posuvníku začne posúvať.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | Posúvaný element. |\n\nPozri [SCROLLBAR()](../globals/).\n\nExample: Zisti posúvanie\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scroll', function(area) {\n\tconsole.log(area instanceof jQuery); // true\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('scrollidle', function(area) {})\n\nType: `event`\n\nSpustí sa, keď sa posúvanie vo vlastnom posuvníku zastavilo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `area` | `jQuery` | yes |  | Posúvaný element. |\n\nUdalosť príde 700 milisekúnd po poslednom pohybe.\n\nExample: Zisti koniec posúvania\n```html\n<div id=\"panel\" style=\"width:200px;height:100px\"><div style=\"height:600px\">Content</div></div>\n\n<script>\nON('scrollidle', function(area) {\n\tconsole.log(area.scrollTop()); // 20\n});\n\nvar scrollbar = SCROLLBAR($('#panel'));\nscrollbar.area.css('overflow', 'auto');\nscrollbar.scrollTop(20);\n</script>\n```\n\n### ON('service', function(counter) {})\n\nType: `event`\n\nSpustí sa každú minútu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `counter` | `Number` | yes |  | Počet minút od načítania stránky. |\n\nKnižnica najprv obnoví [NOW](../globals/), odstráni expirované položky cache a vyčistí [TEMP](../globals/).\n\nExample: Spusti periodickú úlohu\n```js\nON('service', function(counter) {\n\tconsole.log(counter); // 1\n});\n```\n\n### ON('visible', function(visible) {})\n\nType: `event`\n\nSpustí sa, keď stránka prejde do pozadia alebo sa z neho vráti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `visible` | `Boolean` | yes |  | `true`, keď je stránka viditeľná. |\n\nExample: Pozastav prácu na pozadí\n```js\nON('visible', function(visible) {\n\tconsole.log(visible); // true\n});\n```\n","entries":[{"type":"event","name":"@flag name","signature":"ON('@flag name', function(path) {})","since":"","deprecated":false},{"type":"event","name":"bind","signature":"ON('bind', function(binder) {})","since":"","deprecated":false},{"type":"event","name":"component","signature":"ON('component', function(component) {})","since":"","deprecated":false},{"type":"event","name":"env","signature":"ON('env', function(name, value) {})","since":"","deprecated":false},{"type":"event","name":"ERROR","signature":"ON('ERROR', function(response) {})","since":"","deprecated":false},{"type":"event","name":"import","signature":"ON('import', function(url, target) {})","since":"","deprecated":false},{"type":"event","name":"init","signature":"ON('init', function() {})","since":"","deprecated":false},{"type":"event","name":"knockknock","signature":"ON('knockknock', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"plugin","signature":"ON('plugin', function(plugin) {})","since":"","deprecated":false},{"type":"event","name":"ready","signature":"ON('ready', function() {})","since":"","deprecated":false},{"type":"event","name":"request","signature":"ON('request', function(options) {})","since":"","deprecated":false},{"type":"event","name":"resize2","signature":"ON('resize2', function() {})","since":"","deprecated":false},{"type":"event","name":"response","signature":"ON('response', function(options) {})","since":"","deprecated":false},{"type":"event","name":"scroll","signature":"ON('scroll', function(area) {})","since":"","deprecated":false},{"type":"event","name":"scrollidle","signature":"ON('scrollidle', function(area) {})","since":"","deprecated":false},{"type":"event","name":"service","signature":"ON('service', function(counter) {})","since":"","deprecated":false},{"type":"event","name":"visible","signature":"ON('visible', function(visible) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcWf7Uo61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/path/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"Path","summary":"The properties and the methods of a parsed path.","markdown":"---\ntitle: Path\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/path/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Path\n\n> The properties and the methods of a parsed path.\n\nA Path object holds a parsed path with its flags. It is available as `component.path` and `plugin.path`, and `new jComponent.Path(path)` creates one. The syntax of paths is explained in [Paths](../../guides/paths/) and [Flags and path modifiers](../../guides/flags/).\n\n## API\n\n### path\n\nType: `property`\n\nThe clean path without flags.\n\nReturns: `String` The clean path without flags.\n\nExample: Parse a path\n```js\nvar path = new jComponent.Path('form.user.name @touched #countries');\nconsole.log(path.path);\n// logs: form.user.name\nconsole.log(JSON.stringify(path.flags));\n// logs: {\"touched\":1}\nconsole.log(path.cl);\n// logs: countries\n```\n\n### raw\n\nType: `property`\n\nThe path with its flags, without code lists.\n\nReturns: `String` The path with its flags, without code lists.\n\n### flags\n\nType: `property`\n\nThe flags of the path as an object.\n\nReturns: `Object` The flags of the path as an object.\n\nA flag without a value has the value `1`. The form `@key:value` keeps the value.\n\n### split\n\nType: `property`\n\nThe path divided into its levels, from the first to the whole path.\n\nReturns: `Array` The path divided into its levels, from the first to the whole path.\n\n### cl\n\nType: `property`\n\nThe names of the code lists written with `#`, separated with a comma.\n\nReturns: `String` The names of the code lists written with `#`, separated with a comma.\n\n### cache\n\nType: `property`\n\nThe text written between `<` and `>`.\n\nReturns: `String` The text written between `<` and `>`.\n\n### ERROR\n\nType: `property`\n\nIs `true` when the path contains the keyword `ERROR`.\n\nReturns: `Boolean` Is `true` when the path contains the keyword `ERROR`.\n\n### SYNC\n\nType: `property`\n\nIs `true` when the path contains the keyword `SYNC`.\n\nReturns: `Boolean` Is `true` when the path contains the keyword `SYNC`.\n\n### toString()\n\nType: `method`\n\nReturns the clean path.\n\nReturns: `String` The path.\n\nExample: Convert to a string\n```js\nvar path = new jComponent.Path('form.name @touched');\nconsole.log(path.toString());\n// logs: form.name\n```\n\n### get(scope)\n\nType: `method`\n\nReads the value at the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | The object that the path is resolved against, usually `window`. |\n\nReturns: `Object` The value.\n\nExample: Read and write in your own object\n```js\nvar path = new jComponent.Path('user.name');\nvar scope = {};\npath.set(scope, 'Anna');\nconsole.log(JSON.stringify(scope), path.get(scope));\n// logs: {\"user\":{\"name\":\"Anna\"}} Anna\n```\n\n### set(scope, value)\n\nType: `method`\n\nWrites a value at the path, without notifying anything.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | The object that the path is resolved against, usually `window`. |\n| `value` | `Object` | yes |  | The value to write. |\n\nMissing parent objects are created.\n\n### notify(scope, [flags])\n\nType: `method`\n\nNotifies the components, watchers and binders bound to the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | The object that the path is resolved against, usually `window`. |\n| `flags` | `String` | no |  | Flags as a string such as `@touched`, or as an object such as `{ touched: 1 }`. |\n\nExample: Notify the watchers\n```js\nvar path = new jComponent.Path('common.count');\nWATCH('common.count', (value, flags) => console.log(value, JSON.stringify(flags)));\npath.set(window, 5);\npath.notify(window, '@touched');\n// logs: 5 {\"touched\":1}\n```\n\n### assign(path)\n\nType: `method`\n\nCreates a path relative to this one.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The relative path. |\n\nReturns: `Path` The new path.\n\nThe result depends on the first character of the argument:\n\n| Argument | Result for `form.user` |\n| --- | --- |\n| `name` | `form.user.name` |\n| `@touched` | `form.user` with the flag |\n| `?suffix` | `form.usersuffix` |\n| `*name` | `common.name` |\n| `#name` | `DEF.cl.name` |\n| `%name` | `DEF.tmp.name` |\n\nWithout an argument, the method returns the same object.\n\nExample: Build relative paths\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.assign('name').path);\n// logs: form.user.name\nconsole.log(path.assign('*name').path);\n// logs: common.name\n```\n\n### includes(path, [partially])\n\nType: `method`\n\nTells whether two paths lie on the same branch.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path to compare. |\n| `partially` | `Boolean` | no | `false` | Compares the last level of the argument. |\n\nReturns: `Boolean` The result of the comparison.\n\nThe result is `true` when one path is a parent of the other or both are the same. With `partially`, it is also `true` when a level of this path ends with the last level of the argument.\n\nExample: Compare paths\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.includes('form'), path.includes('form.user.name'), path.includes('form.other'));\n// logs: true true false\nconsole.log(new jComponent.Path('form.user.name').includes('name', true));\n// logs: true\n```\n\n### exec(callback)\n\nType: `method`\n\nEmits the flags of the path, loads its code lists and calls a function.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | The function to call. |\n\nEach flag is emitted as the event `@flag name`, with the path as the argument.\n\nExample: Run the flags of a path\n```js\nON('@flag saved', path => console.log('flag', path));\nnew jComponent.Path('form.user @saved').exec(() => console.log('done'));\n// logs: flag form.user\n// logs: done\n```\n\n### find(scope, callback)\n\nType: `method`\n\nFinds the ready components bound to the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | The object that the path is resolved against, usually `window`. |\n| `callback` | `Function` | yes |  | A function `(components)`. |\n\nThe flags `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` and `@enabled` limit the result.\n\nExample: Find components in a form\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nnew jComponent.Path('form').find(window, function(components) {\n    console.log(components.map(m => m.path.toString()).join());\n});\n// logs: form.name,form.email\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"raw","signature":"raw","since":"","deprecated":false},{"type":"property","name":"flags","signature":"flags","since":"","deprecated":false},{"type":"property","name":"split","signature":"split","since":"","deprecated":false},{"type":"property","name":"cl","signature":"cl","since":"","deprecated":false},{"type":"property","name":"cache","signature":"cache","since":"","deprecated":false},{"type":"property","name":"ERROR","signature":"ERROR","since":"","deprecated":false},{"type":"property","name":"SYNC","signature":"SYNC","since":"","deprecated":false},{"type":"method","name":"toString()","signature":"toString()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get(scope)","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(scope, value)","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"notify(scope, [flags])","since":"","deprecated":false},{"type":"method","name":"assign()","signature":"assign(path)","since":"","deprecated":false},{"type":"method","name":"includes()","signature":"includes(path, [partially])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(callback)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(scope, callback)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcWf7Uo61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/path/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"Path","summary":"Die Eigenschaften und Methoden eines geparsten Paths.","markdown":"---\ntitle: Path\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/path/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Path\n\n> Die Eigenschaften und Methoden eines geparsten Paths.\n\nEin Path-Objekt enthält einen geparsten Path mit seinen Flags. Es steht als `component.path` und `plugin.path` zur Verfügung, und `new jComponent.Path(path)` erstellt eines. Die Syntax von Paths ist in [Paths](../../guides/paths/) und [Flags und Path-Modifikatoren](../../guides/flags/) erklärt.\n\n## API\n\n### path\n\nType: `property`\n\nDer bereinigte Path ohne Flags.\n\nReturns: `String` Der bereinigte Path ohne Flags.\n\nExample: Path parsen\n```js\nvar path = new jComponent.Path('form.user.name @touched #countries');\nconsole.log(path.path);\n// logs: form.user.name\nconsole.log(JSON.stringify(path.flags));\n// logs: {\"touched\":1}\nconsole.log(path.cl);\n// logs: countries\n```\n\n### raw\n\nType: `property`\n\nDer Path mit seinen Flags, ohne Codelisten.\n\nReturns: `String` Der Path mit seinen Flags, ohne Codelisten.\n\n### flags\n\nType: `property`\n\nDie Flags des Paths als Objekt.\n\nReturns: `Object` Die Flags des Paths als Objekt.\n\nEin Flag ohne Wert hat den Wert `1`. Die Form `@key:value` behält den Wert.\n\n### split\n\nType: `property`\n\nDer Path, aufgeteilt in seine Ebenen, von der ersten bis zum gesamten Path.\n\nReturns: `Array` Der Path, aufgeteilt in seine Ebenen, von der ersten bis zum gesamten Path.\n\n### cl\n\nType: `property`\n\nDie mit `#` geschriebenen Namen der Codelisten, durch Kommas getrennt.\n\nReturns: `String` Die mit `#` geschriebenen Namen der Codelisten, durch Kommas getrennt.\n\n### cache\n\nType: `property`\n\nDer Text zwischen `<` und `>`.\n\nReturns: `String` Der Text zwischen `<` und `>`.\n\n### ERROR\n\nType: `property`\n\nIst `true`, wenn der Path das Schlüsselwort `ERROR` enthält.\n\nReturns: `Boolean` Ist `true`, wenn der Path das Schlüsselwort `ERROR` enthält.\n\n### SYNC\n\nType: `property`\n\nIst `true`, wenn der Path das Schlüsselwort `SYNC` enthält.\n\nReturns: `Boolean` Ist `true`, wenn der Path das Schlüsselwort `SYNC` enthält.\n\n### toString()\n\nType: `method`\n\nGibt den bereinigten Path zurück.\n\nReturns: `String` Der Path.\n\nExample: In einen String umwandeln\n```js\nvar path = new jComponent.Path('form.name @touched');\nconsole.log(path.toString());\n// logs: form.name\n```\n\n### get(scope)\n\nType: `method`\n\nLiest den Wert am Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Das Objekt, gegen das der Path aufgelöst wird, normalerweise `window`. |\n\nReturns: `Object` Der Wert.\n\nExample: In deinem eigenen Objekt lesen und schreiben\n```js\nvar path = new jComponent.Path('user.name');\nvar scope = {};\npath.set(scope, 'Anna');\nconsole.log(JSON.stringify(scope), path.get(scope));\n// logs: {\"user\":{\"name\":\"Anna\"}} Anna\n```\n\n### set(scope, value)\n\nType: `method`\n\nSchreibt einen Wert an den Path, ohne etwas zu benachrichtigen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Das Objekt, gegen das der Path aufgelöst wird, normalerweise `window`. |\n| `value` | `Object` | yes |  | Der zu schreibende Wert. |\n\nFehlende übergeordnete Objekte werden angelegt.\n\n### notify(scope, [flags])\n\nType: `method`\n\nBenachrichtigt die Komponenten, Watcher und Binder, die an den Path gebunden sind.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Das Objekt, gegen das der Path aufgelöst wird, normalerweise `window`. |\n| `flags` | `String` | no |  | Flags als String wie `@touched` oder als Objekt wie `{ touched: 1 }`. |\n\nExample: Watcher benachrichtigen\n```js\nvar path = new jComponent.Path('common.count');\nWATCH('common.count', (value, flags) => console.log(value, JSON.stringify(flags)));\npath.set(window, 5);\npath.notify(window, '@touched');\n// logs: 5 {\"touched\":1}\n```\n\n### assign(path)\n\nType: `method`\n\nErstellt einen Path relativ zu diesem.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der relative Path. |\n\nReturns: `Path` Der neue Path.\n\nDas Ergebnis hängt vom ersten Zeichen des Arguments ab:\n\n| Argument | Ergebnis für `form.user` |\n| --- | --- |\n| `name` | `form.user.name` |\n| `@touched` | `form.user` mit dem Flag |\n| `?suffix` | `form.usersuffix` |\n| `*name` | `common.name` |\n| `#name` | `DEF.cl.name` |\n| `%name` | `DEF.tmp.name` |\n\nOhne Argument gibt die Methode dasselbe Objekt zurück.\n\nExample: Relative Paths bilden\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.assign('name').path);\n// logs: form.user.name\nconsole.log(path.assign('*name').path);\n// logs: common.name\n```\n\n### includes(path, [partially])\n\nType: `method`\n\nGibt an, ob zwei Paths auf demselben Zweig liegen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der zu vergleichende Path. |\n| `partially` | `Boolean` | no | `false` | Vergleicht die letzte Ebene des Arguments. |\n\nReturns: `Boolean` Das Ergebnis des Vergleichs.\n\nDas Ergebnis ist `true`, wenn ein Path dem anderen übergeordnet ist oder beide gleich sind. Mit `partially` ist es auch `true`, wenn eine Ebene dieses Paths auf die letzte Ebene des Arguments endet.\n\nExample: Paths vergleichen\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.includes('form'), path.includes('form.user.name'), path.includes('form.other'));\n// logs: true true false\nconsole.log(new jComponent.Path('form.user.name').includes('name', true));\n// logs: true\n```\n\n### exec(callback)\n\nType: `method`\n\nLöst die Flags des Paths aus, lädt seine Codelisten und ruft eine Funktion auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | Die aufzurufende Funktion. |\n\nJedes Flag wird als Event `@flag name` ausgelöst, mit dem Path als Argument.\n\nExample: Flags eines Paths ausführen\n```js\nON('@flag saved', path => console.log('flag', path));\nnew jComponent.Path('form.user @saved').exec(() => console.log('done'));\n// logs: flag form.user\n// logs: done\n```\n\n### find(scope, callback)\n\nType: `method`\n\nFindet die bereiten Komponenten, die an den Path gebunden sind.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Das Objekt, gegen das der Path aufgelöst wird, normalerweise `window`. |\n| `callback` | `Function` | yes |  | Eine Funktion `(components)`. |\n\nDie Flags `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` und `@enabled` schränken das Ergebnis ein.\n\nExample: Komponenten in einem Formular finden\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nnew jComponent.Path('form').find(window, function(components) {\n    console.log(components.map(m => m.path.toString()).join());\n});\n// logs: form.name,form.email\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"raw","signature":"raw","since":"","deprecated":false},{"type":"property","name":"flags","signature":"flags","since":"","deprecated":false},{"type":"property","name":"split","signature":"split","since":"","deprecated":false},{"type":"property","name":"cl","signature":"cl","since":"","deprecated":false},{"type":"property","name":"cache","signature":"cache","since":"","deprecated":false},{"type":"property","name":"ERROR","signature":"ERROR","since":"","deprecated":false},{"type":"property","name":"SYNC","signature":"SYNC","since":"","deprecated":false},{"type":"method","name":"toString()","signature":"toString()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get(scope)","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(scope, value)","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"notify(scope, [flags])","since":"","deprecated":false},{"type":"method","name":"assign()","signature":"assign(path)","since":"","deprecated":false},{"type":"method","name":"includes()","signature":"includes(path, [partially])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(callback)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(scope, callback)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcWf7Uo61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/path/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Path","summary":"Las propiedades y los métodos de un path analizado.","markdown":"---\ntitle: Path\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/path/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Path\n\n> Las propiedades y los métodos de un path analizado.\n\nUn objeto Path contiene un path analizado con sus flags. Está disponible como `component.path` y `plugin.path`, y `new jComponent.Path(path)` crea uno. La sintaxis de los paths se explica en [Paths](../../guides/paths/) y en [Flags y modificadores de path](../../guides/flags/).\n\n## API\n\n### path\n\nType: `property`\n\nEl path limpio, sin flags.\n\nReturns: `String` El path limpio, sin flags.\n\nExample: Analizar un path\n```js\nvar path = new jComponent.Path('form.user.name @touched #countries');\nconsole.log(path.path);\n// logs: form.user.name\nconsole.log(JSON.stringify(path.flags));\n// logs: {\"touched\":1}\nconsole.log(path.cl);\n// logs: countries\n```\n\n### raw\n\nType: `property`\n\nEl path con sus flags, sin listas de códigos.\n\nReturns: `String` El path con sus flags, sin listas de códigos.\n\n### flags\n\nType: `property`\n\nLos flags del path como objeto.\n\nReturns: `Object` Los flags del path como objeto.\n\nUn flag sin valor tiene el valor `1`. La forma `@key:value` conserva el valor.\n\n### split\n\nType: `property`\n\nEl path dividido en sus niveles, desde el primero hasta el path completo.\n\nReturns: `Array` El path dividido en sus niveles, desde el primero hasta el path completo.\n\n### cl\n\nType: `property`\n\nLos nombres de las listas de códigos escritos con `#`, separados por comas.\n\nReturns: `String` Los nombres de las listas de códigos escritos con `#`, separados por comas.\n\n### cache\n\nType: `property`\n\nEl texto escrito entre `<` y `>`.\n\nReturns: `String` El texto escrito entre `<` y `>`.\n\n### ERROR\n\nType: `property`\n\nEs `true` cuando el path contiene la palabra clave `ERROR`.\n\nReturns: `Boolean` Es `true` cuando el path contiene la palabra clave `ERROR`.\n\n### SYNC\n\nType: `property`\n\nEs `true` cuando el path contiene la palabra clave `SYNC`.\n\nReturns: `Boolean` Es `true` cuando el path contiene la palabra clave `SYNC`.\n\n### toString()\n\nType: `method`\n\nDevuelve el path limpio.\n\nReturns: `String` El path.\n\nExample: Convertir a cadena\n```js\nvar path = new jComponent.Path('form.name @touched');\nconsole.log(path.toString());\n// logs: form.name\n```\n\n### get(scope)\n\nType: `method`\n\nLee el valor del path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | El objeto sobre el que se resuelve el path, normalmente `window`. |\n\nReturns: `Object` El valor.\n\nExample: Leer y escribir en tu propio objeto\n```js\nvar path = new jComponent.Path('user.name');\nvar scope = {};\npath.set(scope, 'Anna');\nconsole.log(JSON.stringify(scope), path.get(scope));\n// logs: {\"user\":{\"name\":\"Anna\"}} Anna\n```\n\n### set(scope, value)\n\nType: `method`\n\nEscribe un valor en el path, sin notificar nada.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | El objeto sobre el que se resuelve el path, normalmente `window`. |\n| `value` | `Object` | yes |  | El valor que se va a escribir. |\n\nLos objetos padre que faltan se crean.\n\n### notify(scope, [flags])\n\nType: `method`\n\nNotifica a los componentes, observadores y binders enlazados al path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | El objeto sobre el que se resuelve el path, normalmente `window`. |\n| `flags` | `String` | no |  | Flags como cadena, por ejemplo `@touched`, o como objeto, por ejemplo `{ touched: 1 }`. |\n\nExample: Notificar a los observadores\n```js\nvar path = new jComponent.Path('common.count');\nWATCH('common.count', (value, flags) => console.log(value, JSON.stringify(flags)));\npath.set(window, 5);\npath.notify(window, '@touched');\n// logs: 5 {\"touched\":1}\n```\n\n### assign(path)\n\nType: `method`\n\nCrea un path relativo a este.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path relativo. |\n\nReturns: `Path` El nuevo path.\n\nEl resultado depende del primer carácter del argumento:\n\n| Argumento | Resultado para `form.user` |\n| --- | --- |\n| `name` | `form.user.name` |\n| `@touched` | `form.user` con el flag |\n| `?suffix` | `form.usersuffix` |\n| `*name` | `common.name` |\n| `#name` | `DEF.cl.name` |\n| `%name` | `DEF.tmp.name` |\n\nSin argumento, el método devuelve el mismo objeto.\n\nExample: Construir paths relativos\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.assign('name').path);\n// logs: form.user.name\nconsole.log(path.assign('*name').path);\n// logs: common.name\n```\n\n### includes(path, [partially])\n\nType: `method`\n\nIndica si dos paths están en la misma rama.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path que se compara. |\n| `partially` | `Boolean` | no | `false` | Compara el último nivel del argumento. |\n\nReturns: `Boolean` El resultado de la comparación.\n\nEl resultado es `true` cuando un path es padre del otro o ambos son iguales. Con `partially`, también es `true` cuando un nivel de este path termina con el último nivel del argumento.\n\nExample: Comparar paths\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.includes('form'), path.includes('form.user.name'), path.includes('form.other'));\n// logs: true true false\nconsole.log(new jComponent.Path('form.user.name').includes('name', true));\n// logs: true\n```\n\n### exec(callback)\n\nType: `method`\n\nEmite los flags del path, carga sus listas de códigos y llama a una función.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | La función a la que se llama. |\n\nCada flag se emite como el evento `@flag name`, con el path como argumento.\n\nExample: Ejecutar los flags de un path\n```js\nON('@flag saved', path => console.log('flag', path));\nnew jComponent.Path('form.user @saved').exec(() => console.log('done'));\n// logs: flag form.user\n// logs: done\n```\n\n### find(scope, callback)\n\nType: `method`\n\nBusca los componentes listos enlazados al path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | El objeto sobre el que se resuelve el path, normalmente `window`. |\n| `callback` | `Function` | yes |  | Una función `(components)`. |\n\nLos flags `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` y `@enabled` limitan el resultado.\n\nExample: Buscar componentes en un formulario\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nnew jComponent.Path('form').find(window, function(components) {\n    console.log(components.map(m => m.path.toString()).join());\n});\n// logs: form.name,form.email\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"raw","signature":"raw","since":"","deprecated":false},{"type":"property","name":"flags","signature":"flags","since":"","deprecated":false},{"type":"property","name":"split","signature":"split","since":"","deprecated":false},{"type":"property","name":"cl","signature":"cl","since":"","deprecated":false},{"type":"property","name":"cache","signature":"cache","since":"","deprecated":false},{"type":"property","name":"ERROR","signature":"ERROR","since":"","deprecated":false},{"type":"property","name":"SYNC","signature":"SYNC","since":"","deprecated":false},{"type":"method","name":"toString()","signature":"toString()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get(scope)","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(scope, value)","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"notify(scope, [flags])","since":"","deprecated":false},{"type":"method","name":"assign()","signature":"assign(path)","since":"","deprecated":false},{"type":"method","name":"includes()","signature":"includes(path, [partially])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(callback)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(scope, callback)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcWf7Uo61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/path/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Path","summary":"Les propriétés et les méthodes d'un path analysé.","markdown":"---\ntitle: Path\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/path/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Path\n\n> Les propriétés et les méthodes d'un path analysé.\n\nUn objet Path contient un path analysé avec ses flags. Il est disponible sous la forme `component.path` et `plugin.path`, et `new jComponent.Path(path)` en crée un. La syntaxe des paths est expliquée dans [Paths](../../guides/paths/) et [Flags et modificateurs de path](../../guides/flags/).\n\n## API\n\n### path\n\nType: `property`\n\nLe path nettoyé, sans flags.\n\nReturns: `String` Le path nettoyé, sans flags.\n\nExample: Analyser un path\n```js\nvar path = new jComponent.Path('form.user.name @touched #countries');\nconsole.log(path.path);\n// logs: form.user.name\nconsole.log(JSON.stringify(path.flags));\n// logs: {\"touched\":1}\nconsole.log(path.cl);\n// logs: countries\n```\n\n### raw\n\nType: `property`\n\nLe path avec ses flags, sans listes de codes.\n\nReturns: `String` Le path avec ses flags, sans listes de codes.\n\n### flags\n\nType: `property`\n\nLes flags du path sous forme d'objet.\n\nReturns: `Object` Les flags du path sous forme d'objet.\n\nUn flag sans valeur a la valeur `1`. La forme `@key:value` conserve la valeur.\n\n### split\n\nType: `property`\n\nLe path découpé en niveaux, du premier jusqu'au path complet.\n\nReturns: `Array` Le path découpé en niveaux, du premier jusqu'au path complet.\n\n### cl\n\nType: `property`\n\nLes noms des listes de codes écrits avec `#`, séparés par une virgule.\n\nReturns: `String` Les noms des listes de codes écrits avec `#`, séparés par une virgule.\n\n### cache\n\nType: `property`\n\nLe texte écrit entre `<` et `>`.\n\nReturns: `String` Le texte écrit entre `<` et `>`.\n\n### ERROR\n\nType: `property`\n\nVaut `true` quand le path contient le mot-clé `ERROR`.\n\nReturns: `Boolean` Vaut `true` quand le path contient le mot-clé `ERROR`.\n\n### SYNC\n\nType: `property`\n\nVaut `true` quand le path contient le mot-clé `SYNC`.\n\nReturns: `Boolean` Vaut `true` quand le path contient le mot-clé `SYNC`.\n\n### toString()\n\nType: `method`\n\nRenvoie le path nettoyé.\n\nReturns: `String` Le path.\n\nExample: Convertir en chaîne\n```js\nvar path = new jComponent.Path('form.name @touched');\nconsole.log(path.toString());\n// logs: form.name\n```\n\n### get(scope)\n\nType: `method`\n\nLit la valeur située au path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'objet par rapport auquel le path est résolu, en général `window`. |\n\nReturns: `Object` La valeur.\n\nExample: Lire et écrire dans ton propre objet\n```js\nvar path = new jComponent.Path('user.name');\nvar scope = {};\npath.set(scope, 'Anna');\nconsole.log(JSON.stringify(scope), path.get(scope));\n// logs: {\"user\":{\"name\":\"Anna\"}} Anna\n```\n\n### set(scope, value)\n\nType: `method`\n\nÉcrit une valeur au path, sans rien notifier.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'objet par rapport auquel le path est résolu, en général `window`. |\n| `value` | `Object` | yes |  | La valeur à écrire. |\n\nLes objets parents manquants sont créés.\n\n### notify(scope, [flags])\n\nType: `method`\n\nNotifie les composants, les observateurs et les binders liés au path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'objet par rapport auquel le path est résolu, en général `window`. |\n| `flags` | `String` | no |  | Les flags sous forme de chaîne comme `@touched`, ou d'objet comme `{ touched: 1 }`. |\n\nExample: Notifier les observateurs\n```js\nvar path = new jComponent.Path('common.count');\nWATCH('common.count', (value, flags) => console.log(value, JSON.stringify(flags)));\npath.set(window, 5);\npath.notify(window, '@touched');\n// logs: 5 {\"touched\":1}\n```\n\n### assign(path)\n\nType: `method`\n\nCrée un path relatif à celui-ci.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path relatif. |\n\nReturns: `Path` Le nouveau path.\n\nLe résultat dépend du premier caractère de l'argument :\n\n| Argument | Résultat pour `form.user` |\n| --- | --- |\n| `name` | `form.user.name` |\n| `@touched` | `form.user` avec le flag |\n| `?suffix` | `form.usersuffix` |\n| `*name` | `common.name` |\n| `#name` | `DEF.cl.name` |\n| `%name` | `DEF.tmp.name` |\n\nSans argument, la méthode renvoie le même objet.\n\nExample: Construire des paths relatifs\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.assign('name').path);\n// logs: form.user.name\nconsole.log(path.assign('*name').path);\n// logs: common.name\n```\n\n### includes(path, [partially])\n\nType: `method`\n\nIndique si deux paths se trouvent sur la même branche.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path à comparer. |\n| `partially` | `Boolean` | no | `false` | Compare le dernier niveau de l'argument. |\n\nReturns: `Boolean` Le résultat de la comparaison.\n\nLe résultat est `true` quand un path est le parent de l'autre ou que les deux sont identiques. Avec `partially`, il vaut aussi `true` quand un niveau de ce path se termine par le dernier niveau de l'argument.\n\nExample: Comparer des paths\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.includes('form'), path.includes('form.user.name'), path.includes('form.other'));\n// logs: true true false\nconsole.log(new jComponent.Path('form.user.name').includes('name', true));\n// logs: true\n```\n\n### exec(callback)\n\nType: `method`\n\nÉmet les flags du path, charge ses listes de codes et appelle une fonction.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | La fonction à appeler. |\n\nChaque flag est émis sous la forme de l'événement `@flag name`, avec le path comme argument.\n\nExample: Exécuter les flags d'un path\n```js\nON('@flag saved', path => console.log('flag', path));\nnew jComponent.Path('form.user @saved').exec(() => console.log('done'));\n// logs: flag form.user\n// logs: done\n```\n\n### find(scope, callback)\n\nType: `method`\n\nTrouve les composants prêts liés au path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'objet par rapport auquel le path est résolu, en général `window`. |\n| `callback` | `Function` | yes |  | Une fonction `(components)`. |\n\nLes flags `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` et `@enabled` limitent le résultat.\n\nExample: Trouver les composants d'un formulaire\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nnew jComponent.Path('form').find(window, function(components) {\n    console.log(components.map(m => m.path.toString()).join());\n});\n// logs: form.name,form.email\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"raw","signature":"raw","since":"","deprecated":false},{"type":"property","name":"flags","signature":"flags","since":"","deprecated":false},{"type":"property","name":"split","signature":"split","since":"","deprecated":false},{"type":"property","name":"cl","signature":"cl","since":"","deprecated":false},{"type":"property","name":"cache","signature":"cache","since":"","deprecated":false},{"type":"property","name":"ERROR","signature":"ERROR","since":"","deprecated":false},{"type":"property","name":"SYNC","signature":"SYNC","since":"","deprecated":false},{"type":"method","name":"toString()","signature":"toString()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get(scope)","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(scope, value)","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"notify(scope, [flags])","since":"","deprecated":false},{"type":"method","name":"assign()","signature":"assign(path)","since":"","deprecated":false},{"type":"method","name":"includes()","signature":"includes(path, [partially])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(callback)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(scope, callback)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcWf7Uo61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/path/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Path","summary":"Le proprietà e i metodi di un path analizzato.","markdown":"---\ntitle: Path\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/path/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Path\n\n> Le proprietà e i metodi di un path analizzato.\n\nUn oggetto Path contiene un path analizzato con i suoi flag. È disponibile come `component.path` e `plugin.path`, e `new jComponent.Path(path)` ne crea uno. La sintassi dei path è spiegata in [Path](../../guides/paths/) e in [Flag e modificatori di path](../../guides/flags/).\n\n## API\n\n### path\n\nType: `property`\n\nIl path pulito, senza flag.\n\nReturns: `String` Il path pulito, senza flag.\n\nExample: Analizza un path\n```js\nvar path = new jComponent.Path('form.user.name @touched #countries');\nconsole.log(path.path);\n// logs: form.user.name\nconsole.log(JSON.stringify(path.flags));\n// logs: {\"touched\":1}\nconsole.log(path.cl);\n// logs: countries\n```\n\n### raw\n\nType: `property`\n\nIl path con i suoi flag, senza elenchi di codici.\n\nReturns: `String` Il path con i suoi flag, senza elenchi di codici.\n\n### flags\n\nType: `property`\n\nI flag del path sotto forma di oggetto.\n\nReturns: `Object` I flag del path sotto forma di oggetto.\n\nUn flag senza valore ha il valore `1`. La forma `@key:value` conserva il valore.\n\n### split\n\nType: `property`\n\nIl path suddiviso nei suoi livelli, dal primo fino al path completo.\n\nReturns: `Array` Il path suddiviso nei suoi livelli, dal primo fino al path completo.\n\n### cl\n\nType: `property`\n\nI nomi degli elenchi di codici scritti con `#`, separati da una virgola.\n\nReturns: `String` I nomi degli elenchi di codici scritti con `#`, separati da una virgola.\n\n### cache\n\nType: `property`\n\nIl testo scritto tra `<` e `>`.\n\nReturns: `String` Il testo scritto tra `<` e `>`.\n\n### ERROR\n\nType: `property`\n\nÈ `true` quando il path contiene la parola chiave `ERROR`.\n\nReturns: `Boolean` È `true` quando il path contiene la parola chiave `ERROR`.\n\n### SYNC\n\nType: `property`\n\nÈ `true` quando il path contiene la parola chiave `SYNC`.\n\nReturns: `Boolean` È `true` quando il path contiene la parola chiave `SYNC`.\n\n### toString()\n\nType: `method`\n\nRestituisce il path pulito.\n\nReturns: `String` Il path.\n\nExample: Converti in stringa\n```js\nvar path = new jComponent.Path('form.name @touched');\nconsole.log(path.toString());\n// logs: form.name\n```\n\n### get(scope)\n\nType: `method`\n\nLegge il valore nel path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'oggetto rispetto al quale viene risolto il path, di solito `window`. |\n\nReturns: `Object` Il valore.\n\nExample: Leggi e scrivi nel tuo oggetto\n```js\nvar path = new jComponent.Path('user.name');\nvar scope = {};\npath.set(scope, 'Anna');\nconsole.log(JSON.stringify(scope), path.get(scope));\n// logs: {\"user\":{\"name\":\"Anna\"}} Anna\n```\n\n### set(scope, value)\n\nType: `method`\n\nScrive un valore nel path, senza notificare nulla.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'oggetto rispetto al quale viene risolto il path, di solito `window`. |\n| `value` | `Object` | yes |  | Il valore da scrivere. |\n\nGli oggetti genitori mancanti vengono creati.\n\n### notify(scope, [flags])\n\nType: `method`\n\nNotifica i componenti, gli osservatori e i binder associati al path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'oggetto rispetto al quale viene risolto il path, di solito `window`. |\n| `flags` | `String` | no |  | I flag come stringa, ad esempio `@touched`, o come oggetto, ad esempio `{ touched: 1 }`. |\n\nExample: Notifica gli osservatori\n```js\nvar path = new jComponent.Path('common.count');\nWATCH('common.count', (value, flags) => console.log(value, JSON.stringify(flags)));\npath.set(window, 5);\npath.notify(window, '@touched');\n// logs: 5 {\"touched\":1}\n```\n\n### assign(path)\n\nType: `method`\n\nCrea un path relativo a questo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path relativo. |\n\nReturns: `Path` Il nuovo path.\n\nIl risultato dipende dal primo carattere dell'argomento:\n\n| Argomento | Risultato per `form.user` |\n| --- | --- |\n| `name` | `form.user.name` |\n| `@touched` | `form.user` con il flag |\n| `?suffix` | `form.usersuffix` |\n| `*name` | `common.name` |\n| `#name` | `DEF.cl.name` |\n| `%name` | `DEF.tmp.name` |\n\nSenza argomento, il metodo restituisce lo stesso oggetto.\n\nExample: Costruisci path relativi\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.assign('name').path);\n// logs: form.user.name\nconsole.log(path.assign('*name').path);\n// logs: common.name\n```\n\n### includes(path, [partially])\n\nType: `method`\n\nIndica se due path si trovano sullo stesso ramo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path da confrontare. |\n| `partially` | `Boolean` | no | `false` | Confronta l'ultimo livello dell'argomento. |\n\nReturns: `Boolean` Il risultato del confronto.\n\nIl risultato è `true` quando un path è genitore dell'altro o quando sono uguali. Con `partially`, è `true` anche quando un livello di questo path termina con l'ultimo livello dell'argomento.\n\nExample: Confronta i path\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.includes('form'), path.includes('form.user.name'), path.includes('form.other'));\n// logs: true true false\nconsole.log(new jComponent.Path('form.user.name').includes('name', true));\n// logs: true\n```\n\n### exec(callback)\n\nType: `method`\n\nEmette i flag del path, carica i suoi elenchi di codici e chiama una funzione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | La funzione da chiamare. |\n\nOgni flag viene emesso come evento `@flag name`, con il path come argomento.\n\nExample: Esegui i flag di un path\n```js\nON('@flag saved', path => console.log('flag', path));\nnew jComponent.Path('form.user @saved').exec(() => console.log('done'));\n// logs: flag form.user\n// logs: done\n```\n\n### find(scope, callback)\n\nType: `method`\n\nTrova i componenti pronti associati al path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | L'oggetto rispetto al quale viene risolto il path, di solito `window`. |\n| `callback` | `Function` | yes |  | Una funzione `(components)`. |\n\nI flag `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` e `@enabled` limitano il risultato.\n\nExample: Trova i componenti in un modulo\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nnew jComponent.Path('form').find(window, function(components) {\n    console.log(components.map(m => m.path.toString()).join());\n});\n// logs: form.name,form.email\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"raw","signature":"raw","since":"","deprecated":false},{"type":"property","name":"flags","signature":"flags","since":"","deprecated":false},{"type":"property","name":"split","signature":"split","since":"","deprecated":false},{"type":"property","name":"cl","signature":"cl","since":"","deprecated":false},{"type":"property","name":"cache","signature":"cache","since":"","deprecated":false},{"type":"property","name":"ERROR","signature":"ERROR","since":"","deprecated":false},{"type":"property","name":"SYNC","signature":"SYNC","since":"","deprecated":false},{"type":"method","name":"toString()","signature":"toString()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get(scope)","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(scope, value)","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"notify(scope, [flags])","since":"","deprecated":false},{"type":"method","name":"assign()","signature":"assign(path)","since":"","deprecated":false},{"type":"method","name":"includes()","signature":"includes(path, [partially])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(callback)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(scope, callback)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcWf7Uo61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/path/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Path","summary":"Vlastnosti a metódy analyzovaného path.","markdown":"---\ntitle: Path\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/path/\nupdated: 2026-11-18T13:58:14.460Z\n---\n\n# Path\n\n> Vlastnosti a metódy analyzovaného path.\n\nObjekt Path uchováva analyzovaný path s jeho flagmi. Je dostupný ako `component.path` a `plugin.path` a vytvoríš ho pomocou `new jComponent.Path(path)`. Syntax paths vysvetľujú časti [Paths](../../guides/paths/) a [Flagy a modifikátory path](../../guides/flags/).\n\n## API\n\n### path\n\nType: `property`\n\nČistý path bez flagov.\n\nReturns: `String` Čistý path bez flagov.\n\nExample: Analyzuj path\n```js\nvar path = new jComponent.Path('form.user.name @touched #countries');\nconsole.log(path.path);\n// logs: form.user.name\nconsole.log(JSON.stringify(path.flags));\n// logs: {\"touched\":1}\nconsole.log(path.cl);\n// logs: countries\n```\n\n### raw\n\nType: `property`\n\nPath s flagmi, bez zoznamov kódov.\n\nReturns: `String` Path s flagmi, bez zoznamov kódov.\n\n### flags\n\nType: `property`\n\nFlagy daného path ako objekt.\n\nReturns: `Object` Flagy daného path ako objekt.\n\nFlag bez hodnoty má hodnotu `1`. Tvar `@key:value` hodnotu zachová.\n\n### split\n\nType: `property`\n\nPath rozdelený na úrovne, od prvej až po celý path.\n\nReturns: `Array` Path rozdelený na úrovne, od prvej až po celý path.\n\n### cl\n\nType: `property`\n\nNázvy zoznamov kódov zapísané pomocou `#`, oddelené čiarkou.\n\nReturns: `String` Názvy zoznamov kódov zapísané pomocou `#`, oddelené čiarkou.\n\n### cache\n\nType: `property`\n\nText zapísaný medzi `<` a `>`.\n\nReturns: `String` Text zapísaný medzi `<` a `>`.\n\n### ERROR\n\nType: `property`\n\nJe `true`, keď path obsahuje kľúčové slovo `ERROR`.\n\nReturns: `Boolean` Je `true`, keď path obsahuje kľúčové slovo `ERROR`.\n\n### SYNC\n\nType: `property`\n\nJe `true`, keď path obsahuje kľúčové slovo `SYNC`.\n\nReturns: `Boolean` Je `true`, keď path obsahuje kľúčové slovo `SYNC`.\n\n### toString()\n\nType: `method`\n\nVráti čistý path.\n\nReturns: `String` Path.\n\nExample: Preveď na reťazec\n```js\nvar path = new jComponent.Path('form.name @touched');\nconsole.log(path.toString());\n// logs: form.name\n```\n\n### get(scope)\n\nType: `method`\n\nPrečíta hodnotu na danom path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Objekt, voči ktorému sa path vyhodnocuje, zvyčajne `window`. |\n\nReturns: `Object` Hodnota.\n\nExample: Čítaj a zapisuj vo vlastnom objekte\n```js\nvar path = new jComponent.Path('user.name');\nvar scope = {};\npath.set(scope, 'Anna');\nconsole.log(JSON.stringify(scope), path.get(scope));\n// logs: {\"user\":{\"name\":\"Anna\"}} Anna\n```\n\n### set(scope, value)\n\nType: `method`\n\nZapíše hodnotu na path bez akéhokoľvek upozornenia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Objekt, voči ktorému sa path vyhodnocuje, zvyčajne `window`. |\n| `value` | `Object` | yes |  | Hodnota na zápis. |\n\nChýbajúce nadradené objekty sa vytvoria.\n\n### notify(scope, [flags])\n\nType: `method`\n\nUpozorní komponenty, sledovače a bindery naviazané na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Objekt, voči ktorému sa path vyhodnocuje, zvyčajne `window`. |\n| `flags` | `String` | no |  | Flagy ako reťazec, napríklad `@touched`, alebo ako objekt, napríklad `{ touched: 1 }`. |\n\nExample: Upozorni sledovače\n```js\nvar path = new jComponent.Path('common.count');\nWATCH('common.count', (value, flags) => console.log(value, JSON.stringify(flags)));\npath.set(window, 5);\npath.notify(window, '@touched');\n// logs: 5 {\"touched\":1}\n```\n\n### assign(path)\n\nType: `method`\n\nVytvorí path relatívny k tomuto path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Relatívny path. |\n\nReturns: `Path` Nový path.\n\nVýsledok závisí od prvého znaku argumentu:\n\n| Argument | Výsledok pre `form.user` |\n| --- | --- |\n| `name` | `form.user.name` |\n| `@touched` | `form.user` s flagom |\n| `?suffix` | `form.usersuffix` |\n| `*name` | `common.name` |\n| `#name` | `DEF.cl.name` |\n| `%name` | `DEF.tmp.name` |\n\nBez argumentu metóda vráti ten istý objekt.\n\nExample: Vytvor relatívne paths\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.assign('name').path);\n// logs: form.user.name\nconsole.log(path.assign('*name').path);\n// logs: common.name\n```\n\n### includes(path, [partially])\n\nType: `method`\n\nZistí, či dva paths ležia na tej istej vetve.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path na porovnanie. |\n| `partially` | `Boolean` | no | `false` | Porovná poslednú úroveň argumentu. |\n\nReturns: `Boolean` Výsledok porovnania.\n\nVýsledok je `true`, keď je jeden path nadradený druhému alebo keď sú oba rovnaké. S `partially` je `true` aj vtedy, keď sa niektorá úroveň tohto path končí poslednou úrovňou argumentu.\n\nExample: Porovnaj paths\n```js\nvar path = new jComponent.Path('form.user');\nconsole.log(path.includes('form'), path.includes('form.user.name'), path.includes('form.other'));\n// logs: true true false\nconsole.log(new jComponent.Path('form.user.name').includes('name', true));\n// logs: true\n```\n\n### exec(callback)\n\nType: `method`\n\nVyšle flagy daného path, načíta jeho zoznamy kódov a zavolá funkciu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `callback` | `Function` | yes |  | Funkcia, ktorá sa má zavolať. |\n\nKaždý flag sa vyšle ako udalosť `@flag name` s path ako argumentom.\n\nExample: Spusti flagy daného path\n```js\nON('@flag saved', path => console.log('flag', path));\nnew jComponent.Path('form.user @saved').exec(() => console.log('done'));\n// logs: flag form.user\n// logs: done\n```\n\n### find(scope, callback)\n\nType: `method`\n\nNájde pripravené komponenty naviazané na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `scope` | `Object` | yes |  | Objekt, voči ktorému sa path vyhodnocuje, zvyčajne `window`. |\n| `callback` | `Function` | yes |  | Funkcia `(components)`. |\n\nVýsledok obmedzujú flagy `@visible`, `@touched`, `@modified`, `@required`, `@invalid`, `@disabled` a `@enabled`.\n\nExample: Nájdi komponenty vo formulári\n```html\n<ui-component name=\"field\" path=\"form.name\"></ui-component>\n<ui-component name=\"field\" path=\"form.email\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nnew jComponent.Path('form').find(window, function(components) {\n    console.log(components.map(m => m.path.toString()).join());\n});\n// logs: form.name,form.email\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"raw","signature":"raw","since":"","deprecated":false},{"type":"property","name":"flags","signature":"flags","since":"","deprecated":false},{"type":"property","name":"split","signature":"split","since":"","deprecated":false},{"type":"property","name":"cl","signature":"cl","since":"","deprecated":false},{"type":"property","name":"cache","signature":"cache","since":"","deprecated":false},{"type":"property","name":"ERROR","signature":"ERROR","since":"","deprecated":false},{"type":"property","name":"SYNC","signature":"SYNC","since":"","deprecated":false},{"type":"method","name":"toString()","signature":"toString()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get(scope)","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(scope, value)","since":"","deprecated":false},{"type":"method","name":"notify()","signature":"notify(scope, [flags])","since":"","deprecated":false},{"type":"method","name":"assign()","signature":"assign(path)","since":"","deprecated":false},{"type":"method","name":"includes()","signature":"includes(path, [partially])","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(callback)","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(scope, callback)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:14.460Z"}
{"id":"JamcZCAUo61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/ui-bind/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"ui-bind","summary":"The attributes and the commands of the ui-bind element.","markdown":"---\ntitle: ui-bind\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/ui-bind/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# ui-bind\n\n> The attributes and the commands of the ui-bind element.\n\nThe `<ui-bind>` element updates the page each time the value at a path changes. The `config` attribute holds a list of commands separated with `;`. The [Data binding](../../guides/data-binding/) guide explains how to use it.\n\nA command has the form `name:expression`, or `name selector:expression` to act on the elements found by a selector inside the target. Without an expression, the command uses the value at the path. The expression is JavaScript and can use `value`, `path`, `flags`, `element` and `el` (the same as `element`). Join command names with `+` to give them the same expression, for example `text+title:value`. Write `\\\\;` for a semicolon inside an expression. All commands run once when the element is created, with the current value at the path. An error in an expression is written to the console and the commands continue.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nThe path to observe.\n\nA `?` is replaced with the path of the parent plugin. With a `!` at the beginning (`!common.user`), the commands do not run while the value is `null` or `undefined`.\n\nExample: Skip empty values\n```html\n<ui-bind path=\"!common.user\" config=\"text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Peter' });\nconsole.log($('ui-bind').text());\n// logs: Peter\n</script>\n```\n\n### config=\"commands\"\n\nType: `property`\n\nThe commands, separated with `;`.\n\nThe values are kept as strings, because they are compiled as JavaScript.\n\n### element=\"selector\"\n\nType: `property`\n\nRuns the commands on the elements found by a selector in the whole document.\n\nExample: Update an element elsewhere in the page\n```html\n<h1 id=\"title\"></h1>\n<ui-bind path=\"common.title\" element=\"#title\" config=\"text\"></ui-bind>\n\n<script>\nSET('common.title', 'Orders');\nconsole.log($('#title').text());\n// logs: Orders\n</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nRuns the commands on the elements found by a selector inside the element.\n\nThe `value` command needs this attribute or a selector to reach an input.\n\nExample: Fill an input\n```html\n<ui-bind path=\"common.email\" child=\"input\" config=\"value\"><input /></ui-bind>\n\n<script>\nSET('common.email', 'info@example.com');\nconsole.log($('input').val());\n// logs: info@example.com\n</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nRuns the commands on the closest parent found by a selector.\n\nExample: Change a parent element\n```html\n<div class=\"row\">\n    <ui-bind path=\"common.active\" parent=\".row\" config=\".selected\"></ui-bind>\n</div>\n\n<script>\nSET('common.active', true);\nconsole.log($('.row').attr('class'));\n// logs: row selected\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCreates a plugin on the element itself, and a `?` in the path refers to it.\n\nExample: A binder with its own plugin\n```html\n<ui-bind plugin=\"clock\" path=\"?.time\" config=\"text\"></ui-bind>\n\n<script>\nPLUGIN('clock', function(exports) {\n    exports.make = () => exports.set('time', '12:00');\n});\n\nconsole.log($('ui-bind').text());\n// logs: 12:00\n</script>\n```\n\n### .name:expression\n\nType: `command`\n\nToggles the CSS class `name` according to the result of the expression.\n\nExample: Toggle classes\n```html\n<ui-bind path=\"common.count\" config=\".empty:!value;.many:value > 10\"></ui-bind>\n\n<script>\nSET('common.count', 20);\nconsole.log($('ui-bind').attr('class'));\n// logs: many\n</script>\n```\n\n### text:expression\n\nType: `command`\n\nSets the text of the element. HTML is escaped.\n\nA `null`, `undefined`, `false` or empty-string result writes the value of the `empty` command, and `0` is written as `0`. Nothing is written while the element is hidden by `show`, `hide`, `visible` or `invisible`, unless `forcerender` allows it.\n\nExample: Show a text\n```html\n<ui-bind path=\"common.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n\n<script>\nSET('common.name', 'anna');\nconsole.log($('ui-bind').text());\n// logs: ANNA\n</script>\n```\n\n### html:expression\n\nType: `command`\n\nSets the HTML content of the element.\n\nIt follows the same rules as `text`, without escaping.\n\nExample: Render markup\n```html\n<ui-bind path=\"common.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('ui-bind').html());\n// logs: <b>Anna</b>\n</script>\n```\n\n### value selector:expression\n\nType: `command`\n\nSets the value of a form control.\n\nUse a selector or the `child` attribute, because the `<ui-bind>` element is not a control itself.\n\nExample: Fill an input with a selector\n```html\n<ui-bind path=\"common.city\" config=\"value input\"><input /></ui-bind>\n\n<script>\nSET('common.city', 'Bratislava');\nconsole.log($('input').val());\n// logs: Bratislava\n</script>\n```\n\n### title:expression\n\nType: `command`\n\nSets the `title` attribute.\n\nExample: Text and title together\n```html\n<ui-bind path=\"common.name\" config=\"text+title:value\"></ui-bind>\n\n<script>\nON('ready', function() {\n    SET('common.name', 'Anna');\n    console.log($('ui-bind').text(), $('ui-bind').attr('title'));\n});\n// logs: Anna Anna\n</script>\n```\n\n### href:expression\n\nType: `command`\n\nSets the `href` attribute.\n\n### src:expression\n\nType: `command`\n\nSets the `src` attribute.\n\nExample: Set attributes with selectors\n```html\n<ui-bind path=\"common.user\" config=\"href a:'/users/' + value.id;title a:value.name;src img:value.photo\">\n    <a><img /></a>\n</ui-bind>\n\n<script>\nSET('common.user', { id: 7, name: 'Anna', photo: '/a.png' });\nconsole.log($('ui-bind').html().trim());\n// logs: <a href=\"/users/7\" title=\"Anna\"><img src=\"/a.png\"></a>\n</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nSets the attribute `name`.\n\nExample: Set a custom attribute\n```html\n<ui-bind path=\"common.id\" config=\"attr data-id:value\"></ui-bind>\n\n<script>\nSET('common.id', 5);\nconsole.log($('ui-bind').attr('data-id'));\n// logs: 5\n</script>\n```\n\n### show:expression\n\nType: `command`\n\nRemoves the CSS class `hidden` when the result is truthy and adds it otherwise.\n\nExample: Show and hide\n```html\n<ui-bind path=\"common.items\" config=\"show:value > 0\">Items</ui-bind>\n<ui-bind path=\"common.items\" config=\"hide:value > 0\">Empty</ui-bind>\n\n<script>\nSET('common.items', 3);\nconsole.log($('ui-bind').eq(0).hclass('hidden'), $('ui-bind').eq(1).hclass('hidden'));\n// logs: false true\n</script>\n```\n\n### hide:expression\n\nType: `command`\n\nAdds the CSS class `hidden` when the result is truthy and removes it otherwise.\n\n### visible:expression\n\nType: `command`\n\nRemoves the CSS class `invisible` when the result is truthy and adds it otherwise.\n\n### invisible:expression\n\nType: `command`\n\nAdds the CSS class `invisible` when the result is truthy and removes it otherwise.\n\nExample: Keep the space of the element\n```html\n<ui-bind path=\"common.ready\" config=\"invisible:!value\">Loaded</ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: invisible\nSET('common.ready', true);\nconsole.log($('ui-bind').hclass('invisible'));\n// logs: false\n</script>\n```\n\n### forcerender:expression\n\nType: `command`\n\nAllows `text`, `html` and `template` to render while the element is hidden, when the result is truthy.\n\nExample: Render into a hidden element\n```html\n<ui-bind id=\"a\" path=\"common.name\" config=\"show:false;text\"></ui-bind>\n<ui-bind id=\"b\" path=\"common.name\" config=\"show:false;forcerender:true;text\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('#a').text() === '', $('#b').text());\n// logs: true Anna\n</script>\n```\n\n### template:[{selector}] [selector --> attribute]\n\nType: `command`\n\nRenders a Tangular template with the value.\n\nThe template comes from a `<script>` or `<template>` element inside the target, from the HTML of the target, or from the element in `{selector}`. The model contains `value`, `path` and `element`. The text `SCR` in a template is replaced with `script`.\n\nWith `selector --> attribute`, only the elements matching the selector are updated. Existing elements with the same attribute value stay in the page. Without an attribute, whole elements are compared. See [Templates with Tangular](../../guides/tangular/).\n\nExample: Render a list\n```html\n<ui-bind path=\"common.users\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<b>{{ m }}</b>{{ end }}\n    </script>\n</ui-bind>\n\n<script>\nSET('common.users', ['Anna', 'Peter']);\nconsole.log($('ui-bind').html().trim());\n// logs: <b>Anna</b><b>Peter</b>\n</script>\n```\n\nExample: Use an external template and update only changed rows\n```html\n<script type=\"text/html\" id=\"row\"><div data-id=\"{{ value }}\">{{ value }}</div></script>\n<ui-bind path=\"common.id\" config=\"template:{#row} div --> data-id\"></ui-bind>\n\n<script>\nSET('common.id', 1);\nvar first = $('ui-bind div')[0];\nSET('common.id', 1);\nconsole.log(first === $('ui-bind div')[0]);\n// logs: true\n</script>\n```\n\n### helpers:path\n\nType: `command`\n\nSets the object with the Tangular helpers for the `template` command.\n\nExample: Custom helpers\n```html\n<ui-bind path=\"common.name\" config=\"template;helpers:FUNC.helpers\">\n    <template>{{ value | shout }}</template>\n</ui-bind>\n\n<script>\nFUNC.helpers = {\n    shout: value => (value || '').toUpperCase() + '!'\n};\n\nSET('common.name', 'anna');\nconsole.log($('ui-bind').html().trim());\n// logs: ANNA!\n</script>\n```\n\n### format:value\n\nType: `command`\n\nFormats a `Date` value for the `text`, `html`, `value`, `title`, `href`, `src` and `attr` commands.\n\nExample: Format a date\n```html\n<ui-bind path=\"common.date\" config=\"text;format:dd.MM.yyyy\"></ui-bind>\n\n<script>\nSET('common.date', new Date(2024, 0, 15));\nconsole.log($('ui-bind').text());\n// logs: 15.01.2024\n</script>\n```\n\n### empty:text\n\nType: `command`\n\nSets the text written by `text`, `html`, `value`, `title`, `href` and `src` when the result is `null`, `undefined`, `false` or an empty string.\n\nWithout a value, the text in `DEF.empty` is used (`---`).\n\nExample: Show a placeholder\n```html\n<ui-bind path=\"common.note\" config=\"text;empty:No note\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').text());\n// logs: No note\n</script>\n```\n\n### class:name\n\nType: `command`\n\nToggles a CSS class on the `<ui-bind>` element once, after the commands run for the first time.\n\nExample: Mark the element as rendered\n```html\n<ui-bind path=\"common.name\" config=\"text;class:rendered\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: rendered\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nCalls a function with the value, the path and the target element.\n\nA `?` in the value is replaced with the path of the parent plugin. The form `?/method` calls a method of the plugin.\n\nExample: Call a function on each change\n```html\n<ui-bind path=\"common.total\" config=\"exec:FUNC.total\"></ui-bind>\n\n<script>\nFUNC.total = function(value, path, element) {\n    value && console.log(value, path.toString(), element[0].tagName);\n};\n\nSET('common.total', 10);\n// logs: 10 common.total UI-BIND\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nCalls a function with the value, the path and the target element, in the same way as `exec`.\n\n### focus:selector\n\nType: `command`\n\nMoves the focus to the first visible element found by the selector, 500 milliseconds after the change.\n\nThe focus is not moved on mobile devices.\n\nExample: Focus an input\n```html\n<ui-bind path=\"common.open\" config=\"focus:input\"><input id=\"name\" /></ui-bind>\n\n<script>\nsetTimeout(() => console.log(document.activeElement.id), 700);\n// logs: name\n</script>\n```\n\n### checked:expression\n\nType: `command`\n\nSets the `checked` state of the checkboxes and radio buttons inside the target.\n\nExample: Check a checkbox\n```html\n<ui-bind path=\"common.agree\" config=\"checked\"><input type=\"checkbox\" /></ui-bind>\n\n<script>\nSET('common.agree', true);\nconsole.log($('input')[0].checked);\n// logs: true\n</script>\n```\n\n### disabled:expression\n\nType: `command`\n\nDisables the form controls and the components inside the target when the result is truthy.\n\nForm controls are `input`, `select`, `textarea` and `button`. Components receive the `disabled` config key.\n\nExample: Disable a form\n```html\n<ui-bind path=\"common.locked\" config=\"disabled\">\n    <input />\n    <ui-component name=\"field\"></ui-component>\n</ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.locked', true);\nconsole.log($('input').prop('disabled'), $('ui-component').hclass('ui-disabled'));\n// logs: true true\n</script>\n```\n\n### enabled:expression\n\nType: `command`\n\nEnables the form controls and the components inside the target when the result is truthy, and disables them otherwise.\n\nExample: Enable a button\n```html\n<ui-bind path=\"common.valid\" config=\"enabled\"><button>Save</button></ui-bind>\n\n<script>\nconsole.log($('button').prop('disabled'));\n// logs: true\nSET('common.valid', true);\nconsole.log($('button').prop('disabled'));\n// logs: false\n</script>\n```\n\n### required:expression\n\nType: `command`\n\nSets the `required` config key of the components inside the target.\n\nExample: Require a field\n```html\n<ui-bind path=\"common.company\" config=\"required\"><ui-component name=\"field\"></ui-component></ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.company', true);\nconsole.log($('ui-component').component().config.required);\n// logs: true\n</script>\n```\n\n### assign:path\n\nType: `command`\n\nWrites the instance of the binder to a path.\n\nThe instance has the method `exec(value, path, [flags])`, which runs the commands with a given value.\n\nExample: Run the commands from code\n```html\n<ui-bind path=\"common.name\" config=\"text;assign:common.binder\"></ui-bind>\n\n<script>\ncommon.binder.exec('Manual', 'common.name');\nconsole.log($('ui-bind').text());\n// logs: Manual\n</script>\n```\n\n### once\n\nType: `command`\n\nRuns the commands only one time.\n\nWith the `!` prefix in the path, the commands run for the first value that is not empty. Without it, they run with the value that exists when the element is created.\n\nExample: Render the first value\n```html\n<ui-bind path=\"!common.name\" config=\"once;text\"></ui-bind>\n\n<script>\nSET('common.name', 'first');\nSET('common.name', 'second');\nconsole.log($('ui-bind').text());\n// logs: first\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnores changes made in nested paths.\n\nExample: React only to the path itself\n```html\n<ui-bind path=\"common.user\" config=\"strict;text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Anna' });\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Anna\n</script>\n```\n\n### track:name[,name]\n\nType: `command`\n\nLimits changes in nested paths to the listed property names.\n\nA change of the observed path itself, or of a parent path, always runs the commands.\n\nExample: Track one property\n```html\n<ui-bind path=\"common.user\" config=\"track:name;text:value.name + ' ' + value.age\"></ui-bind>\n\n<script>\nSET('common.user.age', 30);\nconsole.log($('ui-bind').text());\n// logs: Anna 20\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Peter 30\n</script>\n```\n\n### changes\n\nType: `command`\n\nRuns the commands only when the value differs from the previous one.\n\nExample: Ignore identical values\n```html\n<ui-bind path=\"common.total\" config=\"changes;exec:FUNC.log\"></ui-bind>\n\n<script>\nFUNC.log = value => value && console.log(value);\n\nSET('common.total', 1);\nSET('common.total', 1);\nSET('common.total', 2);\n// logs: 1\n// logs: 2\n</script>\n```\n\n### check:path\n\nType: `command`\n\nRuns the commands only when the function at the path returns a truthy value.\n\nThe function receives the value, the path and the `<ui-bind>` element.\n\nExample: Filter the values\n```html\n<ui-bind path=\"common.age\" config=\"check:FUNC.adult;text\"></ui-bind>\n\n<script>\nFUNC.adult = value => value >= 18;\n\nSET('common.age', 15);\nconsole.log($('ui-bind').text() === '');\n// logs: true\nSET('common.age', 20);\nconsole.log($('ui-bind').text());\n// logs: 20\n</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nWaits for the given time and runs the commands with the last value.\n\nWithout a value, the delay is 100 milliseconds.\n\nExample: Group quick changes\n```html\n<ui-bind path=\"common.search\" config=\"delay:50;text\"></ui-bind>\n\n<script>\nSET('common.search', 'a');\nSET('common.search', 'ab');\nconsole.log($('ui-bind').text() === '');\n// logs: true\nsetTimeout(() => console.log($('ui-bind').text()), 200);\n// logs: ab\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"commands\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"command","name":".name","signature":".name:expression","since":"","deprecated":false},{"type":"command","name":"text","signature":"text:expression","since":"","deprecated":false},{"type":"command","name":"html","signature":"html:expression","since":"","deprecated":false},{"type":"command","name":"value","signature":"value selector:expression","since":"","deprecated":false},{"type":"command","name":"title","signature":"title:expression","since":"","deprecated":false},{"type":"command","name":"href","signature":"href:expression","since":"","deprecated":false},{"type":"command","name":"src","signature":"src:expression","since":"","deprecated":false},{"type":"command","name":"attr","signature":"attr name [selector]:expression","since":"","deprecated":false},{"type":"command","name":"show","signature":"show:expression","since":"","deprecated":false},{"type":"command","name":"hide","signature":"hide:expression","since":"","deprecated":false},{"type":"command","name":"visible","signature":"visible:expression","since":"","deprecated":false},{"type":"command","name":"invisible","signature":"invisible:expression","since":"","deprecated":false},{"type":"command","name":"forcerender","signature":"forcerender:expression","since":"","deprecated":false},{"type":"command","name":"template","signature":"template:[{selector}] [selector --> attribute]","since":"","deprecated":false},{"type":"command","name":"helpers","signature":"helpers:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty:text","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"checked","signature":"checked:expression","since":"","deprecated":false},{"type":"command","name":"disabled","signature":"disabled:expression","since":"","deprecated":false},{"type":"command","name":"enabled","signature":"enabled:expression","since":"","deprecated":false},{"type":"command","name":"required","signature":"required:expression","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:name[,name]","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JamcZCAUo61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/ui-bind/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"ui-bind","summary":"Die Attribute und Befehle des Elements ui-bind.","markdown":"---\ntitle: ui-bind\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/ui-bind/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# ui-bind\n\n> Die Attribute und Befehle des Elements ui-bind.\n\nDas Element `<ui-bind>` aktualisiert die Seite jedes Mal, wenn sich der Wert an einem Path ändert. Das Attribut `config` enthält eine Liste von Befehlen, die durch `;` getrennt sind. Wie du es verwendest, erklärt die Anleitung [Datenbindung](../../guides/data-binding/).\n\nEin Befehl hat die Form `name:expression` oder `name selector:expression`, um auf die Elemente zu wirken, die ein Selektor innerhalb des Ziels findet. Ohne Ausdruck verwendet der Befehl den Wert am Path. Der Ausdruck ist JavaScript und kann `value`, `path`, `flags`, `element` und `el` (dasselbe wie `element`) verwenden. Verbinde Befehlsnamen mit `+`, damit sie denselben Ausdruck erhalten, zum Beispiel `text+title:value`. Schreibe `\\\\;` für ein Semikolon innerhalb eines Ausdrucks. Alle Befehle werden einmal ausgeführt, wenn das Element erstellt wird, und zwar mit dem aktuellen Wert am Path. Ein Fehler in einem Ausdruck wird in die Konsole geschrieben, und die Befehle laufen weiter.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nDer zu beobachtende Path.\n\nEin `?` wird durch den Path des übergeordneten Plugins ersetzt. Mit einem `!` am Anfang (`!common.user`) werden die Befehle nicht ausgeführt, solange der Wert `null` oder `undefined` ist.\n\nExample: Leere Werte überspringen\n```html\n<ui-bind path=\"!common.user\" config=\"text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Peter' });\nconsole.log($('ui-bind').text());\n// logs: Peter\n</script>\n```\n\n### config=\"commands\"\n\nType: `property`\n\nDie Befehle, durch `;` getrennt.\n\nDie Werte bleiben Strings, weil sie als JavaScript kompiliert werden.\n\n### element=\"selector\"\n\nType: `property`\n\nFührt die Befehle auf den Elementen aus, die ein Selektor im gesamten Dokument findet.\n\nExample: Element an anderer Stelle der Seite aktualisieren\n```html\n<h1 id=\"title\"></h1>\n<ui-bind path=\"common.title\" element=\"#title\" config=\"text\"></ui-bind>\n\n<script>\nSET('common.title', 'Orders');\nconsole.log($('#title').text());\n// logs: Orders\n</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nFührt die Befehle auf den Elementen aus, die ein Selektor innerhalb des Elements findet.\n\nDer Befehl `value` braucht dieses Attribut oder einen Selektor, um ein Eingabefeld zu erreichen.\n\nExample: Eingabefeld füllen\n```html\n<ui-bind path=\"common.email\" child=\"input\" config=\"value\"><input /></ui-bind>\n\n<script>\nSET('common.email', 'info@example.com');\nconsole.log($('input').val());\n// logs: info@example.com\n</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nFührt die Befehle auf dem nächsten übergeordneten Element aus, das ein Selektor findet.\n\nExample: Übergeordnetes Element ändern\n```html\n<div class=\"row\">\n    <ui-bind path=\"common.active\" parent=\".row\" config=\".selected\"></ui-bind>\n</div>\n\n<script>\nSET('common.active', true);\nconsole.log($('.row').attr('class'));\n// logs: row selected\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nErstellt ein Plugin auf dem Element selbst, und ein `?` im Path verweist darauf.\n\nExample: Ein Binder mit eigenem Plugin\n```html\n<ui-bind plugin=\"clock\" path=\"?.time\" config=\"text\"></ui-bind>\n\n<script>\nPLUGIN('clock', function(exports) {\n    exports.make = () => exports.set('time', '12:00');\n});\n\nconsole.log($('ui-bind').text());\n// logs: 12:00\n</script>\n```\n\n### .name:expression\n\nType: `command`\n\nSchaltet die CSS-Klasse `name` je nach Ergebnis des Ausdrucks um.\n\nExample: Klassen umschalten\n```html\n<ui-bind path=\"common.count\" config=\".empty:!value;.many:value > 10\"></ui-bind>\n\n<script>\nSET('common.count', 20);\nconsole.log($('ui-bind').attr('class'));\n// logs: many\n</script>\n```\n\n### text:expression\n\nType: `command`\n\nSetzt den Text des Elements. HTML wird maskiert.\n\nEin Ergebnis `null`, `undefined`, `false` oder ein leerer String schreibt den Wert des Befehls `empty`, und `0` wird als `0` geschrieben. Solange das Element durch `show`, `hide`, `visible` oder `invisible` verborgen ist, wird nichts geschrieben, es sei denn, `forcerender` erlaubt es.\n\nExample: Text anzeigen\n```html\n<ui-bind path=\"common.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n\n<script>\nSET('common.name', 'anna');\nconsole.log($('ui-bind').text());\n// logs: ANNA\n</script>\n```\n\n### html:expression\n\nType: `command`\n\nSetzt den HTML-Inhalt des Elements.\n\nEs gelten dieselben Regeln wie bei `text`, aber ohne Maskierung.\n\nExample: Markup rendern\n```html\n<ui-bind path=\"common.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('ui-bind').html());\n// logs: <b>Anna</b>\n</script>\n```\n\n### value selector:expression\n\nType: `command`\n\nSetzt den Wert eines Formularelements.\n\nVerwende einen Selektor oder das Attribut `child`, weil das Element `<ui-bind>` selbst kein Formularelement ist.\n\nExample: Eingabefeld mit einem Selektor füllen\n```html\n<ui-bind path=\"common.city\" config=\"value input\"><input /></ui-bind>\n\n<script>\nSET('common.city', 'Bratislava');\nconsole.log($('input').val());\n// logs: Bratislava\n</script>\n```\n\n### title:expression\n\nType: `command`\n\nSetzt das Attribut `title`.\n\nExample: Text und Titel zusammen\n```html\n<ui-bind path=\"common.name\" config=\"text+title:value\"></ui-bind>\n\n<script>\nON('ready', function() {\n    SET('common.name', 'Anna');\n    console.log($('ui-bind').text(), $('ui-bind').attr('title'));\n});\n// logs: Anna Anna\n</script>\n```\n\n### href:expression\n\nType: `command`\n\nSetzt das Attribut `href`.\n\n### src:expression\n\nType: `command`\n\nSetzt das Attribut `src`.\n\nExample: Attribute mit Selektoren setzen\n```html\n<ui-bind path=\"common.user\" config=\"href a:'/users/' + value.id;title a:value.name;src img:value.photo\">\n    <a><img /></a>\n</ui-bind>\n\n<script>\nSET('common.user', { id: 7, name: 'Anna', photo: '/a.png' });\nconsole.log($('ui-bind').html().trim());\n// logs: <a href=\"/users/7\" title=\"Anna\"><img src=\"/a.png\"></a>\n</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nSetzt das Attribut `name`.\n\nExample: Benutzerdefiniertes Attribut setzen\n```html\n<ui-bind path=\"common.id\" config=\"attr data-id:value\"></ui-bind>\n\n<script>\nSET('common.id', 5);\nconsole.log($('ui-bind').attr('data-id'));\n// logs: 5\n</script>\n```\n\n### show:expression\n\nType: `command`\n\nEntfernt die CSS-Klasse `hidden`, wenn das Ergebnis truthy ist, und fügt sie andernfalls hinzu.\n\nExample: Ein- und ausblenden\n```html\n<ui-bind path=\"common.items\" config=\"show:value > 0\">Items</ui-bind>\n<ui-bind path=\"common.items\" config=\"hide:value > 0\">Empty</ui-bind>\n\n<script>\nSET('common.items', 3);\nconsole.log($('ui-bind').eq(0).hclass('hidden'), $('ui-bind').eq(1).hclass('hidden'));\n// logs: false true\n</script>\n```\n\n### hide:expression\n\nType: `command`\n\nFügt die CSS-Klasse `hidden` hinzu, wenn das Ergebnis truthy ist, und entfernt sie andernfalls.\n\n### visible:expression\n\nType: `command`\n\nEntfernt die CSS-Klasse `invisible`, wenn das Ergebnis truthy ist, und fügt sie andernfalls hinzu.\n\n### invisible:expression\n\nType: `command`\n\nFügt die CSS-Klasse `invisible` hinzu, wenn das Ergebnis truthy ist, und entfernt sie andernfalls.\n\nExample: Platz des Elements beibehalten\n```html\n<ui-bind path=\"common.ready\" config=\"invisible:!value\">Loaded</ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: invisible\nSET('common.ready', true);\nconsole.log($('ui-bind').hclass('invisible'));\n// logs: false\n</script>\n```\n\n### forcerender:expression\n\nType: `command`\n\nErlaubt `text`, `html` und `template`, bei einem truthy Ergebnis zu rendern, während das Element verborgen ist.\n\nExample: In ein verborgenes Element rendern\n```html\n<ui-bind id=\"a\" path=\"common.name\" config=\"show:false;text\"></ui-bind>\n<ui-bind id=\"b\" path=\"common.name\" config=\"show:false;forcerender:true;text\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('#a').text() === '', $('#b').text());\n// logs: true Anna\n</script>\n```\n\n### template:[{selector}] [selector --> attribute]\n\nType: `command`\n\nRendert ein Tangular-Template mit dem Wert.\n\nDas Template stammt aus einem `<script>`- oder `<template>`-Element innerhalb des Ziels, aus dem HTML des Ziels oder aus dem Element in `{selector}`. Das Modell enthält `value`, `path` und `element`. Der Text `SCR` in einem Template wird durch `script` ersetzt.\n\nMit `selector --> attribute` werden nur die Elemente aktualisiert, die zum Selektor passen. Vorhandene Elemente mit demselben Attributwert bleiben auf der Seite. Ohne Attribut werden ganze Elemente verglichen. Siehe [Templates mit Tangular](../../guides/tangular/).\n\nExample: Liste rendern\n```html\n<ui-bind path=\"common.users\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<b>{{ m }}</b>{{ end }}\n    </script>\n</ui-bind>\n\n<script>\nSET('common.users', ['Anna', 'Peter']);\nconsole.log($('ui-bind').html().trim());\n// logs: <b>Anna</b><b>Peter</b>\n</script>\n```\n\nExample: Externes Template verwenden und nur geänderte Zeilen aktualisieren\n```html\n<script type=\"text/html\" id=\"row\"><div data-id=\"{{ value }}\">{{ value }}</div></script>\n<ui-bind path=\"common.id\" config=\"template:{#row} div --> data-id\"></ui-bind>\n\n<script>\nSET('common.id', 1);\nvar first = $('ui-bind div')[0];\nSET('common.id', 1);\nconsole.log(first === $('ui-bind div')[0]);\n// logs: true\n</script>\n```\n\n### helpers:path\n\nType: `command`\n\nSetzt das Objekt mit den Tangular-Helpern für den Befehl `template`.\n\nExample: Eigene Helper\n```html\n<ui-bind path=\"common.name\" config=\"template;helpers:FUNC.helpers\">\n    <template>{{ value | shout }}</template>\n</ui-bind>\n\n<script>\nFUNC.helpers = {\n    shout: value => (value || '').toUpperCase() + '!'\n};\n\nSET('common.name', 'anna');\nconsole.log($('ui-bind').html().trim());\n// logs: ANNA!\n</script>\n```\n\n### format:value\n\nType: `command`\n\nFormatiert einen `Date`-Wert für die Befehle `text`, `html`, `value`, `title`, `href`, `src` und `attr`.\n\nExample: Datum formatieren\n```html\n<ui-bind path=\"common.date\" config=\"text;format:dd.MM.yyyy\"></ui-bind>\n\n<script>\nSET('common.date', new Date(2024, 0, 15));\nconsole.log($('ui-bind').text());\n// logs: 15.01.2024\n</script>\n```\n\n### empty:text\n\nType: `command`\n\nSetzt den Text, den `text`, `html`, `value`, `title`, `href` und `src` schreiben, wenn das Ergebnis `null`, `undefined`, `false` oder ein leerer String ist.\n\nOhne Wert wird der Text aus `DEF.empty` verwendet (`---`).\n\nExample: Platzhalter anzeigen\n```html\n<ui-bind path=\"common.note\" config=\"text;empty:No note\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').text());\n// logs: No note\n</script>\n```\n\n### class:name\n\nType: `command`\n\nSchaltet einmalig eine CSS-Klasse am Element `<ui-bind>` um, nachdem die Befehle zum ersten Mal ausgeführt wurden.\n\nExample: Element als gerendert markieren\n```html\n<ui-bind path=\"common.name\" config=\"text;class:rendered\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: rendered\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nRuft eine Funktion mit dem Wert, dem Path und dem Zielelement auf.\n\nEin `?` im Wert wird durch den Path des übergeordneten Plugins ersetzt. Die Form `?/method` ruft eine Methode des Plugins auf.\n\nExample: Bei jeder Änderung eine Funktion aufrufen\n```html\n<ui-bind path=\"common.total\" config=\"exec:FUNC.total\"></ui-bind>\n\n<script>\nFUNC.total = function(value, path, element) {\n    value && console.log(value, path.toString(), element[0].tagName);\n};\n\nSET('common.total', 10);\n// logs: 10 common.total UI-BIND\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nRuft wie `exec` eine Funktion mit dem Wert, dem Path und dem Zielelement auf.\n\n### focus:selector\n\nType: `command`\n\nVerschiebt den Fokus 500 Millisekunden nach der Änderung auf das erste sichtbare Element, das der Selektor findet.\n\nAuf Mobilgeräten wird der Fokus nicht verschoben.\n\nExample: Eingabefeld fokussieren\n```html\n<ui-bind path=\"common.open\" config=\"focus:input\"><input id=\"name\" /></ui-bind>\n\n<script>\nsetTimeout(() => console.log(document.activeElement.id), 700);\n// logs: name\n</script>\n```\n\n### checked:expression\n\nType: `command`\n\nSetzt den Zustand `checked` der Checkboxen und Radiobuttons innerhalb des Ziels.\n\nExample: Checkbox aktivieren\n```html\n<ui-bind path=\"common.agree\" config=\"checked\"><input type=\"checkbox\" /></ui-bind>\n\n<script>\nSET('common.agree', true);\nconsole.log($('input')[0].checked);\n// logs: true\n</script>\n```\n\n### disabled:expression\n\nType: `command`\n\nDeaktiviert die Formularelemente und Komponenten innerhalb des Ziels, wenn das Ergebnis truthy ist.\n\nFormularelemente sind `input`, `select`, `textarea` und `button`. Komponenten erhalten den Config-Key `disabled`.\n\nExample: Formular deaktivieren\n```html\n<ui-bind path=\"common.locked\" config=\"disabled\">\n    <input />\n    <ui-component name=\"field\"></ui-component>\n</ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.locked', true);\nconsole.log($('input').prop('disabled'), $('ui-component').hclass('ui-disabled'));\n// logs: true true\n</script>\n```\n\n### enabled:expression\n\nType: `command`\n\nAktiviert die Formularelemente und Komponenten innerhalb des Ziels, wenn das Ergebnis truthy ist, und deaktiviert sie andernfalls.\n\nExample: Button aktivieren\n```html\n<ui-bind path=\"common.valid\" config=\"enabled\"><button>Save</button></ui-bind>\n\n<script>\nconsole.log($('button').prop('disabled'));\n// logs: true\nSET('common.valid', true);\nconsole.log($('button').prop('disabled'));\n// logs: false\n</script>\n```\n\n### required:expression\n\nType: `command`\n\nSetzt den Config-Key `required` der Komponenten innerhalb des Ziels.\n\nExample: Feld als Pflichtfeld festlegen\n```html\n<ui-bind path=\"common.company\" config=\"required\"><ui-component name=\"field\"></ui-component></ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.company', true);\nconsole.log($('ui-component').component().config.required);\n// logs: true\n</script>\n```\n\n### assign:path\n\nType: `command`\n\nSchreibt die Instanz des Binders an einen Path.\n\nDie Instanz hat die Methode `exec(value, path, [flags])`, die die Befehle mit einem bestimmten Wert ausführt.\n\nExample: Befehle per Code ausführen\n```html\n<ui-bind path=\"common.name\" config=\"text;assign:common.binder\"></ui-bind>\n\n<script>\ncommon.binder.exec('Manual', 'common.name');\nconsole.log($('ui-bind').text());\n// logs: Manual\n</script>\n```\n\n### once\n\nType: `command`\n\nFührt die Befehle nur ein einziges Mal aus.\n\nMit dem Präfix `!` im Path werden die Befehle für den ersten nicht leeren Wert ausgeführt. Ohne das Präfix laufen sie mit dem Wert, der beim Erstellen des Elements vorhanden ist.\n\nExample: Ersten Wert rendern\n```html\n<ui-bind path=\"!common.name\" config=\"once;text\"></ui-bind>\n\n<script>\nSET('common.name', 'first');\nSET('common.name', 'second');\nconsole.log($('ui-bind').text());\n// logs: first\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnoriert Änderungen in verschachtelten Paths.\n\nExample: Nur auf den Path selbst reagieren\n```html\n<ui-bind path=\"common.user\" config=\"strict;text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Anna' });\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Anna\n</script>\n```\n\n### track:name[,name]\n\nType: `command`\n\nBeschränkt Änderungen in verschachtelten Paths auf die aufgeführten Eigenschaftsnamen.\n\nEine Änderung am beobachteten Path selbst oder an einem übergeordneten Path führt die Befehle immer aus.\n\nExample: Eine Eigenschaft verfolgen\n```html\n<ui-bind path=\"common.user\" config=\"track:name;text:value.name + ' ' + value.age\"></ui-bind>\n\n<script>\nSET('common.user.age', 30);\nconsole.log($('ui-bind').text());\n// logs: Anna 20\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Peter 30\n</script>\n```\n\n### changes\n\nType: `command`\n\nFührt die Befehle nur aus, wenn sich der Wert vom vorherigen unterscheidet.\n\nExample: Identische Werte ignorieren\n```html\n<ui-bind path=\"common.total\" config=\"changes;exec:FUNC.log\"></ui-bind>\n\n<script>\nFUNC.log = value => value && console.log(value);\n\nSET('common.total', 1);\nSET('common.total', 1);\nSET('common.total', 2);\n// logs: 1\n// logs: 2\n</script>\n```\n\n### check:path\n\nType: `command`\n\nFührt die Befehle nur aus, wenn die Funktion am Path einen truthy Wert zurückgibt.\n\nDie Funktion erhält den Wert, den Path und das Element `<ui-bind>`.\n\nExample: Werte filtern\n```html\n<ui-bind path=\"common.age\" config=\"check:FUNC.adult;text\"></ui-bind>\n\n<script>\nFUNC.adult = value => value >= 18;\n\nSET('common.age', 15);\nconsole.log($('ui-bind').text() === '');\n// logs: true\nSET('common.age', 20);\nconsole.log($('ui-bind').text());\n// logs: 20\n</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nWartet die angegebene Zeit und führt die Befehle mit dem letzten Wert aus.\n\nOhne Wert beträgt die Verzögerung 100 Millisekunden.\n\nExample: Schnelle Änderungen zusammenfassen\n```html\n<ui-bind path=\"common.search\" config=\"delay:50;text\"></ui-bind>\n\n<script>\nSET('common.search', 'a');\nSET('common.search', 'ab');\nconsole.log($('ui-bind').text() === '');\n// logs: true\nsetTimeout(() => console.log($('ui-bind').text()), 200);\n// logs: ab\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"commands\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"command","name":".name","signature":".name:expression","since":"","deprecated":false},{"type":"command","name":"text","signature":"text:expression","since":"","deprecated":false},{"type":"command","name":"html","signature":"html:expression","since":"","deprecated":false},{"type":"command","name":"value","signature":"value selector:expression","since":"","deprecated":false},{"type":"command","name":"title","signature":"title:expression","since":"","deprecated":false},{"type":"command","name":"href","signature":"href:expression","since":"","deprecated":false},{"type":"command","name":"src","signature":"src:expression","since":"","deprecated":false},{"type":"command","name":"attr","signature":"attr name [selector]:expression","since":"","deprecated":false},{"type":"command","name":"show","signature":"show:expression","since":"","deprecated":false},{"type":"command","name":"hide","signature":"hide:expression","since":"","deprecated":false},{"type":"command","name":"visible","signature":"visible:expression","since":"","deprecated":false},{"type":"command","name":"invisible","signature":"invisible:expression","since":"","deprecated":false},{"type":"command","name":"forcerender","signature":"forcerender:expression","since":"","deprecated":false},{"type":"command","name":"template","signature":"template:[{selector}] [selector --> attribute]","since":"","deprecated":false},{"type":"command","name":"helpers","signature":"helpers:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty:text","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"checked","signature":"checked:expression","since":"","deprecated":false},{"type":"command","name":"disabled","signature":"disabled:expression","since":"","deprecated":false},{"type":"command","name":"enabled","signature":"enabled:expression","since":"","deprecated":false},{"type":"command","name":"required","signature":"required:expression","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:name[,name]","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JamcZCAUo61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/ui-bind/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"ui-bind","summary":"Los atributos y los comandos del elemento ui-bind.","markdown":"---\ntitle: ui-bind\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/ui-bind/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# ui-bind\n\n> Los atributos y los comandos del elemento ui-bind.\n\nEl elemento `<ui-bind>` actualiza la página cada vez que cambia el valor de un path. El atributo `config` contiene una lista de comandos separados por `;`. La guía [Enlace de datos](../../guides/data-binding/) explica cómo usarlo.\n\nUn comando tiene la forma `name:expression`, o `name selector:expression` para actuar sobre los elementos que un selector encuentra dentro del destino. Sin expresión, el comando usa el valor del path. La expresión es JavaScript y puede usar `value`, `path`, `flags`, `element` y `el` (lo mismo que `element`). Une nombres de comandos con `+` para darles la misma expresión, por ejemplo `text+title:value`. Escribe `\\\\;` para poner un punto y coma dentro de una expresión. Todos los comandos se ejecutan una vez al crearse el elemento, con el valor actual del path. Un error en una expresión se escribe en la consola y los comandos continúan.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nEl path que se va a observar.\n\nUn `?` se sustituye por el path del plugin padre. Con un `!` al principio (`!common.user`), los comandos no se ejecutan mientras el valor sea `null` o `undefined`.\n\nExample: Omitir los valores vacíos\n```html\n<ui-bind path=\"!common.user\" config=\"text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Peter' });\nconsole.log($('ui-bind').text());\n// logs: Peter\n</script>\n```\n\n### config=\"commands\"\n\nType: `property`\n\nLos comandos, separados por `;`.\n\nLos valores se conservan como cadenas, porque se compilan como JavaScript.\n\n### element=\"selector\"\n\nType: `property`\n\nEjecuta los comandos sobre los elementos que un selector encuentra en todo el documento.\n\nExample: Actualizar un elemento en otra parte de la página\n```html\n<h1 id=\"title\"></h1>\n<ui-bind path=\"common.title\" element=\"#title\" config=\"text\"></ui-bind>\n\n<script>\nSET('common.title', 'Orders');\nconsole.log($('#title').text());\n// logs: Orders\n</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nEjecuta los comandos sobre los elementos que un selector encuentra dentro del elemento.\n\nEl comando `value` necesita este atributo o un selector para llegar a un input.\n\nExample: Rellenar un input\n```html\n<ui-bind path=\"common.email\" child=\"input\" config=\"value\"><input /></ui-bind>\n\n<script>\nSET('common.email', 'info@example.com');\nconsole.log($('input').val());\n// logs: info@example.com\n</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nEjecuta los comandos sobre el padre más cercano que encuentra un selector.\n\nExample: Cambiar un elemento padre\n```html\n<div class=\"row\">\n    <ui-bind path=\"common.active\" parent=\".row\" config=\".selected\"></ui-bind>\n</div>\n\n<script>\nSET('common.active', true);\nconsole.log($('.row').attr('class'));\n// logs: row selected\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea un plugin en el propio elemento, y un `?` en el path hace referencia a él.\n\nExample: Un binder con su propio plugin\n```html\n<ui-bind plugin=\"clock\" path=\"?.time\" config=\"text\"></ui-bind>\n\n<script>\nPLUGIN('clock', function(exports) {\n    exports.make = () => exports.set('time', '12:00');\n});\n\nconsole.log($('ui-bind').text());\n// logs: 12:00\n</script>\n```\n\n### .name:expression\n\nType: `command`\n\nAlterna la clase CSS `name` según el resultado de la expresión.\n\nExample: Alternar clases\n```html\n<ui-bind path=\"common.count\" config=\".empty:!value;.many:value > 10\"></ui-bind>\n\n<script>\nSET('common.count', 20);\nconsole.log($('ui-bind').attr('class'));\n// logs: many\n</script>\n```\n\n### text:expression\n\nType: `command`\n\nEstablece el texto del elemento. El HTML se escapa.\n\nUn resultado `null`, `undefined`, `false` o una cadena vacía escribe el valor del comando `empty`, y `0` se escribe como `0`. No se escribe nada mientras el elemento esté oculto por `show`, `hide`, `visible` o `invisible`, salvo que `forcerender` lo permita.\n\nExample: Mostrar un texto\n```html\n<ui-bind path=\"common.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n\n<script>\nSET('common.name', 'anna');\nconsole.log($('ui-bind').text());\n// logs: ANNA\n</script>\n```\n\n### html:expression\n\nType: `command`\n\nEstablece el contenido HTML del elemento.\n\nSigue las mismas reglas que `text`, sin escapar.\n\nExample: Renderizar marcado\n```html\n<ui-bind path=\"common.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('ui-bind').html());\n// logs: <b>Anna</b>\n</script>\n```\n\n### value selector:expression\n\nType: `command`\n\nEstablece el valor de un control de formulario.\n\nUsa un selector o el atributo `child`, porque el elemento `<ui-bind>` no es un control en sí.\n\nExample: Rellenar un input con un selector\n```html\n<ui-bind path=\"common.city\" config=\"value input\"><input /></ui-bind>\n\n<script>\nSET('common.city', 'Bratislava');\nconsole.log($('input').val());\n// logs: Bratislava\n</script>\n```\n\n### title:expression\n\nType: `command`\n\nEstablece el atributo `title`.\n\nExample: Texto y título a la vez\n```html\n<ui-bind path=\"common.name\" config=\"text+title:value\"></ui-bind>\n\n<script>\nON('ready', function() {\n    SET('common.name', 'Anna');\n    console.log($('ui-bind').text(), $('ui-bind').attr('title'));\n});\n// logs: Anna Anna\n</script>\n```\n\n### href:expression\n\nType: `command`\n\nEstablece el atributo `href`.\n\n### src:expression\n\nType: `command`\n\nEstablece el atributo `src`.\n\nExample: Establecer atributos con selectores\n```html\n<ui-bind path=\"common.user\" config=\"href a:'/users/' + value.id;title a:value.name;src img:value.photo\">\n    <a><img /></a>\n</ui-bind>\n\n<script>\nSET('common.user', { id: 7, name: 'Anna', photo: '/a.png' });\nconsole.log($('ui-bind').html().trim());\n// logs: <a href=\"/users/7\" title=\"Anna\"><img src=\"/a.png\"></a>\n</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nEstablece el atributo `name`.\n\nExample: Establecer un atributo personalizado\n```html\n<ui-bind path=\"common.id\" config=\"attr data-id:value\"></ui-bind>\n\n<script>\nSET('common.id', 5);\nconsole.log($('ui-bind').attr('data-id'));\n// logs: 5\n</script>\n```\n\n### show:expression\n\nType: `command`\n\nQuita la clase CSS `hidden` cuando el resultado es truthy y la añade en caso contrario.\n\nExample: Mostrar y ocultar\n```html\n<ui-bind path=\"common.items\" config=\"show:value > 0\">Items</ui-bind>\n<ui-bind path=\"common.items\" config=\"hide:value > 0\">Empty</ui-bind>\n\n<script>\nSET('common.items', 3);\nconsole.log($('ui-bind').eq(0).hclass('hidden'), $('ui-bind').eq(1).hclass('hidden'));\n// logs: false true\n</script>\n```\n\n### hide:expression\n\nType: `command`\n\nAñade la clase CSS `hidden` cuando el resultado es truthy y la quita en caso contrario.\n\n### visible:expression\n\nType: `command`\n\nQuita la clase CSS `invisible` cuando el resultado es truthy y la añade en caso contrario.\n\n### invisible:expression\n\nType: `command`\n\nAñade la clase CSS `invisible` cuando el resultado es truthy y la quita en caso contrario.\n\nExample: Conservar el espacio del elemento\n```html\n<ui-bind path=\"common.ready\" config=\"invisible:!value\">Loaded</ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: invisible\nSET('common.ready', true);\nconsole.log($('ui-bind').hclass('invisible'));\n// logs: false\n</script>\n```\n\n### forcerender:expression\n\nType: `command`\n\nPermite que `text`, `html` y `template` rendericen mientras el elemento está oculto, cuando el resultado es truthy.\n\nExample: Renderizar en un elemento oculto\n```html\n<ui-bind id=\"a\" path=\"common.name\" config=\"show:false;text\"></ui-bind>\n<ui-bind id=\"b\" path=\"common.name\" config=\"show:false;forcerender:true;text\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('#a').text() === '', $('#b').text());\n// logs: true Anna\n</script>\n```\n\n### template:[{selector}] [selector --> attribute]\n\nType: `command`\n\nRenderiza una plantilla de Tangular con el valor.\n\nLa plantilla procede de un elemento `<script>` o `<template>` dentro del destino, del HTML del destino o del elemento indicado en `{selector}`. El modelo contiene `value`, `path` y `element`. El texto `SCR` de una plantilla se sustituye por `script`.\n\nCon `selector --> attribute`, solo se actualizan los elementos que coinciden con el selector. Los elementos existentes con el mismo valor de atributo permanecen en la página. Sin atributo, se comparan los elementos completos. Consulta [Plantillas con Tangular](../../guides/tangular/).\n\nExample: Renderizar una lista\n```html\n<ui-bind path=\"common.users\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<b>{{ m }}</b>{{ end }}\n    </script>\n</ui-bind>\n\n<script>\nSET('common.users', ['Anna', 'Peter']);\nconsole.log($('ui-bind').html().trim());\n// logs: <b>Anna</b><b>Peter</b>\n</script>\n```\n\nExample: Usar una plantilla externa y actualizar solo las filas modificadas\n```html\n<script type=\"text/html\" id=\"row\"><div data-id=\"{{ value }}\">{{ value }}</div></script>\n<ui-bind path=\"common.id\" config=\"template:{#row} div --> data-id\"></ui-bind>\n\n<script>\nSET('common.id', 1);\nvar first = $('ui-bind div')[0];\nSET('common.id', 1);\nconsole.log(first === $('ui-bind div')[0]);\n// logs: true\n</script>\n```\n\n### helpers:path\n\nType: `command`\n\nEstablece el objeto con los helpers de Tangular para el comando `template`.\n\nExample: Helpers personalizados\n```html\n<ui-bind path=\"common.name\" config=\"template;helpers:FUNC.helpers\">\n    <template>{{ value | shout }}</template>\n</ui-bind>\n\n<script>\nFUNC.helpers = {\n    shout: value => (value || '').toUpperCase() + '!'\n};\n\nSET('common.name', 'anna');\nconsole.log($('ui-bind').html().trim());\n// logs: ANNA!\n</script>\n```\n\n### format:value\n\nType: `command`\n\nDa formato a un valor `Date` para los comandos `text`, `html`, `value`, `title`, `href`, `src` y `attr`.\n\nExample: Dar formato a una fecha\n```html\n<ui-bind path=\"common.date\" config=\"text;format:dd.MM.yyyy\"></ui-bind>\n\n<script>\nSET('common.date', new Date(2024, 0, 15));\nconsole.log($('ui-bind').text());\n// logs: 15.01.2024\n</script>\n```\n\n### empty:text\n\nType: `command`\n\nEstablece el texto que escriben `text`, `html`, `value`, `title`, `href` y `src` cuando el resultado es `null`, `undefined`, `false` o una cadena vacía.\n\nSin valor, se usa el texto de `DEF.empty` (`---`).\n\nExample: Mostrar un texto de sustitución\n```html\n<ui-bind path=\"common.note\" config=\"text;empty:No note\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').text());\n// logs: No note\n</script>\n```\n\n### class:name\n\nType: `command`\n\nAlterna una clase CSS en el elemento `<ui-bind>` una sola vez, después de que los comandos se ejecuten por primera vez.\n\nExample: Marcar el elemento como renderizado\n```html\n<ui-bind path=\"common.name\" config=\"text;class:rendered\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: rendered\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nLlama a una función con el valor, el path y el elemento de destino.\n\nUn `?` en el valor se sustituye por el path del plugin padre. La forma `?/method` llama a un método del plugin.\n\nExample: Llamar a una función en cada cambio\n```html\n<ui-bind path=\"common.total\" config=\"exec:FUNC.total\"></ui-bind>\n\n<script>\nFUNC.total = function(value, path, element) {\n    value && console.log(value, path.toString(), element[0].tagName);\n};\n\nSET('common.total', 10);\n// logs: 10 common.total UI-BIND\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nLlama a una función con el valor, el path y el elemento de destino, igual que `exec`.\n\n### focus:selector\n\nType: `command`\n\nMueve el foco al primer elemento visible que encuentra el selector, 500 milisegundos después del cambio.\n\nEn los dispositivos móviles el foco no se mueve.\n\nExample: Enfocar un input\n```html\n<ui-bind path=\"common.open\" config=\"focus:input\"><input id=\"name\" /></ui-bind>\n\n<script>\nsetTimeout(() => console.log(document.activeElement.id), 700);\n// logs: name\n</script>\n```\n\n### checked:expression\n\nType: `command`\n\nEstablece el estado `checked` de las casillas de verificación y los botones de opción que hay dentro del destino.\n\nExample: Marcar una casilla de verificación\n```html\n<ui-bind path=\"common.agree\" config=\"checked\"><input type=\"checkbox\" /></ui-bind>\n\n<script>\nSET('common.agree', true);\nconsole.log($('input')[0].checked);\n// logs: true\n</script>\n```\n\n### disabled:expression\n\nType: `command`\n\nDesactiva los controles de formulario y los componentes que hay dentro del destino cuando el resultado es truthy.\n\nLos controles de formulario son `input`, `select`, `textarea` y `button`. Los componentes reciben la clave de configuración `disabled`.\n\nExample: Desactivar un formulario\n```html\n<ui-bind path=\"common.locked\" config=\"disabled\">\n    <input />\n    <ui-component name=\"field\"></ui-component>\n</ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.locked', true);\nconsole.log($('input').prop('disabled'), $('ui-component').hclass('ui-disabled'));\n// logs: true true\n</script>\n```\n\n### enabled:expression\n\nType: `command`\n\nActiva los controles de formulario y los componentes que hay dentro del destino cuando el resultado es truthy, y los desactiva en caso contrario.\n\nExample: Activar un botón\n```html\n<ui-bind path=\"common.valid\" config=\"enabled\"><button>Save</button></ui-bind>\n\n<script>\nconsole.log($('button').prop('disabled'));\n// logs: true\nSET('common.valid', true);\nconsole.log($('button').prop('disabled'));\n// logs: false\n</script>\n```\n\n### required:expression\n\nType: `command`\n\nEstablece la clave de configuración `required` de los componentes que hay dentro del destino.\n\nExample: Hacer obligatorio un campo\n```html\n<ui-bind path=\"common.company\" config=\"required\"><ui-component name=\"field\"></ui-component></ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.company', true);\nconsole.log($('ui-component').component().config.required);\n// logs: true\n</script>\n```\n\n### assign:path\n\nType: `command`\n\nEscribe la instancia del binder en un path.\n\nLa instancia tiene el método `exec(value, path, [flags])`, que ejecuta los comandos con un valor dado.\n\nExample: Ejecutar los comandos desde el código\n```html\n<ui-bind path=\"common.name\" config=\"text;assign:common.binder\"></ui-bind>\n\n<script>\ncommon.binder.exec('Manual', 'common.name');\nconsole.log($('ui-bind').text());\n// logs: Manual\n</script>\n```\n\n### once\n\nType: `command`\n\nEjecuta los comandos una sola vez.\n\nCon el prefijo `!` en el path, los comandos se ejecutan con el primer valor que no esté vacío. Sin él, se ejecutan con el valor que existe cuando se crea el elemento.\n\nExample: Renderizar el primer valor\n```html\n<ui-bind path=\"!common.name\" config=\"once;text\"></ui-bind>\n\n<script>\nSET('common.name', 'first');\nSET('common.name', 'second');\nconsole.log($('ui-bind').text());\n// logs: first\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnora los cambios hechos en paths anidados.\n\nExample: Reaccionar solo al propio path\n```html\n<ui-bind path=\"common.user\" config=\"strict;text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Anna' });\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Anna\n</script>\n```\n\n### track:name[,name]\n\nType: `command`\n\nLimita los cambios en paths anidados a los nombres de propiedad indicados.\n\nUn cambio del propio path observado, o de un path padre, siempre ejecuta los comandos.\n\nExample: Seguir una propiedad\n```html\n<ui-bind path=\"common.user\" config=\"track:name;text:value.name + ' ' + value.age\"></ui-bind>\n\n<script>\nSET('common.user.age', 30);\nconsole.log($('ui-bind').text());\n// logs: Anna 20\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Peter 30\n</script>\n```\n\n### changes\n\nType: `command`\n\nEjecuta los comandos solo cuando el valor es distinto del anterior.\n\nExample: Ignorar los valores idénticos\n```html\n<ui-bind path=\"common.total\" config=\"changes;exec:FUNC.log\"></ui-bind>\n\n<script>\nFUNC.log = value => value && console.log(value);\n\nSET('common.total', 1);\nSET('common.total', 1);\nSET('common.total', 2);\n// logs: 1\n// logs: 2\n</script>\n```\n\n### check:path\n\nType: `command`\n\nEjecuta los comandos solo cuando la función del path devuelve un valor truthy.\n\nLa función recibe el valor, el path y el elemento `<ui-bind>`.\n\nExample: Filtrar los valores\n```html\n<ui-bind path=\"common.age\" config=\"check:FUNC.adult;text\"></ui-bind>\n\n<script>\nFUNC.adult = value => value >= 18;\n\nSET('common.age', 15);\nconsole.log($('ui-bind').text() === '');\n// logs: true\nSET('common.age', 20);\nconsole.log($('ui-bind').text());\n// logs: 20\n</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nEspera el tiempo indicado y ejecuta los comandos con el último valor.\n\nSin valor, el retardo es de 100 milisegundos.\n\nExample: Agrupar los cambios rápidos\n```html\n<ui-bind path=\"common.search\" config=\"delay:50;text\"></ui-bind>\n\n<script>\nSET('common.search', 'a');\nSET('common.search', 'ab');\nconsole.log($('ui-bind').text() === '');\n// logs: true\nsetTimeout(() => console.log($('ui-bind').text()), 200);\n// logs: ab\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"commands\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"command","name":".name","signature":".name:expression","since":"","deprecated":false},{"type":"command","name":"text","signature":"text:expression","since":"","deprecated":false},{"type":"command","name":"html","signature":"html:expression","since":"","deprecated":false},{"type":"command","name":"value","signature":"value selector:expression","since":"","deprecated":false},{"type":"command","name":"title","signature":"title:expression","since":"","deprecated":false},{"type":"command","name":"href","signature":"href:expression","since":"","deprecated":false},{"type":"command","name":"src","signature":"src:expression","since":"","deprecated":false},{"type":"command","name":"attr","signature":"attr name [selector]:expression","since":"","deprecated":false},{"type":"command","name":"show","signature":"show:expression","since":"","deprecated":false},{"type":"command","name":"hide","signature":"hide:expression","since":"","deprecated":false},{"type":"command","name":"visible","signature":"visible:expression","since":"","deprecated":false},{"type":"command","name":"invisible","signature":"invisible:expression","since":"","deprecated":false},{"type":"command","name":"forcerender","signature":"forcerender:expression","since":"","deprecated":false},{"type":"command","name":"template","signature":"template:[{selector}] [selector --> attribute]","since":"","deprecated":false},{"type":"command","name":"helpers","signature":"helpers:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty:text","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"checked","signature":"checked:expression","since":"","deprecated":false},{"type":"command","name":"disabled","signature":"disabled:expression","since":"","deprecated":false},{"type":"command","name":"enabled","signature":"enabled:expression","since":"","deprecated":false},{"type":"command","name":"required","signature":"required:expression","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:name[,name]","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JamcZCAUo61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/ui-bind/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"ui-bind","summary":"Les attributs et les commandes de l'élément ui-bind.","markdown":"---\ntitle: ui-bind\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/ui-bind/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# ui-bind\n\n> Les attributs et les commandes de l'élément ui-bind.\n\nL'élément `<ui-bind>` met à jour la page chaque fois que la valeur d'un path change. L'attribut `config` contient une liste de commandes séparées par `;`. Le guide [Liaison de données](../../guides/data-binding/) explique comment l'utiliser.\n\nUne commande a la forme `name:expression`, ou `name selector:expression` pour agir sur les éléments trouvés par un sélecteur à l'intérieur de la cible. Sans expression, la commande utilise la valeur du path. L'expression est du JavaScript et peut utiliser `value`, `path`, `flags`, `element` et `el` (identique à `element`). Relie des noms de commandes avec `+` pour leur donner la même expression, par exemple `text+title:value`. Écris `\\\\;` pour un point-virgule dans une expression. Toutes les commandes s'exécutent une fois à la création de l'élément, avec la valeur actuelle du path. Une erreur dans une expression est écrite dans la console et les commandes continuent.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nLe path à observer.\n\nUn `?` est remplacé par le path du plugin parent. Avec un `!` au début (`!common.user`), les commandes ne s'exécutent pas tant que la valeur est `null` ou `undefined`.\n\nExample: Ignorer les valeurs vides\n```html\n<ui-bind path=\"!common.user\" config=\"text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Peter' });\nconsole.log($('ui-bind').text());\n// logs: Peter\n</script>\n```\n\n### config=\"commands\"\n\nType: `property`\n\nLes commandes, séparées par `;`.\n\nLes valeurs restent des chaînes, car elles sont compilées en JavaScript.\n\n### element=\"selector\"\n\nType: `property`\n\nExécute les commandes sur les éléments trouvés par un sélecteur dans tout le document.\n\nExample: Mettre à jour un élément ailleurs dans la page\n```html\n<h1 id=\"title\"></h1>\n<ui-bind path=\"common.title\" element=\"#title\" config=\"text\"></ui-bind>\n\n<script>\nSET('common.title', 'Orders');\nconsole.log($('#title').text());\n// logs: Orders\n</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nExécute les commandes sur les éléments trouvés par un sélecteur à l'intérieur de l'élément.\n\nLa commande `value` a besoin de cet attribut ou d'un sélecteur pour atteindre un champ de saisie.\n\nExample: Remplir un champ de saisie\n```html\n<ui-bind path=\"common.email\" child=\"input\" config=\"value\"><input /></ui-bind>\n\n<script>\nSET('common.email', 'info@example.com');\nconsole.log($('input').val());\n// logs: info@example.com\n</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nExécute les commandes sur le parent le plus proche trouvé par un sélecteur.\n\nExample: Modifier un élément parent\n```html\n<div class=\"row\">\n    <ui-bind path=\"common.active\" parent=\".row\" config=\".selected\"></ui-bind>\n</div>\n\n<script>\nSET('common.active', true);\nconsole.log($('.row').attr('class'));\n// logs: row selected\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrée un plugin sur l'élément lui-même, et un `?` dans le path y fait référence.\n\nExample: Un binder avec son propre plugin\n```html\n<ui-bind plugin=\"clock\" path=\"?.time\" config=\"text\"></ui-bind>\n\n<script>\nPLUGIN('clock', function(exports) {\n    exports.make = () => exports.set('time', '12:00');\n});\n\nconsole.log($('ui-bind').text());\n// logs: 12:00\n</script>\n```\n\n### .name:expression\n\nType: `command`\n\nBascule la classe CSS `name` selon le résultat de l'expression.\n\nExample: Basculer des classes\n```html\n<ui-bind path=\"common.count\" config=\".empty:!value;.many:value > 10\"></ui-bind>\n\n<script>\nSET('common.count', 20);\nconsole.log($('ui-bind').attr('class'));\n// logs: many\n</script>\n```\n\n### text:expression\n\nType: `command`\n\nDéfinit le texte de l'élément. Le HTML est échappé.\n\nUn résultat `null`, `undefined`, `false` ou chaîne vide écrit la valeur de la commande `empty`, et `0` s'écrit `0`. Rien n'est écrit tant que l'élément est masqué par `show`, `hide`, `visible` ou `invisible`, sauf si `forcerender` l'autorise.\n\nExample: Afficher un texte\n```html\n<ui-bind path=\"common.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n\n<script>\nSET('common.name', 'anna');\nconsole.log($('ui-bind').text());\n// logs: ANNA\n</script>\n```\n\n### html:expression\n\nType: `command`\n\nDéfinit le contenu HTML de l'élément.\n\nSuit les mêmes règles que `text`, sans échappement.\n\nExample: Afficher du balisage\n```html\n<ui-bind path=\"common.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('ui-bind').html());\n// logs: <b>Anna</b>\n</script>\n```\n\n### value selector:expression\n\nType: `command`\n\nDéfinit la valeur d'un contrôle de formulaire.\n\nUtilise un sélecteur ou l'attribut `child`, car l'élément `<ui-bind>` n'est pas lui-même un contrôle.\n\nExample: Remplir un champ de saisie avec un sélecteur\n```html\n<ui-bind path=\"common.city\" config=\"value input\"><input /></ui-bind>\n\n<script>\nSET('common.city', 'Bratislava');\nconsole.log($('input').val());\n// logs: Bratislava\n</script>\n```\n\n### title:expression\n\nType: `command`\n\nDéfinit l'attribut `title`.\n\nExample: Texte et titre ensemble\n```html\n<ui-bind path=\"common.name\" config=\"text+title:value\"></ui-bind>\n\n<script>\nON('ready', function() {\n    SET('common.name', 'Anna');\n    console.log($('ui-bind').text(), $('ui-bind').attr('title'));\n});\n// logs: Anna Anna\n</script>\n```\n\n### href:expression\n\nType: `command`\n\nDéfinit l'attribut `href`.\n\n### src:expression\n\nType: `command`\n\nDéfinit l'attribut `src`.\n\nExample: Définir des attributs avec des sélecteurs\n```html\n<ui-bind path=\"common.user\" config=\"href a:'/users/' + value.id;title a:value.name;src img:value.photo\">\n    <a><img /></a>\n</ui-bind>\n\n<script>\nSET('common.user', { id: 7, name: 'Anna', photo: '/a.png' });\nconsole.log($('ui-bind').html().trim());\n// logs: <a href=\"/users/7\" title=\"Anna\"><img src=\"/a.png\"></a>\n</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nDéfinit l'attribut `name`.\n\nExample: Définir un attribut personnalisé\n```html\n<ui-bind path=\"common.id\" config=\"attr data-id:value\"></ui-bind>\n\n<script>\nSET('common.id', 5);\nconsole.log($('ui-bind').attr('data-id'));\n// logs: 5\n</script>\n```\n\n### show:expression\n\nType: `command`\n\nRetire la classe CSS `hidden` quand le résultat est truthy et l'ajoute dans le cas contraire.\n\nExample: Afficher et masquer\n```html\n<ui-bind path=\"common.items\" config=\"show:value > 0\">Items</ui-bind>\n<ui-bind path=\"common.items\" config=\"hide:value > 0\">Empty</ui-bind>\n\n<script>\nSET('common.items', 3);\nconsole.log($('ui-bind').eq(0).hclass('hidden'), $('ui-bind').eq(1).hclass('hidden'));\n// logs: false true\n</script>\n```\n\n### hide:expression\n\nType: `command`\n\nAjoute la classe CSS `hidden` quand le résultat est truthy et la retire dans le cas contraire.\n\n### visible:expression\n\nType: `command`\n\nRetire la classe CSS `invisible` quand le résultat est truthy et l'ajoute dans le cas contraire.\n\n### invisible:expression\n\nType: `command`\n\nAjoute la classe CSS `invisible` quand le résultat est truthy et la retire dans le cas contraire.\n\nExample: Conserver l'espace de l'élément\n```html\n<ui-bind path=\"common.ready\" config=\"invisible:!value\">Loaded</ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: invisible\nSET('common.ready', true);\nconsole.log($('ui-bind').hclass('invisible'));\n// logs: false\n</script>\n```\n\n### forcerender:expression\n\nType: `command`\n\nPermet à `text`, `html` et `template` d'effectuer le rendu pendant que l'élément est masqué, quand le résultat est truthy.\n\nExample: Effectuer le rendu dans un élément masqué\n```html\n<ui-bind id=\"a\" path=\"common.name\" config=\"show:false;text\"></ui-bind>\n<ui-bind id=\"b\" path=\"common.name\" config=\"show:false;forcerender:true;text\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('#a').text() === '', $('#b').text());\n// logs: true Anna\n</script>\n```\n\n### template:[{selector}] [selector --> attribute]\n\nType: `command`\n\nEffectue le rendu d'un modèle Tangular avec la valeur.\n\nLe modèle provient d'un élément `<script>` ou `<template>` situé dans la cible, du HTML de la cible ou de l'élément indiqué dans `{selector}`. Le modèle de données contient `value`, `path` et `element`. Le texte `SCR` dans un modèle est remplacé par `script`.\n\nAvec `selector --> attribute`, seuls les éléments correspondant au sélecteur sont mis à jour. Les éléments existants ayant la même valeur d'attribut restent dans la page. Sans attribut, les éléments entiers sont comparés. Voir [Modèles avec Tangular](../../guides/tangular/).\n\nExample: Afficher une liste\n```html\n<ui-bind path=\"common.users\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<b>{{ m }}</b>{{ end }}\n    </script>\n</ui-bind>\n\n<script>\nSET('common.users', ['Anna', 'Peter']);\nconsole.log($('ui-bind').html().trim());\n// logs: <b>Anna</b><b>Peter</b>\n</script>\n```\n\nExample: Utiliser un modèle externe et ne mettre à jour que les lignes modifiées\n```html\n<script type=\"text/html\" id=\"row\"><div data-id=\"{{ value }}\">{{ value }}</div></script>\n<ui-bind path=\"common.id\" config=\"template:{#row} div --> data-id\"></ui-bind>\n\n<script>\nSET('common.id', 1);\nvar first = $('ui-bind div')[0];\nSET('common.id', 1);\nconsole.log(first === $('ui-bind div')[0]);\n// logs: true\n</script>\n```\n\n### helpers:path\n\nType: `command`\n\nDéfinit l'objet contenant les helpers Tangular de la commande `template`.\n\nExample: Helpers personnalisés\n```html\n<ui-bind path=\"common.name\" config=\"template;helpers:FUNC.helpers\">\n    <template>{{ value | shout }}</template>\n</ui-bind>\n\n<script>\nFUNC.helpers = {\n    shout: value => (value || '').toUpperCase() + '!'\n};\n\nSET('common.name', 'anna');\nconsole.log($('ui-bind').html().trim());\n// logs: ANNA!\n</script>\n```\n\n### format:value\n\nType: `command`\n\nFormate une valeur `Date` pour les commandes `text`, `html`, `value`, `title`, `href`, `src` et `attr`.\n\nExample: Formater une date\n```html\n<ui-bind path=\"common.date\" config=\"text;format:dd.MM.yyyy\"></ui-bind>\n\n<script>\nSET('common.date', new Date(2024, 0, 15));\nconsole.log($('ui-bind').text());\n// logs: 15.01.2024\n</script>\n```\n\n### empty:text\n\nType: `command`\n\nDéfinit le texte écrit par `text`, `html`, `value`, `title`, `href` et `src` quand le résultat vaut `null`, `undefined`, `false` ou une chaîne vide.\n\nSans valeur, le texte de `DEF.empty` est utilisé (`---`).\n\nExample: Afficher un texte de remplacement\n```html\n<ui-bind path=\"common.note\" config=\"text;empty:No note\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').text());\n// logs: No note\n</script>\n```\n\n### class:name\n\nType: `command`\n\nBascule une classe CSS sur l'élément `<ui-bind>` une seule fois, après la première exécution des commandes.\n\nExample: Marquer l'élément comme rendu\n```html\n<ui-bind path=\"common.name\" config=\"text;class:rendered\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: rendered\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nAppelle une fonction avec la valeur, le path et l'élément cible.\n\nUn `?` dans la valeur est remplacé par le path du plugin parent. La forme `?/method` appelle une méthode du plugin.\n\nExample: Appeler une fonction à chaque modification\n```html\n<ui-bind path=\"common.total\" config=\"exec:FUNC.total\"></ui-bind>\n\n<script>\nFUNC.total = function(value, path, element) {\n    value && console.log(value, path.toString(), element[0].tagName);\n};\n\nSET('common.total', 10);\n// logs: 10 common.total UI-BIND\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nAppelle une fonction avec la valeur, le path et l'élément cible, de la même manière que `exec`.\n\n### focus:selector\n\nType: `command`\n\nDéplace le focus vers le premier élément visible trouvé par le sélecteur, 500 millisecondes après la modification.\n\nLe focus n'est pas déplacé sur les appareils mobiles.\n\nExample: Donner le focus à un champ de saisie\n```html\n<ui-bind path=\"common.open\" config=\"focus:input\"><input id=\"name\" /></ui-bind>\n\n<script>\nsetTimeout(() => console.log(document.activeElement.id), 700);\n// logs: name\n</script>\n```\n\n### checked:expression\n\nType: `command`\n\nDéfinit l'état `checked` des cases à cocher et des boutons radio situés dans la cible.\n\nExample: Cocher une case\n```html\n<ui-bind path=\"common.agree\" config=\"checked\"><input type=\"checkbox\" /></ui-bind>\n\n<script>\nSET('common.agree', true);\nconsole.log($('input')[0].checked);\n// logs: true\n</script>\n```\n\n### disabled:expression\n\nType: `command`\n\nDésactive les contrôles de formulaire et les composants situés dans la cible quand le résultat est truthy.\n\nLes contrôles de formulaire sont `input`, `select`, `textarea` et `button`. Les composants reçoivent la clé de configuration `disabled`.\n\nExample: Désactiver un formulaire\n```html\n<ui-bind path=\"common.locked\" config=\"disabled\">\n    <input />\n    <ui-component name=\"field\"></ui-component>\n</ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.locked', true);\nconsole.log($('input').prop('disabled'), $('ui-component').hclass('ui-disabled'));\n// logs: true true\n</script>\n```\n\n### enabled:expression\n\nType: `command`\n\nActive les contrôles de formulaire et les composants situés dans la cible quand le résultat est truthy, et les désactive dans le cas contraire.\n\nExample: Activer un bouton\n```html\n<ui-bind path=\"common.valid\" config=\"enabled\"><button>Save</button></ui-bind>\n\n<script>\nconsole.log($('button').prop('disabled'));\n// logs: true\nSET('common.valid', true);\nconsole.log($('button').prop('disabled'));\n// logs: false\n</script>\n```\n\n### required:expression\n\nType: `command`\n\nDéfinit la clé de configuration `required` des composants situés dans la cible.\n\nExample: Rendre un champ obligatoire\n```html\n<ui-bind path=\"common.company\" config=\"required\"><ui-component name=\"field\"></ui-component></ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.company', true);\nconsole.log($('ui-component').component().config.required);\n// logs: true\n</script>\n```\n\n### assign:path\n\nType: `command`\n\nÉcrit l'instance du binder dans un path.\n\nL'instance possède la méthode `exec(value, path, [flags])`, qui exécute les commandes avec une valeur donnée.\n\nExample: Exécuter les commandes depuis le code\n```html\n<ui-bind path=\"common.name\" config=\"text;assign:common.binder\"></ui-bind>\n\n<script>\ncommon.binder.exec('Manual', 'common.name');\nconsole.log($('ui-bind').text());\n// logs: Manual\n</script>\n```\n\n### once\n\nType: `command`\n\nExécute les commandes une seule fois.\n\nAvec le préfixe `!` dans le path, les commandes s'exécutent pour la première valeur non vide. Sans lui, elles s'exécutent avec la valeur présente à la création de l'élément.\n\nExample: Afficher la première valeur\n```html\n<ui-bind path=\"!common.name\" config=\"once;text\"></ui-bind>\n\n<script>\nSET('common.name', 'first');\nSET('common.name', 'second');\nconsole.log($('ui-bind').text());\n// logs: first\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnore les modifications effectuées dans les paths imbriqués.\n\nExample: Réagir uniquement au path lui-même\n```html\n<ui-bind path=\"common.user\" config=\"strict;text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Anna' });\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Anna\n</script>\n```\n\n### track:name[,name]\n\nType: `command`\n\nLimite les modifications dans les paths imbriqués aux noms de propriétés listés.\n\nUne modification du path observé lui-même, ou d'un path parent, exécute toujours les commandes.\n\nExample: Suivre une propriété\n```html\n<ui-bind path=\"common.user\" config=\"track:name;text:value.name + ' ' + value.age\"></ui-bind>\n\n<script>\nSET('common.user.age', 30);\nconsole.log($('ui-bind').text());\n// logs: Anna 20\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Peter 30\n</script>\n```\n\n### changes\n\nType: `command`\n\nExécute les commandes uniquement quand la valeur diffère de la précédente.\n\nExample: Ignorer les valeurs identiques\n```html\n<ui-bind path=\"common.total\" config=\"changes;exec:FUNC.log\"></ui-bind>\n\n<script>\nFUNC.log = value => value && console.log(value);\n\nSET('common.total', 1);\nSET('common.total', 1);\nSET('common.total', 2);\n// logs: 1\n// logs: 2\n</script>\n```\n\n### check:path\n\nType: `command`\n\nExécute les commandes uniquement quand la fonction située au path renvoie une valeur truthy.\n\nLa fonction reçoit la valeur, le path et l'élément `<ui-bind>`.\n\nExample: Filtrer les valeurs\n```html\n<ui-bind path=\"common.age\" config=\"check:FUNC.adult;text\"></ui-bind>\n\n<script>\nFUNC.adult = value => value >= 18;\n\nSET('common.age', 15);\nconsole.log($('ui-bind').text() === '');\n// logs: true\nSET('common.age', 20);\nconsole.log($('ui-bind').text());\n// logs: 20\n</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nAttend le temps indiqué et exécute les commandes avec la dernière valeur.\n\nSans valeur, le délai est de 100 millisecondes.\n\nExample: Regrouper les modifications rapides\n```html\n<ui-bind path=\"common.search\" config=\"delay:50;text\"></ui-bind>\n\n<script>\nSET('common.search', 'a');\nSET('common.search', 'ab');\nconsole.log($('ui-bind').text() === '');\n// logs: true\nsetTimeout(() => console.log($('ui-bind').text()), 200);\n// logs: ab\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"commands\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"command","name":".name","signature":".name:expression","since":"","deprecated":false},{"type":"command","name":"text","signature":"text:expression","since":"","deprecated":false},{"type":"command","name":"html","signature":"html:expression","since":"","deprecated":false},{"type":"command","name":"value","signature":"value selector:expression","since":"","deprecated":false},{"type":"command","name":"title","signature":"title:expression","since":"","deprecated":false},{"type":"command","name":"href","signature":"href:expression","since":"","deprecated":false},{"type":"command","name":"src","signature":"src:expression","since":"","deprecated":false},{"type":"command","name":"attr","signature":"attr name [selector]:expression","since":"","deprecated":false},{"type":"command","name":"show","signature":"show:expression","since":"","deprecated":false},{"type":"command","name":"hide","signature":"hide:expression","since":"","deprecated":false},{"type":"command","name":"visible","signature":"visible:expression","since":"","deprecated":false},{"type":"command","name":"invisible","signature":"invisible:expression","since":"","deprecated":false},{"type":"command","name":"forcerender","signature":"forcerender:expression","since":"","deprecated":false},{"type":"command","name":"template","signature":"template:[{selector}] [selector --> attribute]","since":"","deprecated":false},{"type":"command","name":"helpers","signature":"helpers:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty:text","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"checked","signature":"checked:expression","since":"","deprecated":false},{"type":"command","name":"disabled","signature":"disabled:expression","since":"","deprecated":false},{"type":"command","name":"enabled","signature":"enabled:expression","since":"","deprecated":false},{"type":"command","name":"required","signature":"required:expression","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:name[,name]","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JamcZCAUo61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/ui-bind/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"ui-bind","summary":"Gli attributi e i comandi dell'elemento ui-bind.","markdown":"---\ntitle: ui-bind\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/ui-bind/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# ui-bind\n\n> Gli attributi e i comandi dell'elemento ui-bind.\n\nL'elemento `<ui-bind>` aggiorna la pagina ogni volta che cambia il valore in un path. L'attributo `config` contiene un elenco di comandi separati da `;`. La guida [Associazione dei dati](../../guides/data-binding/) spiega come usarlo.\n\nUn comando ha la forma `name:expression`, oppure `name selector:expression` per agire sugli elementi trovati da un selettore all'interno della destinazione. Senza espressione, il comando usa il valore nel path. L'espressione è JavaScript e può usare `value`, `path`, `flags`, `element` e `el` (equivalente a `element`). Unisci i nomi dei comandi con `+` per dar loro la stessa espressione, ad esempio `text+title:value`. Scrivi `\\\\;` per inserire un punto e virgola in un'espressione. Tutti i comandi vengono eseguiti una volta alla creazione dell'elemento, con il valore corrente nel path. Un errore in un'espressione viene scritto nella console e i comandi proseguono.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nIl path da osservare.\n\nUn `?` viene sostituito con il path del plugin genitore. Con un `!` all'inizio (`!common.user`), i comandi non vengono eseguiti finché il valore è `null` o `undefined`.\n\nExample: Salta i valori vuoti\n```html\n<ui-bind path=\"!common.user\" config=\"text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Peter' });\nconsole.log($('ui-bind').text());\n// logs: Peter\n</script>\n```\n\n### config=\"commands\"\n\nType: `property`\n\nI comandi, separati da `;`.\n\nI valori restano stringhe, perché vengono compilati come JavaScript.\n\n### element=\"selector\"\n\nType: `property`\n\nEsegue i comandi sugli elementi trovati da un selettore nell'intero documento.\n\nExample: Aggiorna un elemento in un'altra parte della pagina\n```html\n<h1 id=\"title\"></h1>\n<ui-bind path=\"common.title\" element=\"#title\" config=\"text\"></ui-bind>\n\n<script>\nSET('common.title', 'Orders');\nconsole.log($('#title').text());\n// logs: Orders\n</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nEsegue i comandi sugli elementi trovati da un selettore all'interno dell'elemento.\n\nIl comando `value` ha bisogno di questo attributo o di un selettore per raggiungere un input.\n\nExample: Compila un input\n```html\n<ui-bind path=\"common.email\" child=\"input\" config=\"value\"><input /></ui-bind>\n\n<script>\nSET('common.email', 'info@example.com');\nconsole.log($('input').val());\n// logs: info@example.com\n</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nEsegue i comandi sul genitore più vicino trovato da un selettore.\n\nExample: Modifica un elemento genitore\n```html\n<div class=\"row\">\n    <ui-bind path=\"common.active\" parent=\".row\" config=\".selected\"></ui-bind>\n</div>\n\n<script>\nSET('common.active', true);\nconsole.log($('.row').attr('class'));\n// logs: row selected\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea un plugin sull'elemento stesso, e un `?` nel path fa riferimento a esso.\n\nExample: Un binder con il proprio plugin\n```html\n<ui-bind plugin=\"clock\" path=\"?.time\" config=\"text\"></ui-bind>\n\n<script>\nPLUGIN('clock', function(exports) {\n    exports.make = () => exports.set('time', '12:00');\n});\n\nconsole.log($('ui-bind').text());\n// logs: 12:00\n</script>\n```\n\n### .name:expression\n\nType: `command`\n\nAttiva o disattiva la classe CSS `name` in base al risultato dell'espressione.\n\nExample: Attiva o disattiva le classi\n```html\n<ui-bind path=\"common.count\" config=\".empty:!value;.many:value > 10\"></ui-bind>\n\n<script>\nSET('common.count', 20);\nconsole.log($('ui-bind').attr('class'));\n// logs: many\n</script>\n```\n\n### text:expression\n\nType: `command`\n\nImposta il testo dell'elemento. L'HTML viene sottoposto a escape.\n\nUn risultato `null`, `undefined`, `false` o una stringa vuota scrive il valore del comando `empty`, mentre `0` viene scritto come `0`. Non viene scritto nulla mentre l'elemento è nascosto da `show`, `hide`, `visible` o `invisible`, a meno che `forcerender` non lo consenta.\n\nExample: Mostra un testo\n```html\n<ui-bind path=\"common.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n\n<script>\nSET('common.name', 'anna');\nconsole.log($('ui-bind').text());\n// logs: ANNA\n</script>\n```\n\n### html:expression\n\nType: `command`\n\nImposta il contenuto HTML dell'elemento.\n\nSegue le stesse regole di `text`, senza escape.\n\nExample: Renderizza il markup\n```html\n<ui-bind path=\"common.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('ui-bind').html());\n// logs: <b>Anna</b>\n</script>\n```\n\n### value selector:expression\n\nType: `command`\n\nImposta il valore di un controllo di modulo.\n\nUsa un selettore o l'attributo `child`, perché l'elemento `<ui-bind>` non è di per sé un controllo.\n\nExample: Compila un input con un selettore\n```html\n<ui-bind path=\"common.city\" config=\"value input\"><input /></ui-bind>\n\n<script>\nSET('common.city', 'Bratislava');\nconsole.log($('input').val());\n// logs: Bratislava\n</script>\n```\n\n### title:expression\n\nType: `command`\n\nImposta l'attributo `title`.\n\nExample: Testo e titolo insieme\n```html\n<ui-bind path=\"common.name\" config=\"text+title:value\"></ui-bind>\n\n<script>\nON('ready', function() {\n    SET('common.name', 'Anna');\n    console.log($('ui-bind').text(), $('ui-bind').attr('title'));\n});\n// logs: Anna Anna\n</script>\n```\n\n### href:expression\n\nType: `command`\n\nImposta l'attributo `href`.\n\n### src:expression\n\nType: `command`\n\nImposta l'attributo `src`.\n\nExample: Imposta gli attributi con i selettori\n```html\n<ui-bind path=\"common.user\" config=\"href a:'/users/' + value.id;title a:value.name;src img:value.photo\">\n    <a><img /></a>\n</ui-bind>\n\n<script>\nSET('common.user', { id: 7, name: 'Anna', photo: '/a.png' });\nconsole.log($('ui-bind').html().trim());\n// logs: <a href=\"/users/7\" title=\"Anna\"><img src=\"/a.png\"></a>\n</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nImposta l'attributo `name`.\n\nExample: Imposta un attributo personalizzato\n```html\n<ui-bind path=\"common.id\" config=\"attr data-id:value\"></ui-bind>\n\n<script>\nSET('common.id', 5);\nconsole.log($('ui-bind').attr('data-id'));\n// logs: 5\n</script>\n```\n\n### show:expression\n\nType: `command`\n\nRimuove la classe CSS `hidden` quando il risultato è truthy e la aggiunge in caso contrario.\n\nExample: Mostra e nascondi\n```html\n<ui-bind path=\"common.items\" config=\"show:value > 0\">Items</ui-bind>\n<ui-bind path=\"common.items\" config=\"hide:value > 0\">Empty</ui-bind>\n\n<script>\nSET('common.items', 3);\nconsole.log($('ui-bind').eq(0).hclass('hidden'), $('ui-bind').eq(1).hclass('hidden'));\n// logs: false true\n</script>\n```\n\n### hide:expression\n\nType: `command`\n\nAggiunge la classe CSS `hidden` quando il risultato è truthy e la rimuove in caso contrario.\n\n### visible:expression\n\nType: `command`\n\nRimuove la classe CSS `invisible` quando il risultato è truthy e la aggiunge in caso contrario.\n\n### invisible:expression\n\nType: `command`\n\nAggiunge la classe CSS `invisible` quando il risultato è truthy e la rimuove in caso contrario.\n\nExample: Mantieni lo spazio dell'elemento\n```html\n<ui-bind path=\"common.ready\" config=\"invisible:!value\">Loaded</ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: invisible\nSET('common.ready', true);\nconsole.log($('ui-bind').hclass('invisible'));\n// logs: false\n</script>\n```\n\n### forcerender:expression\n\nType: `command`\n\nConsente a `text`, `html` e `template` di renderizzare mentre l'elemento è nascosto, quando il risultato è truthy.\n\nExample: Renderizza in un elemento nascosto\n```html\n<ui-bind id=\"a\" path=\"common.name\" config=\"show:false;text\"></ui-bind>\n<ui-bind id=\"b\" path=\"common.name\" config=\"show:false;forcerender:true;text\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('#a').text() === '', $('#b').text());\n// logs: true Anna\n</script>\n```\n\n### template:[{selector}] [selector --> attribute]\n\nType: `command`\n\nRenderizza un template Tangular con il valore.\n\nIl template proviene da un elemento `<script>` o `<template>` all'interno della destinazione, dall'HTML della destinazione o dall'elemento indicato in `{selector}`. Il modello contiene `value`, `path` e `element`. Il testo `SCR` in un template viene sostituito con `script`.\n\nCon `selector --> attribute`, vengono aggiornati solo gli elementi che corrispondono al selettore. Gli elementi esistenti con lo stesso valore dell'attributo restano nella pagina. Senza attributo, vengono confrontati gli elementi interi. Vedi [Template con Tangular](../../guides/tangular/).\n\nExample: Renderizza un elenco\n```html\n<ui-bind path=\"common.users\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<b>{{ m }}</b>{{ end }}\n    </script>\n</ui-bind>\n\n<script>\nSET('common.users', ['Anna', 'Peter']);\nconsole.log($('ui-bind').html().trim());\n// logs: <b>Anna</b><b>Peter</b>\n</script>\n```\n\nExample: Usa un template esterno e aggiorna solo le righe modificate\n```html\n<script type=\"text/html\" id=\"row\"><div data-id=\"{{ value }}\">{{ value }}</div></script>\n<ui-bind path=\"common.id\" config=\"template:{#row} div --> data-id\"></ui-bind>\n\n<script>\nSET('common.id', 1);\nvar first = $('ui-bind div')[0];\nSET('common.id', 1);\nconsole.log(first === $('ui-bind div')[0]);\n// logs: true\n</script>\n```\n\n### helpers:path\n\nType: `command`\n\nImposta l'oggetto con gli helper di Tangular per il comando `template`.\n\nExample: Helper personalizzati\n```html\n<ui-bind path=\"common.name\" config=\"template;helpers:FUNC.helpers\">\n    <template>{{ value | shout }}</template>\n</ui-bind>\n\n<script>\nFUNC.helpers = {\n    shout: value => (value || '').toUpperCase() + '!'\n};\n\nSET('common.name', 'anna');\nconsole.log($('ui-bind').html().trim());\n// logs: ANNA!\n</script>\n```\n\n### format:value\n\nType: `command`\n\nFormatta un valore `Date` per i comandi `text`, `html`, `value`, `title`, `href`, `src` e `attr`.\n\nExample: Formatta una data\n```html\n<ui-bind path=\"common.date\" config=\"text;format:dd.MM.yyyy\"></ui-bind>\n\n<script>\nSET('common.date', new Date(2024, 0, 15));\nconsole.log($('ui-bind').text());\n// logs: 15.01.2024\n</script>\n```\n\n### empty:text\n\nType: `command`\n\nImposta il testo scritto da `text`, `html`, `value`, `title`, `href` e `src` quando il risultato è `null`, `undefined`, `false` o una stringa vuota.\n\nSenza un valore, viene usato il testo in `DEF.empty` (`---`).\n\nExample: Mostra un segnaposto\n```html\n<ui-bind path=\"common.note\" config=\"text;empty:No note\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').text());\n// logs: No note\n</script>\n```\n\n### class:name\n\nType: `command`\n\nAttiva o disattiva una classe CSS sull'elemento `<ui-bind>` una sola volta, dopo la prima esecuzione dei comandi.\n\nExample: Segna l'elemento come renderizzato\n```html\n<ui-bind path=\"common.name\" config=\"text;class:rendered\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: rendered\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nChiama una funzione con il valore, il path e l'elemento di destinazione.\n\nUn `?` nel valore viene sostituito con il path del plugin genitore. La forma `?/method` chiama un metodo del plugin.\n\nExample: Chiama una funzione a ogni modifica\n```html\n<ui-bind path=\"common.total\" config=\"exec:FUNC.total\"></ui-bind>\n\n<script>\nFUNC.total = function(value, path, element) {\n    value && console.log(value, path.toString(), element[0].tagName);\n};\n\nSET('common.total', 10);\n// logs: 10 common.total UI-BIND\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nChiama una funzione con il valore, il path e l'elemento di destinazione, allo stesso modo di `exec`.\n\n### focus:selector\n\nType: `command`\n\nSposta il focus sul primo elemento visibile trovato dal selettore, 500 millisecondi dopo la modifica.\n\nSui dispositivi mobili il focus non viene spostato.\n\nExample: Dai il focus a un input\n```html\n<ui-bind path=\"common.open\" config=\"focus:input\"><input id=\"name\" /></ui-bind>\n\n<script>\nsetTimeout(() => console.log(document.activeElement.id), 700);\n// logs: name\n</script>\n```\n\n### checked:expression\n\nType: `command`\n\nImposta lo stato `checked` delle caselle di controllo e dei pulsanti di opzione all'interno della destinazione.\n\nExample: Seleziona una casella di controllo\n```html\n<ui-bind path=\"common.agree\" config=\"checked\"><input type=\"checkbox\" /></ui-bind>\n\n<script>\nSET('common.agree', true);\nconsole.log($('input')[0].checked);\n// logs: true\n</script>\n```\n\n### disabled:expression\n\nType: `command`\n\nDisabilita i controlli di modulo e i componenti all'interno della destinazione quando il risultato è truthy.\n\nI controlli di modulo sono `input`, `select`, `textarea` e `button`. I componenti ricevono la chiave di configurazione `disabled`.\n\nExample: Disabilita un modulo\n```html\n<ui-bind path=\"common.locked\" config=\"disabled\">\n    <input />\n    <ui-component name=\"field\"></ui-component>\n</ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.locked', true);\nconsole.log($('input').prop('disabled'), $('ui-component').hclass('ui-disabled'));\n// logs: true true\n</script>\n```\n\n### enabled:expression\n\nType: `command`\n\nAbilita i controlli di modulo e i componenti all'interno della destinazione quando il risultato è truthy e li disabilita in caso contrario.\n\nExample: Abilita un pulsante\n```html\n<ui-bind path=\"common.valid\" config=\"enabled\"><button>Save</button></ui-bind>\n\n<script>\nconsole.log($('button').prop('disabled'));\n// logs: true\nSET('common.valid', true);\nconsole.log($('button').prop('disabled'));\n// logs: false\n</script>\n```\n\n### required:expression\n\nType: `command`\n\nImposta la chiave di configurazione `required` dei componenti all'interno della destinazione.\n\nExample: Rendi obbligatorio un campo\n```html\n<ui-bind path=\"common.company\" config=\"required\"><ui-component name=\"field\"></ui-component></ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.company', true);\nconsole.log($('ui-component').component().config.required);\n// logs: true\n</script>\n```\n\n### assign:path\n\nType: `command`\n\nScrive l'istanza del binder in un path.\n\nL'istanza ha il metodo `exec(value, path, [flags])`, che esegue i comandi con un valore dato.\n\nExample: Esegui i comandi dal codice\n```html\n<ui-bind path=\"common.name\" config=\"text;assign:common.binder\"></ui-bind>\n\n<script>\ncommon.binder.exec('Manual', 'common.name');\nconsole.log($('ui-bind').text());\n// logs: Manual\n</script>\n```\n\n### once\n\nType: `command`\n\nEsegue i comandi una sola volta.\n\nCon il prefisso `!` nel path, i comandi vengono eseguiti per il primo valore non vuoto. Senza, vengono eseguiti con il valore presente alla creazione dell'elemento.\n\nExample: Renderizza il primo valore\n```html\n<ui-bind path=\"!common.name\" config=\"once;text\"></ui-bind>\n\n<script>\nSET('common.name', 'first');\nSET('common.name', 'second');\nconsole.log($('ui-bind').text());\n// logs: first\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnora le modifiche fatte nei path annidati.\n\nExample: Reagisci solo al path stesso\n```html\n<ui-bind path=\"common.user\" config=\"strict;text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Anna' });\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Anna\n</script>\n```\n\n### track:name[,name]\n\nType: `command`\n\nLimita le modifiche nei path annidati ai nomi di proprietà elencati.\n\nUna modifica del path osservato stesso, o di un path genitore, esegue sempre i comandi.\n\nExample: Segui una proprietà\n```html\n<ui-bind path=\"common.user\" config=\"track:name;text:value.name + ' ' + value.age\"></ui-bind>\n\n<script>\nSET('common.user.age', 30);\nconsole.log($('ui-bind').text());\n// logs: Anna 20\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Peter 30\n</script>\n```\n\n### changes\n\nType: `command`\n\nEsegue i comandi solo quando il valore è diverso dal precedente.\n\nExample: Ignora i valori identici\n```html\n<ui-bind path=\"common.total\" config=\"changes;exec:FUNC.log\"></ui-bind>\n\n<script>\nFUNC.log = value => value && console.log(value);\n\nSET('common.total', 1);\nSET('common.total', 1);\nSET('common.total', 2);\n// logs: 1\n// logs: 2\n</script>\n```\n\n### check:path\n\nType: `command`\n\nEsegue i comandi solo quando la funzione nel path restituisce un valore truthy.\n\nLa funzione riceve il valore, il path e l'elemento `<ui-bind>`.\n\nExample: Filtra i valori\n```html\n<ui-bind path=\"common.age\" config=\"check:FUNC.adult;text\"></ui-bind>\n\n<script>\nFUNC.adult = value => value >= 18;\n\nSET('common.age', 15);\nconsole.log($('ui-bind').text() === '');\n// logs: true\nSET('common.age', 20);\nconsole.log($('ui-bind').text());\n// logs: 20\n</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nAttende il tempo indicato ed esegue i comandi con l'ultimo valore.\n\nSenza un valore, il ritardo è di 100 millisecondi.\n\nExample: Raggruppa le modifiche rapide\n```html\n<ui-bind path=\"common.search\" config=\"delay:50;text\"></ui-bind>\n\n<script>\nSET('common.search', 'a');\nSET('common.search', 'ab');\nconsole.log($('ui-bind').text() === '');\n// logs: true\nsetTimeout(() => console.log($('ui-bind').text()), 200);\n// logs: ab\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"commands\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"command","name":".name","signature":".name:expression","since":"","deprecated":false},{"type":"command","name":"text","signature":"text:expression","since":"","deprecated":false},{"type":"command","name":"html","signature":"html:expression","since":"","deprecated":false},{"type":"command","name":"value","signature":"value selector:expression","since":"","deprecated":false},{"type":"command","name":"title","signature":"title:expression","since":"","deprecated":false},{"type":"command","name":"href","signature":"href:expression","since":"","deprecated":false},{"type":"command","name":"src","signature":"src:expression","since":"","deprecated":false},{"type":"command","name":"attr","signature":"attr name [selector]:expression","since":"","deprecated":false},{"type":"command","name":"show","signature":"show:expression","since":"","deprecated":false},{"type":"command","name":"hide","signature":"hide:expression","since":"","deprecated":false},{"type":"command","name":"visible","signature":"visible:expression","since":"","deprecated":false},{"type":"command","name":"invisible","signature":"invisible:expression","since":"","deprecated":false},{"type":"command","name":"forcerender","signature":"forcerender:expression","since":"","deprecated":false},{"type":"command","name":"template","signature":"template:[{selector}] [selector --> attribute]","since":"","deprecated":false},{"type":"command","name":"helpers","signature":"helpers:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty:text","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"checked","signature":"checked:expression","since":"","deprecated":false},{"type":"command","name":"disabled","signature":"disabled:expression","since":"","deprecated":false},{"type":"command","name":"enabled","signature":"enabled:expression","since":"","deprecated":false},{"type":"command","name":"required","signature":"required:expression","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:name[,name]","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JamcZCAUo61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/ui-bind/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"ui-bind","summary":"Atribúty a príkazy elementu ui-bind.","markdown":"---\ntitle: ui-bind\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/ui-bind/\nupdated: 2026-11-22T18:42:02.302Z\n---\n\n# ui-bind\n\n> Atribúty a príkazy elementu ui-bind.\n\nElement `<ui-bind>` aktualizuje stránku vždy, keď sa zmení hodnota na path. Atribút `config` obsahuje zoznam príkazov oddelených znakom `;`. Ako ho používať, vysvetľuje príručka [Dátová väzba](../../guides/data-binding/).\n\nPríkaz má tvar `name:expression` alebo `name selector:expression`, ak má pôsobiť na elementy nájdené selektorom vnútri cieľa. Bez výrazu príkaz použije hodnotu na path. Výraz je JavaScript a môže používať `value`, `path`, `flags`, `element` a `el` (to isté ako `element`). Ak chceš viacerým príkazom dať rovnaký výraz, spoj ich názvy znakom `+`, napríklad `text+title:value`. Bodkočiarku vnútri výrazu zapíš ako `\\\\;`. Všetky príkazy sa spustia raz pri vytvorení elementu s aktuálnou hodnotou na path. Chyba vo výraze sa vypíše do konzoly a príkazy pokračujú.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nPath, ktorá sa má sledovať.\n\nZnak `?` sa nahradí path nadradeného pluginu. So znakom `!` na začiatku (`!common.user`) sa príkazy nespúšťajú, kým je hodnota `null` alebo `undefined`.\n\nExample: Preskoč prázdne hodnoty\n```html\n<ui-bind path=\"!common.user\" config=\"text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Peter' });\nconsole.log($('ui-bind').text());\n// logs: Peter\n</script>\n```\n\n### config=\"commands\"\n\nType: `property`\n\nPríkazy oddelené znakom `;`.\n\nHodnoty zostávajú reťazcami, pretože sa kompilujú ako JavaScript.\n\n### element=\"selector\"\n\nType: `property`\n\nSpustí príkazy na elementoch nájdených selektorom v celom dokumente.\n\nExample: Aktualizuj element inde na stránke\n```html\n<h1 id=\"title\"></h1>\n<ui-bind path=\"common.title\" element=\"#title\" config=\"text\"></ui-bind>\n\n<script>\nSET('common.title', 'Orders');\nconsole.log($('#title').text());\n// logs: Orders\n</script>\n```\n\n### child=\"selector\"\n\nType: `property`\n\nSpustí príkazy na elementoch nájdených selektorom vnútri elementu.\n\nPríkaz `value` potrebuje tento atribút alebo selektor, aby sa dostal k vstupnému poľu.\n\nExample: Vyplň vstupné pole\n```html\n<ui-bind path=\"common.email\" child=\"input\" config=\"value\"><input /></ui-bind>\n\n<script>\nSET('common.email', 'info@example.com');\nconsole.log($('input').val());\n// logs: info@example.com\n</script>\n```\n\n### parent=\"selector\"\n\nType: `property`\n\nSpustí príkazy na najbližšom nadradenom elemente nájdenom selektorom.\n\nExample: Zmeň nadradený element\n```html\n<div class=\"row\">\n    <ui-bind path=\"common.active\" parent=\".row\" config=\".selected\"></ui-bind>\n</div>\n\n<script>\nSET('common.active', true);\nconsole.log($('.row').attr('class'));\n// logs: row selected\n</script>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nVytvorí plugin priamo na elemente a znak `?` v path odkazuje naň.\n\nExample: Binder s vlastným pluginom\n```html\n<ui-bind plugin=\"clock\" path=\"?.time\" config=\"text\"></ui-bind>\n\n<script>\nPLUGIN('clock', function(exports) {\n    exports.make = () => exports.set('time', '12:00');\n});\n\nconsole.log($('ui-bind').text());\n// logs: 12:00\n</script>\n```\n\n### .name:expression\n\nType: `command`\n\nPrepína triedu CSS `name` podľa výsledku výrazu.\n\nExample: Prepínaj triedy\n```html\n<ui-bind path=\"common.count\" config=\".empty:!value;.many:value > 10\"></ui-bind>\n\n<script>\nSET('common.count', 20);\nconsole.log($('ui-bind').attr('class'));\n// logs: many\n</script>\n```\n\n### text:expression\n\nType: `command`\n\nNastaví text elementu. HTML sa escapuje.\n\nVýsledok `null`, `undefined`, `false` alebo prázdny reťazec zapíše hodnotu príkazu `empty` a `0` sa zapíše ako `0`. Kým je element skrytý príkazom `show`, `hide`, `visible` alebo `invisible`, nič sa nezapisuje, pokiaľ to nepovolí `forcerender`.\n\nExample: Zobraz text\n```html\n<ui-bind path=\"common.name\" config=\"text:value.toUpperCase()\"></ui-bind>\n\n<script>\nSET('common.name', 'anna');\nconsole.log($('ui-bind').text());\n// logs: ANNA\n</script>\n```\n\n### html:expression\n\nType: `command`\n\nNastaví obsah HTML elementu.\n\nRiadi sa rovnakými pravidlami ako `text`, ale bez escapovania.\n\nExample: Vykresli značky\n```html\n<ui-bind path=\"common.name\" config=\"html:'<b>' + value + '</b>'\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('ui-bind').html());\n// logs: <b>Anna</b>\n</script>\n```\n\n### value selector:expression\n\nType: `command`\n\nNastaví hodnotu ovládacieho prvku formulára.\n\nPouži selektor alebo atribút `child`, pretože element `<ui-bind>` sám nie je ovládací prvok.\n\nExample: Vyplň vstupné pole pomocou selektora\n```html\n<ui-bind path=\"common.city\" config=\"value input\"><input /></ui-bind>\n\n<script>\nSET('common.city', 'Bratislava');\nconsole.log($('input').val());\n// logs: Bratislava\n</script>\n```\n\n### title:expression\n\nType: `command`\n\nNastaví atribút `title`.\n\nExample: Text a title naraz\n```html\n<ui-bind path=\"common.name\" config=\"text+title:value\"></ui-bind>\n\n<script>\nON('ready', function() {\n    SET('common.name', 'Anna');\n    console.log($('ui-bind').text(), $('ui-bind').attr('title'));\n});\n// logs: Anna Anna\n</script>\n```\n\n### href:expression\n\nType: `command`\n\nNastaví atribút `href`.\n\n### src:expression\n\nType: `command`\n\nNastaví atribút `src`.\n\nExample: Nastav atribúty pomocou selektorov\n```html\n<ui-bind path=\"common.user\" config=\"href a:'/users/' + value.id;title a:value.name;src img:value.photo\">\n    <a><img /></a>\n</ui-bind>\n\n<script>\nSET('common.user', { id: 7, name: 'Anna', photo: '/a.png' });\nconsole.log($('ui-bind').html().trim());\n// logs: <a href=\"/users/7\" title=\"Anna\"><img src=\"/a.png\"></a>\n</script>\n```\n\n### attr name [selector]:expression\n\nType: `command`\n\nNastaví atribút `name`.\n\nExample: Nastav vlastný atribút\n```html\n<ui-bind path=\"common.id\" config=\"attr data-id:value\"></ui-bind>\n\n<script>\nSET('common.id', 5);\nconsole.log($('ui-bind').attr('data-id'));\n// logs: 5\n</script>\n```\n\n### show:expression\n\nType: `command`\n\nOdstráni triedu CSS `hidden`, keď je výsledok pravdivý, inak ju pridá.\n\nExample: Zobrazuj a skrývaj\n```html\n<ui-bind path=\"common.items\" config=\"show:value > 0\">Items</ui-bind>\n<ui-bind path=\"common.items\" config=\"hide:value > 0\">Empty</ui-bind>\n\n<script>\nSET('common.items', 3);\nconsole.log($('ui-bind').eq(0).hclass('hidden'), $('ui-bind').eq(1).hclass('hidden'));\n// logs: false true\n</script>\n```\n\n### hide:expression\n\nType: `command`\n\nPridá triedu CSS `hidden`, keď je výsledok pravdivý, inak ju odstráni.\n\n### visible:expression\n\nType: `command`\n\nOdstráni triedu CSS `invisible`, keď je výsledok pravdivý, inak ju pridá.\n\n### invisible:expression\n\nType: `command`\n\nPridá triedu CSS `invisible`, keď je výsledok pravdivý, inak ju odstráni.\n\nExample: Zachovaj miesto elementu\n```html\n<ui-bind path=\"common.ready\" config=\"invisible:!value\">Loaded</ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: invisible\nSET('common.ready', true);\nconsole.log($('ui-bind').hclass('invisible'));\n// logs: false\n</script>\n```\n\n### forcerender:expression\n\nType: `command`\n\nKeď je výsledok pravdivý, povolí príkazom `text`, `html` a `template` vykresľovať aj počas skrytia elementu.\n\nExample: Vykresli do skrytého elementu\n```html\n<ui-bind id=\"a\" path=\"common.name\" config=\"show:false;text\"></ui-bind>\n<ui-bind id=\"b\" path=\"common.name\" config=\"show:false;forcerender:true;text\"></ui-bind>\n\n<script>\nSET('common.name', 'Anna');\nconsole.log($('#a').text() === '', $('#b').text());\n// logs: true Anna\n</script>\n```\n\n### template:[{selector}] [selector --> attribute]\n\nType: `command`\n\nVykreslí šablónu Tangular s hodnotou.\n\nŠablóna pochádza z elementu `<script>` alebo `<template>` vnútri cieľa, z HTML cieľa alebo z elementu v `{selector}`. Model obsahuje `value`, `path` a `element`. Text `SCR` v šablóne sa nahradí za `script`.\n\nS `selector --> attribute` sa aktualizujú iba elementy zodpovedajúce selektoru. Existujúce elementy s rovnakou hodnotou atribútu zostanú na stránke. Bez atribútu sa porovnávajú celé elementy. Pozri [Šablóny s Tangularom](../../guides/tangular/).\n\nExample: Vykresli zoznam\n```html\n<ui-bind path=\"common.users\" config=\"template\">\n    <script type=\"text/html\">\n        {{ foreach m in value }}<b>{{ m }}</b>{{ end }}\n    </script>\n</ui-bind>\n\n<script>\nSET('common.users', ['Anna', 'Peter']);\nconsole.log($('ui-bind').html().trim());\n// logs: <b>Anna</b><b>Peter</b>\n</script>\n```\n\nExample: Použi externú šablónu a aktualizuj iba zmenené riadky\n```html\n<script type=\"text/html\" id=\"row\"><div data-id=\"{{ value }}\">{{ value }}</div></script>\n<ui-bind path=\"common.id\" config=\"template:{#row} div --> data-id\"></ui-bind>\n\n<script>\nSET('common.id', 1);\nvar first = $('ui-bind div')[0];\nSET('common.id', 1);\nconsole.log(first === $('ui-bind div')[0]);\n// logs: true\n</script>\n```\n\n### helpers:path\n\nType: `command`\n\nNastaví objekt s helpermi Tangularu pre príkaz `template`.\n\nExample: Vlastné helpery\n```html\n<ui-bind path=\"common.name\" config=\"template;helpers:FUNC.helpers\">\n    <template>{{ value | shout }}</template>\n</ui-bind>\n\n<script>\nFUNC.helpers = {\n    shout: value => (value || '').toUpperCase() + '!'\n};\n\nSET('common.name', 'anna');\nconsole.log($('ui-bind').html().trim());\n// logs: ANNA!\n</script>\n```\n\n### format:value\n\nType: `command`\n\nNaformátuje hodnotu `Date` pre príkazy `text`, `html`, `value`, `title`, `href`, `src` a `attr`.\n\nExample: Naformátuj dátum\n```html\n<ui-bind path=\"common.date\" config=\"text;format:dd.MM.yyyy\"></ui-bind>\n\n<script>\nSET('common.date', new Date(2024, 0, 15));\nconsole.log($('ui-bind').text());\n// logs: 15.01.2024\n</script>\n```\n\n### empty:text\n\nType: `command`\n\nNastaví text, ktorý príkazy `text`, `html`, `value`, `title`, `href` a `src` zapíšu, keď je výsledok `null`, `undefined`, `false` alebo prázdny reťazec.\n\nBez hodnoty sa použije text v `DEF.empty` (`---`).\n\nExample: Zobraz zástupný text\n```html\n<ui-bind path=\"common.note\" config=\"text;empty:No note\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').text());\n// logs: No note\n</script>\n```\n\n### class:name\n\nType: `command`\n\nPrepne triedu CSS na elemente `<ui-bind>` raz, po prvom spustení príkazov.\n\nExample: Označ element ako vykreslený\n```html\n<ui-bind path=\"common.name\" config=\"text;class:rendered\"></ui-bind>\n\n<script>\nconsole.log($('ui-bind').attr('class'));\n// logs: rendered\n</script>\n```\n\n### exec:path\n\nType: `command`\n\nZavolá funkciu s hodnotou, path a cieľovým elementom.\n\nZnak `?` v hodnote sa nahradí path nadradeného pluginu. Tvar `?/method` zavolá metódu pluginu.\n\nExample: Zavolaj funkciu pri každej zmene\n```html\n<ui-bind path=\"common.total\" config=\"exec:FUNC.total\"></ui-bind>\n\n<script>\nFUNC.total = function(value, path, element) {\n    value && console.log(value, path.toString(), element[0].tagName);\n};\n\nSET('common.total', 10);\n// logs: 10 common.total UI-BIND\n</script>\n```\n\n### refresh:path\n\nType: `command`\n\nZavolá funkciu s hodnotou, path a cieľovým elementom, rovnako ako `exec`.\n\n### focus:selector\n\nType: `command`\n\nPresunie focus na prvý viditeľný element nájdený selektorom, a to 500 milisekúnd po zmene.\n\nNa mobilných zariadeniach sa focus nepresúva.\n\nExample: Presuň focus na vstupné pole\n```html\n<ui-bind path=\"common.open\" config=\"focus:input\"><input id=\"name\" /></ui-bind>\n\n<script>\nsetTimeout(() => console.log(document.activeElement.id), 700);\n// logs: name\n</script>\n```\n\n### checked:expression\n\nType: `command`\n\nNastaví stav `checked` zaškrtávacích políčok a prepínačov vnútri cieľa.\n\nExample: Zaškrtni políčko\n```html\n<ui-bind path=\"common.agree\" config=\"checked\"><input type=\"checkbox\" /></ui-bind>\n\n<script>\nSET('common.agree', true);\nconsole.log($('input')[0].checked);\n// logs: true\n</script>\n```\n\n### disabled:expression\n\nType: `command`\n\nKeď je výsledok pravdivý, zakáže ovládacie prvky formulára a komponenty vnútri cieľa.\n\nOvládacie prvky formulára sú `input`, `select`, `textarea` a `button`. Komponenty dostanú konfiguračný kľúč `disabled`.\n\nExample: Zakáž formulár\n```html\n<ui-bind path=\"common.locked\" config=\"disabled\">\n    <input />\n    <ui-component name=\"field\"></ui-component>\n</ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.locked', true);\nconsole.log($('input').prop('disabled'), $('ui-component').hclass('ui-disabled'));\n// logs: true true\n</script>\n```\n\n### enabled:expression\n\nType: `command`\n\nKeď je výsledok pravdivý, povolí ovládacie prvky formulára a komponenty vnútri cieľa, inak ich zakáže.\n\nExample: Povoľ tlačidlo\n```html\n<ui-bind path=\"common.valid\" config=\"enabled\"><button>Save</button></ui-bind>\n\n<script>\nconsole.log($('button').prop('disabled'));\n// logs: true\nSET('common.valid', true);\nconsole.log($('button').prop('disabled'));\n// logs: false\n</script>\n```\n\n### required:expression\n\nType: `command`\n\nNastaví konfiguračný kľúč `required` komponentov vnútri cieľa.\n\nExample: Nastav pole ako povinné\n```html\n<ui-bind path=\"common.company\" config=\"required\"><ui-component name=\"field\"></ui-component></ui-bind>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nSET('common.company', true);\nconsole.log($('ui-component').component().config.required);\n// logs: true\n</script>\n```\n\n### assign:path\n\nType: `command`\n\nZapíše inštanciu bindera na path.\n\nInštancia má metódu `exec(value, path, [flags])`, ktorá spustí príkazy s danou hodnotou.\n\nExample: Spusti príkazy z kódu\n```html\n<ui-bind path=\"common.name\" config=\"text;assign:common.binder\"></ui-bind>\n\n<script>\ncommon.binder.exec('Manual', 'common.name');\nconsole.log($('ui-bind').text());\n// logs: Manual\n</script>\n```\n\n### once\n\nType: `command`\n\nSpustí príkazy iba raz.\n\nS prefixom `!` v path sa príkazy spustia pre prvú neprázdnu hodnotu. Bez neho sa spustia s hodnotou, ktorá existuje pri vytvorení elementu.\n\nExample: Vykresli prvú hodnotu\n```html\n<ui-bind path=\"!common.name\" config=\"once;text\"></ui-bind>\n\n<script>\nSET('common.name', 'first');\nSET('common.name', 'second');\nconsole.log($('ui-bind').text());\n// logs: first\n</script>\n```\n\n### strict\n\nType: `command`\n\nIgnoruje zmeny vo vnorených paths.\n\nExample: Reaguj iba na samotný path\n```html\n<ui-bind path=\"common.user\" config=\"strict;text:value.name\"></ui-bind>\n\n<script>\nSET('common.user', { name: 'Anna' });\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Anna\n</script>\n```\n\n### track:name[,name]\n\nType: `command`\n\nObmedzí zmeny vo vnorených paths na uvedené názvy vlastností.\n\nZmena samotného sledovaného path alebo nadradeného path príkazy spustí vždy.\n\nExample: Sleduj jednu vlastnosť\n```html\n<ui-bind path=\"common.user\" config=\"track:name;text:value.name + ' ' + value.age\"></ui-bind>\n\n<script>\nSET('common.user.age', 30);\nconsole.log($('ui-bind').text());\n// logs: Anna 20\nSET('common.user.name', 'Peter');\nconsole.log($('ui-bind').text());\n// logs: Peter 30\n</script>\n```\n\n### changes\n\nType: `command`\n\nSpustí príkazy iba vtedy, keď sa hodnota líši od predchádzajúcej.\n\nExample: Ignoruj rovnaké hodnoty\n```html\n<ui-bind path=\"common.total\" config=\"changes;exec:FUNC.log\"></ui-bind>\n\n<script>\nFUNC.log = value => value && console.log(value);\n\nSET('common.total', 1);\nSET('common.total', 1);\nSET('common.total', 2);\n// logs: 1\n// logs: 2\n</script>\n```\n\n### check:path\n\nType: `command`\n\nSpustí príkazy iba vtedy, keď funkcia na path vráti pravdivú hodnotu.\n\nFunkcia dostane hodnotu, path a element `<ui-bind>`.\n\nExample: Filtruj hodnoty\n```html\n<ui-bind path=\"common.age\" config=\"check:FUNC.adult;text\"></ui-bind>\n\n<script>\nFUNC.adult = value => value >= 18;\n\nSET('common.age', 15);\nconsole.log($('ui-bind').text() === '');\n// logs: true\nSET('common.age', 20);\nconsole.log($('ui-bind').text());\n// logs: 20\n</script>\n```\n\n### delay:milliseconds\n\nType: `command`\n\nPočká zadaný čas a spustí príkazy s poslednou hodnotou.\n\nBez hodnoty je oneskorenie 100 milisekúnd.\n\nExample: Zoskup rýchle zmeny\n```html\n<ui-bind path=\"common.search\" config=\"delay:50;text\"></ui-bind>\n\n<script>\nSET('common.search', 'a');\nSET('common.search', 'ab');\nconsole.log($('ui-bind').text() === '');\n// logs: true\nsetTimeout(() => console.log($('ui-bind').text()), 200);\n// logs: ab\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"commands\"","since":"","deprecated":false},{"type":"property","name":"element","signature":"element=\"selector\"","since":"","deprecated":false},{"type":"property","name":"child","signature":"child=\"selector\"","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent=\"selector\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"command","name":".name","signature":".name:expression","since":"","deprecated":false},{"type":"command","name":"text","signature":"text:expression","since":"","deprecated":false},{"type":"command","name":"html","signature":"html:expression","since":"","deprecated":false},{"type":"command","name":"value","signature":"value selector:expression","since":"","deprecated":false},{"type":"command","name":"title","signature":"title:expression","since":"","deprecated":false},{"type":"command","name":"href","signature":"href:expression","since":"","deprecated":false},{"type":"command","name":"src","signature":"src:expression","since":"","deprecated":false},{"type":"command","name":"attr","signature":"attr name [selector]:expression","since":"","deprecated":false},{"type":"command","name":"show","signature":"show:expression","since":"","deprecated":false},{"type":"command","name":"hide","signature":"hide:expression","since":"","deprecated":false},{"type":"command","name":"visible","signature":"visible:expression","since":"","deprecated":false},{"type":"command","name":"invisible","signature":"invisible:expression","since":"","deprecated":false},{"type":"command","name":"forcerender","signature":"forcerender:expression","since":"","deprecated":false},{"type":"command","name":"template","signature":"template:[{selector}] [selector --> attribute]","since":"","deprecated":false},{"type":"command","name":"helpers","signature":"helpers:path","since":"","deprecated":false},{"type":"command","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"command","name":"empty","signature":"empty:text","since":"","deprecated":false},{"type":"command","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"command","name":"exec","signature":"exec:path","since":"","deprecated":false},{"type":"command","name":"refresh","signature":"refresh:path","since":"","deprecated":false},{"type":"command","name":"focus","signature":"focus:selector","since":"","deprecated":false},{"type":"command","name":"checked","signature":"checked:expression","since":"","deprecated":false},{"type":"command","name":"disabled","signature":"disabled:expression","since":"","deprecated":false},{"type":"command","name":"enabled","signature":"enabled:expression","since":"","deprecated":false},{"type":"command","name":"required","signature":"required:expression","since":"","deprecated":false},{"type":"command","name":"assign","signature":"assign:path","since":"","deprecated":false},{"type":"command","name":"once","signature":"once","since":"","deprecated":false},{"type":"command","name":"strict","signature":"strict","since":"","deprecated":false},{"type":"command","name":"track","signature":"track:name[,name]","since":"","deprecated":false},{"type":"command","name":"changes","signature":"changes","since":"","deprecated":false},{"type":"command","name":"check","signature":"check:path","since":"","deprecated":false},{"type":"command","name":"delay","signature":"delay:milliseconds","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-22T18:42:02.302Z"}
{"id":"JamcaEBko61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/ui-component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"ui-component","summary":"The attributes and the config keys of the ui-component element.","markdown":"---\ntitle: ui-component\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/ui-component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-component\n\n> The attributes and the config keys of the ui-component element.\n\nThe `<ui-component>` element places an instance of a component declared with `COMPONENT()` in the page. Its attributes are read once, when the element is created. The [Using components](../../guides/using-components/) guide explains how to work with it, and the instance itself is described on the [Component](../component/) page.\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nThe name of the component declared with `COMPONENT()`. The attribute is required: an element without it is ignored.\n\nWhen no declaration with this name exists, the library downloads one from the address in the `source` attribute, or from the address in `DEF.fallback`.\n\nA name that starts with `LAZY ` (for example `LAZY dialog`) delays the creation of the instance until the first `SETTER()` call for that component.\n\nExample: Create a component on the first SETTER() call\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\nCOMPONENT('dialog', function(self) {\n    console.log('created');\n    self.show = function(title) {\n        console.log('show', title);\n    };\n});\n\n// The instance does not exist yet. This call creates it and then runs show().\nSETTER('dialog/show', 'Hello');\n// logs: created\n// logs: show Hello\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nThe path of the value that the component reads and writes.\n\nThe value is passed to the `setter` of the component and every change at the path calls it again. A `?` is replaced with the path of the parent plugin. Without this attribute, or with the value `null`, the component has no path. See [Paths](../../guides/paths/).\n\nExample: Bind a component to a path\n```html\n<ui-component name=\"label\" path=\"common.title\"></ui-component>\n\n<script>\nCOMPONENT('label', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n});\n\nSET('common.title', 'Hello');\nconsole.log($('ui-component').text());\n// logs: Hello\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nThe configuration of the instance.\n\nKeys and values are separated with `:`, pairs with `;`. Write `\\;` and `\\:` to use these characters in a value. The values `true` and `false` become booleans and numeric values become numbers. Everything else stays a string.\n\nThe keys of the attribute overwrite the default configuration given to `COMPONENT()`.\n\nExample: Read the configuration\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;open:true;note:a\\;b\"></ui-component>\n\n<script>\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n    console.log(JSON.stringify(config));\n});\n// logs: {\"limit\":10,\"color\":\"red\",\"title\":\"Orders\",\"open\":true,\"note\":\"a;b\"}\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nA JavaScript expression that gives the default value of the path.\n\nThe expression is evaluated when the component initializes and the value at the path is `null` or `undefined`. The result is written to the path without calling the `setter` a second time. It is evaluated again when a notification with the `@default` flag finds an empty value.\n\nExample: Fill an empty path\n```html\n<ui-component name=\"field\" path=\"common.count\" default=\"10\"></ui-component>\n<ui-component name=\"field\" path=\"common.tags\" default=\"['a', 'b']\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nconsole.log(common.count, common.tags.join());\n// logs: 10 a,b\n</script>\n```\n\n### source=\"URL\"\n\nType: `property`\n\nThe address of the declaration, used when the component is not declared in the page.\n\nThe content at the address is imported once for all elements with the same name, and the waiting instances are created afterwards.\n\nExample: Load the declaration from your own server\n```html\n<ui-component name=\"clock\" source=\"/components/clock.html\"></ui-component>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCreates a plugin on the element itself.\n\nThe value has the same form as the `path` attribute of [ui-plugin](../ui-plugin/). The plugin is created first, and a `?` in the path of the component refers to it.\n\nExample: A component with its own plugin\n```html\n<ui-component name=\"total\" plugin=\"orders\" path=\"?.sum\"></ui-component>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = function() {\n        exports.set('sum', 25);\n    };\n});\n\nCOMPONENT('total', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n    self.make = function() {\n        console.log(self.path.toString(), self.plugin.name);\n    };\n});\n// logs: orders.sum orders\n</script>\n```\n\n### $assign:path\n\nType: `config`\n\nWrites the component instance to a path.\n\nExample: Keep a reference to the instance\n```html\n<ui-component name=\"grid\" config=\"$assign:common.grid\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = () => console.log('reloaded');\n});\n\ncommon.grid.reload();\n// logs: reloaded\n</script>\n```\n\n### $class:name\n\nType: `config`\n\nToggles a CSS class on the element when the component is configured.\n\nExample: Add a class once the component is ready\n```html\n<ui-component name=\"panel\" config=\"$class:ready\"></ui-component>\n\n<script>\nCOMPONENT('panel', function(self) {});\n</script>\n```\n\n### $id:value\n\nType: `config`\n\nSets the `id` of the instance.\n\nThe identifier selects the component in `SETTER('#value/method')` and `CONFIG('#value', ...)`.\n\nExample: Call one instance by its identifier\n```html\n<ui-component name=\"tab\" config=\"$id:first\"></ui-component>\n<ui-component name=\"tab\" config=\"$id:second\"></ui-component>\n\n<script>\nCOMPONENT('tab', function(self) {\n    self.open = () => console.log('open', self.id);\n});\n\nSETTER('#second/open');\n// logs: open second\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nCalls a function when the component is configured.\n\nThe function receives the instance. A `?` in the value is replaced with the path of the parent plugin.\n\nExample: Run a function with the instance\n```html\n<ui-component name=\"chart\" config=\"$init:FUNC.chartready\"></ui-component>\n\n<script>\nFUNC.chartready = function(component) {\n    console.log(component.name);\n};\n\nCOMPONENT('chart', function(self) {});\n// logs: chart\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nCalls a function after each change of the value.\n\nThe function receives `value`, `path` and `flags`, the same arguments as the `setter` delegate.\n\nExample: Observe the value from outside\n```html\n<ui-component name=\"input\" path=\"common.name\" config=\"$setter:FUNC.changed\"></ui-component>\n\n<script>\nFUNC.changed = function(value, path) {\n    value && console.log(path, value);\n};\n\nCOMPONENT('input', function(self) {});\n\nSET('common.name', 'Peter');\n// logs: common.name Peter\n</script>\n```\n\n### =key:path\n\nType: `config`\n\nKeeps the config key `key` equal to the value at a path.\n\nThe key is set when the component initializes and on each change at the path. `configure` is called each time.\n\nExample: Drive a config key from the model\n```html\n<ui-component name=\"list\" config=\"=limit:common.limit\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.configure = function(key, value) {\n        key === 'limit' && value && console.log('limit', value);\n    };\n});\n\nSET('common.limit', 50);\n// logs: limit 50\n</script>\n```\n\n### =:path\n\nType: `config`\n\nApplies the object at a path as the configuration.\n\nEach key of the object is set with `reconfigure()` when the component initializes and on each change at the path. The path must contain an object when the component initializes.\n\nExample: Configure a component from an object\n```html\n<ui-component name=\"list\" config=\"=:common.options\"></ui-component>\n\n<script>\nvar common = { options: { limit: 10 } };\n\nCOMPONENT('list', function(self, config) {\n    self.make = () => setTimeout(() => console.log(config.limit), 50);\n});\n// logs: 10\n</script>\n```\n\n### type:name\n\nType: `config`\n\nConverts the value that the component writes with `getter()`.\n\nSupported values are `number`, `currency`, `float`, `boolean`, `bool`, `date` and `datetime`. Any other value leaves the input unchanged.\n\nExample: Store a number\n```html\n<ui-component name=\"amount\" path=\"common.price\" config=\"type:number\"><input /></ui-component>\n\n<script>\nCOMPONENT('amount', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('1 250.5').trigger('change');\nsetTimeout(() => console.log(common.price, typeof(common.price)), 300);\n// logs: 1250.5 number\n</script>\n```\n\n### format:value\n\nType: `config`\n\nThe date format used to parse the input when `type` is `date` or `datetime`.\n\nWithout this key, the format in `DEF.dateformat` is used.\n\nExample: Parse a custom date format\n```html\n<ui-component name=\"date\" path=\"common.date\" config=\"type:date;format:dd.MM.yyyy\"><input /></ui-component>\n\n<script>\nCOMPONENT('date', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('15.01.2024').trigger('change');\nsetTimeout(() => console.log(common.date.format('yyyy-MM-dd')), 300);\n// logs: 2024-01-15\n</script>\n```\n\n### touched:true\n\nType: `config`\n\nMarks the component as touched and sets the `ui-touched` class on the element.\n\n### modified:true\n\nType: `config`\n\nMarks the component as modified and sets the `ui-modified` class on the element.\n\n### invalid:true\n\nType: `config`\n\nMarks the component as invalid and sets the `ui-invalid` class on the element.\n\nThe value is overwritten each time the component validates. When a `validate` delegate returns a string, the key holds that string.\n\n### disabled:true\n\nType: `config`\n\nMarks the component as disabled and sets the `ui-disabled` class on the element.\n\nExample: State classes\n```html\n<ui-component name=\"field\" config=\"disabled:true;touched:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n</script>\n```\n\n### required:true\n\nType: `config`\n\nMarks the component as required.\n\nThe key is set by the `required` command of [ui-bind](../ui-bind/) and is matched by the `@required` flag when components are searched by path. A component reads it in its own code.\n","entries":[{"type":"property","name":"name","signature":"name=\"component\"","since":"","deprecated":false},{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"source","signature":"source=\"URL\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:name","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:value","since":"","deprecated":false},{"type":"config","name":"$init","signature":"$init:path","since":"","deprecated":false},{"type":"config","name":"$setter","signature":"$setter:path","since":"","deprecated":false},{"type":"config","name":"=key","signature":"=key:path","since":"","deprecated":false},{"type":"config","name":"=","signature":"=:path","since":"","deprecated":false},{"type":"config","name":"type","signature":"type:name","since":"","deprecated":false},{"type":"config","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"config","name":"touched","signature":"touched:true","since":"","deprecated":false},{"type":"config","name":"modified","signature":"modified:true","since":"","deprecated":false},{"type":"config","name":"invalid","signature":"invalid:true","since":"","deprecated":false},{"type":"config","name":"disabled","signature":"disabled:true","since":"","deprecated":false},{"type":"config","name":"required","signature":"required:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaEBko61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/ui-component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"ui-component","summary":"Die Attribute und Config-Keys des Elements ui-component.","markdown":"---\ntitle: ui-component\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/ui-component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-component\n\n> Die Attribute und Config-Keys des Elements ui-component.\n\nDas Element `<ui-component>` platziert eine Instanz einer mit `COMPONENT()` deklarierten Komponente auf der Seite. Seine Attribute werden einmal gelesen, wenn das Element erstellt wird. Wie du damit arbeitest, erklärt die Anleitung [Komponenten verwenden](../../guides/using-components/), und die Instanz selbst ist auf der Seite [Komponente](../component/) beschrieben.\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nDer Name der mit `COMPONENT()` deklarierten Komponente. Das Attribut ist erforderlich: Ein Element ohne dieses Attribut wird ignoriert.\n\nGibt es keine Deklaration mit diesem Namen, lädt die Bibliothek eine von der Adresse im Attribut `source` oder von der Adresse in `DEF.fallback` herunter.\n\nEin Name, der mit `LAZY ` beginnt (zum Beispiel `LAZY dialog`), verzögert das Erstellen der Instanz bis zum ersten `SETTER()`-Aufruf für diese Komponente.\n\nExample: Komponente beim ersten SETTER()-Aufruf erstellen\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\nCOMPONENT('dialog', function(self) {\n    console.log('created');\n    self.show = function(title) {\n        console.log('show', title);\n    };\n});\n\n// The instance does not exist yet. This call creates it and then runs show().\nSETTER('dialog/show', 'Hello');\n// logs: created\n// logs: show Hello\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nDer Path des Werts, den die Komponente liest und schreibt.\n\nDer Wert wird an den `setter` der Komponente übergeben, und jede Änderung am Path ruft ihn erneut auf. Ein `?` wird durch den Path des übergeordneten Plugins ersetzt. Ohne dieses Attribut oder mit dem Wert `null` hat die Komponente keinen Path. Siehe [Paths](../../guides/paths/).\n\nExample: Komponente an einen Path binden\n```html\n<ui-component name=\"label\" path=\"common.title\"></ui-component>\n\n<script>\nCOMPONENT('label', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n});\n\nSET('common.title', 'Hello');\nconsole.log($('ui-component').text());\n// logs: Hello\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nDie Konfiguration der Instanz.\n\nSchlüssel und Werte werden durch `:` getrennt, Paare durch `;`. Schreibe `\\;` und `\\:`, um diese Zeichen in einem Wert zu verwenden. Die Werte `true` und `false` werden zu Booleans und numerische Werte zu Zahlen. Alles andere bleibt ein String.\n\nDie Schlüssel des Attributs überschreiben die Standardkonfiguration, die an `COMPONENT()` übergeben wurde.\n\nExample: Konfiguration lesen\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;open:true;note:a\\;b\"></ui-component>\n\n<script>\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n    console.log(JSON.stringify(config));\n});\n// logs: {\"limit\":10,\"color\":\"red\",\"title\":\"Orders\",\"open\":true,\"note\":\"a;b\"}\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nEin JavaScript-Ausdruck, der den Standardwert des Paths liefert.\n\nDer Ausdruck wird ausgewertet, wenn die Komponente initialisiert wird und der Wert am Path `null` oder `undefined` ist. Das Ergebnis wird an den Path geschrieben, ohne den `setter` ein zweites Mal aufzurufen. Der Ausdruck wird erneut ausgewertet, wenn eine Benachrichtigung mit dem Flag `@default` auf einen leeren Wert trifft.\n\nExample: Leeren Path füllen\n```html\n<ui-component name=\"field\" path=\"common.count\" default=\"10\"></ui-component>\n<ui-component name=\"field\" path=\"common.tags\" default=\"['a', 'b']\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nconsole.log(common.count, common.tags.join());\n// logs: 10 a,b\n</script>\n```\n\n### source=\"URL\"\n\nType: `property`\n\nDie Adresse der Deklaration, die verwendet wird, wenn die Komponente nicht auf der Seite deklariert ist.\n\nDer Inhalt an der Adresse wird für alle Elemente mit demselben Namen einmal importiert, und die wartenden Instanzen werden danach erstellt.\n\nExample: Deklaration von deinem eigenen Server laden\n```html\n<ui-component name=\"clock\" source=\"/components/clock.html\"></ui-component>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nErstellt ein Plugin auf dem Element selbst.\n\nDer Wert hat dieselbe Form wie das Attribut `path` von [ui-plugin](../ui-plugin/). Das Plugin wird zuerst erstellt, und ein `?` im Path der Komponente verweist darauf.\n\nExample: Eine Komponente mit eigenem Plugin\n```html\n<ui-component name=\"total\" plugin=\"orders\" path=\"?.sum\"></ui-component>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = function() {\n        exports.set('sum', 25);\n    };\n});\n\nCOMPONENT('total', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n    self.make = function() {\n        console.log(self.path.toString(), self.plugin.name);\n    };\n});\n// logs: orders.sum orders\n</script>\n```\n\n### $assign:path\n\nType: `config`\n\nSchreibt die Instanz der Komponente an einen Path.\n\nExample: Referenz auf die Instanz behalten\n```html\n<ui-component name=\"grid\" config=\"$assign:common.grid\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = () => console.log('reloaded');\n});\n\ncommon.grid.reload();\n// logs: reloaded\n</script>\n```\n\n### $class:name\n\nType: `config`\n\nSchaltet eine CSS-Klasse am Element um, wenn die Komponente konfiguriert ist.\n\nExample: Klasse hinzufügen, sobald die Komponente bereit ist\n```html\n<ui-component name=\"panel\" config=\"$class:ready\"></ui-component>\n\n<script>\nCOMPONENT('panel', function(self) {});\n</script>\n```\n\n### $id:value\n\nType: `config`\n\nSetzt die `id` der Instanz.\n\nDer Bezeichner wählt die Komponente in `SETTER('#value/method')` und `CONFIG('#value', ...)` aus.\n\nExample: Eine Instanz über ihren Bezeichner aufrufen\n```html\n<ui-component name=\"tab\" config=\"$id:first\"></ui-component>\n<ui-component name=\"tab\" config=\"$id:second\"></ui-component>\n\n<script>\nCOMPONENT('tab', function(self) {\n    self.open = () => console.log('open', self.id);\n});\n\nSETTER('#second/open');\n// logs: open second\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nRuft eine Funktion auf, wenn die Komponente konfiguriert ist.\n\nDie Funktion erhält die Instanz. Ein `?` im Wert wird durch den Path des übergeordneten Plugins ersetzt.\n\nExample: Funktion mit der Instanz ausführen\n```html\n<ui-component name=\"chart\" config=\"$init:FUNC.chartready\"></ui-component>\n\n<script>\nFUNC.chartready = function(component) {\n    console.log(component.name);\n};\n\nCOMPONENT('chart', function(self) {});\n// logs: chart\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nRuft nach jeder Änderung des Werts eine Funktion auf.\n\nDie Funktion erhält `value`, `path` und `flags`, also dieselben Argumente wie das Delegate `setter`.\n\nExample: Wert von außen beobachten\n```html\n<ui-component name=\"input\" path=\"common.name\" config=\"$setter:FUNC.changed\"></ui-component>\n\n<script>\nFUNC.changed = function(value, path) {\n    value && console.log(path, value);\n};\n\nCOMPONENT('input', function(self) {});\n\nSET('common.name', 'Peter');\n// logs: common.name Peter\n</script>\n```\n\n### =key:path\n\nType: `config`\n\nHält den Config-Key `key` gleich dem Wert an einem Path.\n\nDer Schlüssel wird gesetzt, wenn die Komponente initialisiert wird, und bei jeder Änderung am Path. `configure` wird jedes Mal aufgerufen.\n\nExample: Config-Key aus dem Modell steuern\n```html\n<ui-component name=\"list\" config=\"=limit:common.limit\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.configure = function(key, value) {\n        key === 'limit' && value && console.log('limit', value);\n    };\n});\n\nSET('common.limit', 50);\n// logs: limit 50\n</script>\n```\n\n### =:path\n\nType: `config`\n\nWendet das Objekt an einem Path als Konfiguration an.\n\nJeder Schlüssel des Objekts wird mit `reconfigure()` gesetzt, wenn die Komponente initialisiert wird, und bei jeder Änderung am Path. Der Path muss beim Initialisieren der Komponente ein Objekt enthalten.\n\nExample: Komponente aus einem Objekt konfigurieren\n```html\n<ui-component name=\"list\" config=\"=:common.options\"></ui-component>\n\n<script>\nvar common = { options: { limit: 10 } };\n\nCOMPONENT('list', function(self, config) {\n    self.make = () => setTimeout(() => console.log(config.limit), 50);\n});\n// logs: 10\n</script>\n```\n\n### type:name\n\nType: `config`\n\nWandelt den Wert um, den die Komponente mit `getter()` schreibt.\n\nUnterstützte Werte sind `number`, `currency`, `float`, `boolean`, `bool`, `date` und `datetime`. Jeder andere Wert lässt die Eingabe unverändert.\n\nExample: Zahl speichern\n```html\n<ui-component name=\"amount\" path=\"common.price\" config=\"type:number\"><input /></ui-component>\n\n<script>\nCOMPONENT('amount', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('1 250.5').trigger('change');\nsetTimeout(() => console.log(common.price, typeof(common.price)), 300);\n// logs: 1250.5 number\n</script>\n```\n\n### format:value\n\nType: `config`\n\nDas Datumsformat zum Parsen der Eingabe, wenn `type` den Wert `date` oder `datetime` hat.\n\nOhne diesen Schlüssel wird das Format aus `DEF.dateformat` verwendet.\n\nExample: Eigenes Datumsformat parsen\n```html\n<ui-component name=\"date\" path=\"common.date\" config=\"type:date;format:dd.MM.yyyy\"><input /></ui-component>\n\n<script>\nCOMPONENT('date', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('15.01.2024').trigger('change');\nsetTimeout(() => console.log(common.date.format('yyyy-MM-dd')), 300);\n// logs: 2024-01-15\n</script>\n```\n\n### touched:true\n\nType: `config`\n\nMarkiert die Komponente als berührt und setzt die Klasse `ui-touched` am Element.\n\n### modified:true\n\nType: `config`\n\nMarkiert die Komponente als geändert und setzt die Klasse `ui-modified` am Element.\n\n### invalid:true\n\nType: `config`\n\nMarkiert die Komponente als ungültig und setzt die Klasse `ui-invalid` am Element.\n\nDer Wert wird bei jeder Validierung der Komponente überschrieben. Gibt ein `validate`-Delegate einen String zurück, enthält der Schlüssel diesen String.\n\n### disabled:true\n\nType: `config`\n\nMarkiert die Komponente als deaktiviert und setzt die Klasse `ui-disabled` am Element.\n\nExample: Zustandsklassen\n```html\n<ui-component name=\"field\" config=\"disabled:true;touched:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n</script>\n```\n\n### required:true\n\nType: `config`\n\nMarkiert die Komponente als erforderlich.\n\nDer Schlüssel wird vom Befehl `required` von [ui-bind](../ui-bind/) gesetzt und vom Flag `@required` erfasst, wenn Komponenten nach Path gesucht werden. Eine Komponente liest ihn in ihrem eigenen Code.\n","entries":[{"type":"property","name":"name","signature":"name=\"component\"","since":"","deprecated":false},{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"source","signature":"source=\"URL\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:name","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:value","since":"","deprecated":false},{"type":"config","name":"$init","signature":"$init:path","since":"","deprecated":false},{"type":"config","name":"$setter","signature":"$setter:path","since":"","deprecated":false},{"type":"config","name":"=key","signature":"=key:path","since":"","deprecated":false},{"type":"config","name":"=","signature":"=:path","since":"","deprecated":false},{"type":"config","name":"type","signature":"type:name","since":"","deprecated":false},{"type":"config","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"config","name":"touched","signature":"touched:true","since":"","deprecated":false},{"type":"config","name":"modified","signature":"modified:true","since":"","deprecated":false},{"type":"config","name":"invalid","signature":"invalid:true","since":"","deprecated":false},{"type":"config","name":"disabled","signature":"disabled:true","since":"","deprecated":false},{"type":"config","name":"required","signature":"required:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaEBko61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/ui-component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"ui-component","summary":"Los atributos y las claves de configuración del elemento ui-component.","markdown":"---\ntitle: ui-component\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/ui-component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-component\n\n> Los atributos y las claves de configuración del elemento ui-component.\n\nEl elemento `<ui-component>` coloca en la página una instancia de un componente declarado con `COMPONENT()`. Sus atributos se leen una vez, cuando se crea el elemento. La guía [Usar componentes](../../guides/using-components/) explica cómo trabajar con él, y la propia instancia se describe en la página [Component](../component/).\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nEl nombre del componente declarado con `COMPONENT()`. El atributo es obligatorio: un elemento sin él se ignora.\n\nCuando no existe ninguna declaración con este nombre, la biblioteca descarga una desde la dirección del atributo `source` o desde la dirección de `DEF.fallback`.\n\nUn nombre que empieza por `LAZY ` (por ejemplo `LAZY dialog`) retrasa la creación de la instancia hasta la primera llamada a `SETTER()` para ese componente.\n\nExample: Crear un componente en la primera llamada a SETTER()\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\nCOMPONENT('dialog', function(self) {\n    console.log('created');\n    self.show = function(title) {\n        console.log('show', title);\n    };\n});\n\n// The instance does not exist yet. This call creates it and then runs show().\nSETTER('dialog/show', 'Hello');\n// logs: created\n// logs: show Hello\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nEl path del valor que el componente lee y escribe.\n\nEl valor se pasa al `setter` del componente y cada cambio en el path vuelve a llamarlo. Un `?` se sustituye por el path del plugin padre. Sin este atributo, o con el valor `null`, el componente no tiene path. Consulta [Paths](../../guides/paths/).\n\nExample: Enlazar un componente a un path\n```html\n<ui-component name=\"label\" path=\"common.title\"></ui-component>\n\n<script>\nCOMPONENT('label', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n});\n\nSET('common.title', 'Hello');\nconsole.log($('ui-component').text());\n// logs: Hello\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nLa configuración de la instancia.\n\nLas claves y los valores se separan con `:`, y los pares con `;`. Escribe `\\;` y `\\:` para usar estos caracteres en un valor. Los valores `true` y `false` se convierten en booleanos y los valores numéricos en números. Todo lo demás sigue siendo una cadena.\n\nLas claves del atributo sobrescriben la configuración predeterminada que se pasa a `COMPONENT()`.\n\nExample: Leer la configuración\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;open:true;note:a\\;b\"></ui-component>\n\n<script>\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n    console.log(JSON.stringify(config));\n});\n// logs: {\"limit\":10,\"color\":\"red\",\"title\":\"Orders\",\"open\":true,\"note\":\"a;b\"}\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nUna expresión de JavaScript que da el valor predeterminado del path.\n\nLa expresión se evalúa cuando el componente se inicializa y el valor del path es `null` o `undefined`. El resultado se escribe en el path sin llamar al `setter` una segunda vez. Se vuelve a evaluar cuando una notificación con el flag `@default` encuentra un valor vacío.\n\nExample: Rellenar un path vacío\n```html\n<ui-component name=\"field\" path=\"common.count\" default=\"10\"></ui-component>\n<ui-component name=\"field\" path=\"common.tags\" default=\"['a', 'b']\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nconsole.log(common.count, common.tags.join());\n// logs: 10 a,b\n</script>\n```\n\n### source=\"URL\"\n\nType: `property`\n\nLa dirección de la declaración, que se usa cuando el componente no está declarado en la página.\n\nEl contenido de la dirección se importa una sola vez para todos los elementos con el mismo nombre, y las instancias en espera se crean después.\n\nExample: Cargar la declaración desde tu propio servidor\n```html\n<ui-component name=\"clock\" source=\"/components/clock.html\"></ui-component>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea un plugin en el propio elemento.\n\nEl valor tiene la misma forma que el atributo `path` de [ui-plugin](../ui-plugin/). El plugin se crea primero, y un `?` en el path del componente hace referencia a él.\n\nExample: Un componente con su propio plugin\n```html\n<ui-component name=\"total\" plugin=\"orders\" path=\"?.sum\"></ui-component>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = function() {\n        exports.set('sum', 25);\n    };\n});\n\nCOMPONENT('total', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n    self.make = function() {\n        console.log(self.path.toString(), self.plugin.name);\n    };\n});\n// logs: orders.sum orders\n</script>\n```\n\n### $assign:path\n\nType: `config`\n\nEscribe la instancia del componente en un path.\n\nExample: Conservar una referencia a la instancia\n```html\n<ui-component name=\"grid\" config=\"$assign:common.grid\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = () => console.log('reloaded');\n});\n\ncommon.grid.reload();\n// logs: reloaded\n</script>\n```\n\n### $class:name\n\nType: `config`\n\nAlterna una clase CSS en el elemento cuando el componente está configurado.\n\nExample: Añadir una clase cuando el componente esté listo\n```html\n<ui-component name=\"panel\" config=\"$class:ready\"></ui-component>\n\n<script>\nCOMPONENT('panel', function(self) {});\n</script>\n```\n\n### $id:value\n\nType: `config`\n\nEstablece el `id` de la instancia.\n\nEl identificador selecciona el componente en `SETTER('#value/method')` y `CONFIG('#value', ...)`.\n\nExample: Llamar a una instancia por su identificador\n```html\n<ui-component name=\"tab\" config=\"$id:first\"></ui-component>\n<ui-component name=\"tab\" config=\"$id:second\"></ui-component>\n\n<script>\nCOMPONENT('tab', function(self) {\n    self.open = () => console.log('open', self.id);\n});\n\nSETTER('#second/open');\n// logs: open second\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nLlama a una función cuando el componente está configurado.\n\nLa función recibe la instancia. Un `?` en el valor se sustituye por el path del plugin padre.\n\nExample: Ejecutar una función con la instancia\n```html\n<ui-component name=\"chart\" config=\"$init:FUNC.chartready\"></ui-component>\n\n<script>\nFUNC.chartready = function(component) {\n    console.log(component.name);\n};\n\nCOMPONENT('chart', function(self) {});\n// logs: chart\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nLlama a una función después de cada cambio del valor.\n\nLa función recibe `value`, `path` y `flags`, los mismos argumentos que el delegate `setter`.\n\nExample: Observar el valor desde fuera\n```html\n<ui-component name=\"input\" path=\"common.name\" config=\"$setter:FUNC.changed\"></ui-component>\n\n<script>\nFUNC.changed = function(value, path) {\n    value && console.log(path, value);\n};\n\nCOMPONENT('input', function(self) {});\n\nSET('common.name', 'Peter');\n// logs: common.name Peter\n</script>\n```\n\n### =key:path\n\nType: `config`\n\nMantiene la clave de configuración `key` igual al valor de un path.\n\nLa clave se establece cuando el componente se inicializa y en cada cambio del path. Cada vez se llama a `configure`.\n\nExample: Controlar una clave de configuración desde el modelo\n```html\n<ui-component name=\"list\" config=\"=limit:common.limit\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.configure = function(key, value) {\n        key === 'limit' && value && console.log('limit', value);\n    };\n});\n\nSET('common.limit', 50);\n// logs: limit 50\n</script>\n```\n\n### =:path\n\nType: `config`\n\nAplica como configuración el objeto de un path.\n\nCada clave del objeto se establece con `reconfigure()` cuando el componente se inicializa y en cada cambio del path. El path debe contener un objeto cuando el componente se inicializa.\n\nExample: Configurar un componente desde un objeto\n```html\n<ui-component name=\"list\" config=\"=:common.options\"></ui-component>\n\n<script>\nvar common = { options: { limit: 10 } };\n\nCOMPONENT('list', function(self, config) {\n    self.make = () => setTimeout(() => console.log(config.limit), 50);\n});\n// logs: 10\n</script>\n```\n\n### type:name\n\nType: `config`\n\nConvierte el valor que el componente escribe con `getter()`.\n\nLos valores admitidos son `number`, `currency`, `float`, `boolean`, `bool`, `date` y `datetime`. Cualquier otro valor deja la entrada sin cambios.\n\nExample: Guardar un número\n```html\n<ui-component name=\"amount\" path=\"common.price\" config=\"type:number\"><input /></ui-component>\n\n<script>\nCOMPONENT('amount', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('1 250.5').trigger('change');\nsetTimeout(() => console.log(common.price, typeof(common.price)), 300);\n// logs: 1250.5 number\n</script>\n```\n\n### format:value\n\nType: `config`\n\nEl formato de fecha que se usa para analizar la entrada cuando `type` es `date` o `datetime`.\n\nSin esta clave, se usa el formato de `DEF.dateformat`.\n\nExample: Analizar un formato de fecha personalizado\n```html\n<ui-component name=\"date\" path=\"common.date\" config=\"type:date;format:dd.MM.yyyy\"><input /></ui-component>\n\n<script>\nCOMPONENT('date', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('15.01.2024').trigger('change');\nsetTimeout(() => console.log(common.date.format('yyyy-MM-dd')), 300);\n// logs: 2024-01-15\n</script>\n```\n\n### touched:true\n\nType: `config`\n\nMarca el componente como tocado y pone la clase `ui-touched` en el elemento.\n\n### modified:true\n\nType: `config`\n\nMarca el componente como modificado y pone la clase `ui-modified` en el elemento.\n\n### invalid:true\n\nType: `config`\n\nMarca el componente como no válido y pone la clase `ui-invalid` en el elemento.\n\nEl valor se sobrescribe cada vez que el componente se valida. Cuando un delegate `validate` devuelve una cadena, la clave guarda esa cadena.\n\n### disabled:true\n\nType: `config`\n\nMarca el componente como desactivado y pone la clase `ui-disabled` en el elemento.\n\nExample: Clases de estado\n```html\n<ui-component name=\"field\" config=\"disabled:true;touched:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n</script>\n```\n\n### required:true\n\nType: `config`\n\nMarca el componente como obligatorio.\n\nLa clave la establece el comando `required` de [ui-bind](../ui-bind/) y coincide con el flag `@required` cuando se buscan componentes por path. Un componente la lee en su propio código.\n","entries":[{"type":"property","name":"name","signature":"name=\"component\"","since":"","deprecated":false},{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"source","signature":"source=\"URL\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:name","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:value","since":"","deprecated":false},{"type":"config","name":"$init","signature":"$init:path","since":"","deprecated":false},{"type":"config","name":"$setter","signature":"$setter:path","since":"","deprecated":false},{"type":"config","name":"=key","signature":"=key:path","since":"","deprecated":false},{"type":"config","name":"=","signature":"=:path","since":"","deprecated":false},{"type":"config","name":"type","signature":"type:name","since":"","deprecated":false},{"type":"config","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"config","name":"touched","signature":"touched:true","since":"","deprecated":false},{"type":"config","name":"modified","signature":"modified:true","since":"","deprecated":false},{"type":"config","name":"invalid","signature":"invalid:true","since":"","deprecated":false},{"type":"config","name":"disabled","signature":"disabled:true","since":"","deprecated":false},{"type":"config","name":"required","signature":"required:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaEBko61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/ui-component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"ui-component","summary":"Les attributs et les clés de configuration de l'élément ui-component.","markdown":"---\ntitle: ui-component\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/ui-component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-component\n\n> Les attributs et les clés de configuration de l'élément ui-component.\n\nL'élément `<ui-component>` place dans la page une instance d'un composant déclaré avec `COMPONENT()`. Ses attributs sont lus une seule fois, à la création de l'élément. Le guide [Utiliser les composants](../../guides/using-components/) explique comment travailler avec lui, et l'instance elle-même est décrite sur la page [Component](../component/).\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nLe nom du composant déclaré avec `COMPONENT()`. L'attribut est obligatoire : un élément qui ne l'a pas est ignoré.\n\nQuand aucune déclaration ne porte ce nom, la bibliothèque en télécharge une depuis l'adresse de l'attribut `source` ou depuis l'adresse de `DEF.fallback`.\n\nUn nom qui commence par `LAZY ` (par exemple `LAZY dialog`) retarde la création de l'instance jusqu'au premier appel de `SETTER()` pour ce composant.\n\nExample: Créer un composant au premier appel de SETTER()\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\nCOMPONENT('dialog', function(self) {\n    console.log('created');\n    self.show = function(title) {\n        console.log('show', title);\n    };\n});\n\n// The instance does not exist yet. This call creates it and then runs show().\nSETTER('dialog/show', 'Hello');\n// logs: created\n// logs: show Hello\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nLe path de la valeur que le composant lit et écrit.\n\nLa valeur est transmise au `setter` du composant et chaque modification du path l'appelle à nouveau. Un `?` est remplacé par le path du plugin parent. Sans cet attribut, ou avec la valeur `null`, le composant n'a pas de path. Voir [Paths](../../guides/paths/).\n\nExample: Lier un composant à un path\n```html\n<ui-component name=\"label\" path=\"common.title\"></ui-component>\n\n<script>\nCOMPONENT('label', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n});\n\nSET('common.title', 'Hello');\nconsole.log($('ui-component').text());\n// logs: Hello\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nLa configuration de l'instance.\n\nLes clés et les valeurs sont séparées par `:`, les paires par `;`. Écris `\\;` et `\\:` pour utiliser ces caractères dans une valeur. Les valeurs `true` et `false` deviennent des booléens et les valeurs numériques des nombres. Tout le reste reste une chaîne.\n\nLes clés de l'attribut remplacent la configuration par défaut fournie à `COMPONENT()`.\n\nExample: Lire la configuration\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;open:true;note:a\\;b\"></ui-component>\n\n<script>\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n    console.log(JSON.stringify(config));\n});\n// logs: {\"limit\":10,\"color\":\"red\",\"title\":\"Orders\",\"open\":true,\"note\":\"a;b\"}\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nUne expression JavaScript qui donne la valeur par défaut du path.\n\nL'expression est évaluée quand le composant s'initialise et que la valeur du path est `null` ou `undefined`. Le résultat est écrit dans le path sans appeler le `setter` une seconde fois. Elle est évaluée à nouveau quand une notification avec le flag `@default` trouve une valeur vide.\n\nExample: Remplir un path vide\n```html\n<ui-component name=\"field\" path=\"common.count\" default=\"10\"></ui-component>\n<ui-component name=\"field\" path=\"common.tags\" default=\"['a', 'b']\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nconsole.log(common.count, common.tags.join());\n// logs: 10 a,b\n</script>\n```\n\n### source=\"URL\"\n\nType: `property`\n\nL'adresse de la déclaration, utilisée quand le composant n'est pas déclaré dans la page.\n\nLe contenu de l'adresse est importé une seule fois pour tous les éléments portant le même nom, puis les instances en attente sont créées.\n\nExample: Charger la déclaration depuis ton propre serveur\n```html\n<ui-component name=\"clock\" source=\"/components/clock.html\"></ui-component>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrée un plugin sur l'élément lui-même.\n\nLa valeur a la même forme que l'attribut `path` de [ui-plugin](../ui-plugin/). Le plugin est créé en premier, et un `?` dans le path du composant y fait référence.\n\nExample: Un composant avec son propre plugin\n```html\n<ui-component name=\"total\" plugin=\"orders\" path=\"?.sum\"></ui-component>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = function() {\n        exports.set('sum', 25);\n    };\n});\n\nCOMPONENT('total', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n    self.make = function() {\n        console.log(self.path.toString(), self.plugin.name);\n    };\n});\n// logs: orders.sum orders\n</script>\n```\n\n### $assign:path\n\nType: `config`\n\nÉcrit l'instance du composant dans un path.\n\nExample: Conserver une référence à l'instance\n```html\n<ui-component name=\"grid\" config=\"$assign:common.grid\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = () => console.log('reloaded');\n});\n\ncommon.grid.reload();\n// logs: reloaded\n</script>\n```\n\n### $class:name\n\nType: `config`\n\nBascule une classe CSS sur l'élément quand le composant est configuré.\n\nExample: Ajouter une classe une fois le composant prêt\n```html\n<ui-component name=\"panel\" config=\"$class:ready\"></ui-component>\n\n<script>\nCOMPONENT('panel', function(self) {});\n</script>\n```\n\n### $id:value\n\nType: `config`\n\nDéfinit l'`id` de l'instance.\n\nL'identifiant sélectionne le composant dans `SETTER('#value/method')` et `CONFIG('#value', ...)`.\n\nExample: Appeler une instance par son identifiant\n```html\n<ui-component name=\"tab\" config=\"$id:first\"></ui-component>\n<ui-component name=\"tab\" config=\"$id:second\"></ui-component>\n\n<script>\nCOMPONENT('tab', function(self) {\n    self.open = () => console.log('open', self.id);\n});\n\nSETTER('#second/open');\n// logs: open second\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nAppelle une fonction quand le composant est configuré.\n\nLa fonction reçoit l'instance. Un `?` dans la valeur est remplacé par le path du plugin parent.\n\nExample: Exécuter une fonction avec l'instance\n```html\n<ui-component name=\"chart\" config=\"$init:FUNC.chartready\"></ui-component>\n\n<script>\nFUNC.chartready = function(component) {\n    console.log(component.name);\n};\n\nCOMPONENT('chart', function(self) {});\n// logs: chart\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nAppelle une fonction après chaque modification de la valeur.\n\nLa fonction reçoit `value`, `path` et `flags`, les mêmes arguments que le delegate `setter`.\n\nExample: Observer la valeur depuis l'extérieur\n```html\n<ui-component name=\"input\" path=\"common.name\" config=\"$setter:FUNC.changed\"></ui-component>\n\n<script>\nFUNC.changed = function(value, path) {\n    value && console.log(path, value);\n};\n\nCOMPONENT('input', function(self) {});\n\nSET('common.name', 'Peter');\n// logs: common.name Peter\n</script>\n```\n\n### =key:path\n\nType: `config`\n\nMaintient la clé de configuration `key` égale à la valeur d'un path.\n\nLa clé est définie quand le composant s'initialise et à chaque modification du path. `configure` est appelé à chaque fois.\n\nExample: Piloter une clé de configuration depuis le modèle de données\n```html\n<ui-component name=\"list\" config=\"=limit:common.limit\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.configure = function(key, value) {\n        key === 'limit' && value && console.log('limit', value);\n    };\n});\n\nSET('common.limit', 50);\n// logs: limit 50\n</script>\n```\n\n### =:path\n\nType: `config`\n\nApplique comme configuration l'objet situé à un path.\n\nChaque clé de l'objet est définie avec `reconfigure()` quand le composant s'initialise et à chaque modification du path. Le path doit contenir un objet quand le composant s'initialise.\n\nExample: Configurer un composant à partir d'un objet\n```html\n<ui-component name=\"list\" config=\"=:common.options\"></ui-component>\n\n<script>\nvar common = { options: { limit: 10 } };\n\nCOMPONENT('list', function(self, config) {\n    self.make = () => setTimeout(() => console.log(config.limit), 50);\n});\n// logs: 10\n</script>\n```\n\n### type:name\n\nType: `config`\n\nConvertit la valeur que le composant écrit avec `getter()`.\n\nLes valeurs prises en charge sont `number`, `currency`, `float`, `boolean`, `bool`, `date` et `datetime`. Toute autre valeur laisse l'entrée inchangée.\n\nExample: Stocker un nombre\n```html\n<ui-component name=\"amount\" path=\"common.price\" config=\"type:number\"><input /></ui-component>\n\n<script>\nCOMPONENT('amount', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('1 250.5').trigger('change');\nsetTimeout(() => console.log(common.price, typeof(common.price)), 300);\n// logs: 1250.5 number\n</script>\n```\n\n### format:value\n\nType: `config`\n\nLe format de date utilisé pour analyser l'entrée quand `type` vaut `date` ou `datetime`.\n\nSans cette clé, le format de `DEF.dateformat` est utilisé.\n\nExample: Analyser un format de date personnalisé\n```html\n<ui-component name=\"date\" path=\"common.date\" config=\"type:date;format:dd.MM.yyyy\"><input /></ui-component>\n\n<script>\nCOMPONENT('date', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('15.01.2024').trigger('change');\nsetTimeout(() => console.log(common.date.format('yyyy-MM-dd')), 300);\n// logs: 2024-01-15\n</script>\n```\n\n### touched:true\n\nType: `config`\n\nMarque le composant comme touché et définit la classe `ui-touched` sur l'élément.\n\n### modified:true\n\nType: `config`\n\nMarque le composant comme modifié et définit la classe `ui-modified` sur l'élément.\n\n### invalid:true\n\nType: `config`\n\nMarque le composant comme invalide et définit la classe `ui-invalid` sur l'élément.\n\nLa valeur est remplacée chaque fois que le composant effectue une validation. Quand un delegate `validate` renvoie une chaîne, la clé contient cette chaîne.\n\n### disabled:true\n\nType: `config`\n\nMarque le composant comme désactivé et définit la classe `ui-disabled` sur l'élément.\n\nExample: Classes d'état\n```html\n<ui-component name=\"field\" config=\"disabled:true;touched:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n</script>\n```\n\n### required:true\n\nType: `config`\n\nMarque le composant comme obligatoire.\n\nLa clé est définie par la commande `required` de [ui-bind](../ui-bind/) et correspond au flag `@required` quand les composants sont recherchés par path. Un composant la lit dans son propre code.\n","entries":[{"type":"property","name":"name","signature":"name=\"component\"","since":"","deprecated":false},{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"source","signature":"source=\"URL\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:name","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:value","since":"","deprecated":false},{"type":"config","name":"$init","signature":"$init:path","since":"","deprecated":false},{"type":"config","name":"$setter","signature":"$setter:path","since":"","deprecated":false},{"type":"config","name":"=key","signature":"=key:path","since":"","deprecated":false},{"type":"config","name":"=","signature":"=:path","since":"","deprecated":false},{"type":"config","name":"type","signature":"type:name","since":"","deprecated":false},{"type":"config","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"config","name":"touched","signature":"touched:true","since":"","deprecated":false},{"type":"config","name":"modified","signature":"modified:true","since":"","deprecated":false},{"type":"config","name":"invalid","signature":"invalid:true","since":"","deprecated":false},{"type":"config","name":"disabled","signature":"disabled:true","since":"","deprecated":false},{"type":"config","name":"required","signature":"required:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaEBko61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/ui-component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"ui-component","summary":"Gli attributi e le chiavi di configurazione dell'elemento ui-component.","markdown":"---\ntitle: ui-component\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/ui-component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-component\n\n> Gli attributi e le chiavi di configurazione dell'elemento ui-component.\n\nL'elemento `<ui-component>` inserisce nella pagina un'istanza di un componente dichiarato con `COMPONENT()`. I suoi attributi vengono letti una sola volta, alla creazione dell'elemento. La guida [Usare i componenti](../../guides/using-components/) spiega come lavorarci, e l'istanza stessa è descritta nella pagina [Componente](../component/).\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nIl nome del componente dichiarato con `COMPONENT()`. L'attributo è obbligatorio: un elemento senza di esso viene ignorato.\n\nQuando non esiste nessuna dichiarazione con questo nome, la libreria ne scarica una dall'indirizzo nell'attributo `source` o dall'indirizzo in `DEF.fallback`.\n\nUn nome che inizia con `LAZY ` (ad esempio `LAZY dialog`) ritarda la creazione dell'istanza fino alla prima chiamata `SETTER()` per quel componente.\n\nExample: Crea un componente alla prima chiamata SETTER()\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\nCOMPONENT('dialog', function(self) {\n    console.log('created');\n    self.show = function(title) {\n        console.log('show', title);\n    };\n});\n\n// The instance does not exist yet. This call creates it and then runs show().\nSETTER('dialog/show', 'Hello');\n// logs: created\n// logs: show Hello\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nIl path del valore che il componente legge e scrive.\n\nIl valore viene passato al `setter` del componente e ogni modifica nel path lo chiama di nuovo. Un `?` viene sostituito con il path del plugin genitore. Senza questo attributo, o con il valore `null`, il componente non ha un path. Vedi [Path](../../guides/paths/).\n\nExample: Associa un componente a un path\n```html\n<ui-component name=\"label\" path=\"common.title\"></ui-component>\n\n<script>\nCOMPONENT('label', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n});\n\nSET('common.title', 'Hello');\nconsole.log($('ui-component').text());\n// logs: Hello\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nLa configurazione dell'istanza.\n\nChiavi e valori sono separati da `:`, le coppie da `;`. Scrivi `\\;` e `\\:` per usare questi caratteri in un valore. I valori `true` e `false` diventano booleani e i valori numerici diventano numeri. Tutto il resto rimane una stringa.\n\nLe chiavi dell'attributo sovrascrivono la configurazione predefinita passata a `COMPONENT()`.\n\nExample: Leggi la configurazione\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;open:true;note:a\\;b\"></ui-component>\n\n<script>\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n    console.log(JSON.stringify(config));\n});\n// logs: {\"limit\":10,\"color\":\"red\",\"title\":\"Orders\",\"open\":true,\"note\":\"a;b\"}\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nUn'espressione JavaScript che fornisce il valore predefinito del path.\n\nL'espressione viene valutata quando il componente si inizializza e il valore nel path è `null` o `undefined`. Il risultato viene scritto nel path senza chiamare il `setter` una seconda volta. Viene valutata di nuovo quando una notifica con il flag `@default` trova un valore vuoto.\n\nExample: Riempi un path vuoto\n```html\n<ui-component name=\"field\" path=\"common.count\" default=\"10\"></ui-component>\n<ui-component name=\"field\" path=\"common.tags\" default=\"['a', 'b']\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nconsole.log(common.count, common.tags.join());\n// logs: 10 a,b\n</script>\n```\n\n### source=\"URL\"\n\nType: `property`\n\nL'indirizzo della dichiarazione, usato quando il componente non è dichiarato nella pagina.\n\nIl contenuto all'indirizzo viene importato una sola volta per tutti gli elementi con lo stesso nome, e le istanze in attesa vengono create subito dopo.\n\nExample: Carica la dichiarazione dal tuo server\n```html\n<ui-component name=\"clock\" source=\"/components/clock.html\"></ui-component>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea un plugin sull'elemento stesso.\n\nIl valore ha la stessa forma dell'attributo `path` di [ui-plugin](../ui-plugin/). Il plugin viene creato per primo, e un `?` nel path del componente fa riferimento a esso.\n\nExample: Un componente con il proprio plugin\n```html\n<ui-component name=\"total\" plugin=\"orders\" path=\"?.sum\"></ui-component>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = function() {\n        exports.set('sum', 25);\n    };\n});\n\nCOMPONENT('total', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n    self.make = function() {\n        console.log(self.path.toString(), self.plugin.name);\n    };\n});\n// logs: orders.sum orders\n</script>\n```\n\n### $assign:path\n\nType: `config`\n\nScrive l'istanza del componente in un path.\n\nExample: Conserva un riferimento all'istanza\n```html\n<ui-component name=\"grid\" config=\"$assign:common.grid\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = () => console.log('reloaded');\n});\n\ncommon.grid.reload();\n// logs: reloaded\n</script>\n```\n\n### $class:name\n\nType: `config`\n\nAttiva o disattiva una classe CSS sull'elemento quando il componente è configurato.\n\nExample: Aggiungi una classe quando il componente è pronto\n```html\n<ui-component name=\"panel\" config=\"$class:ready\"></ui-component>\n\n<script>\nCOMPONENT('panel', function(self) {});\n</script>\n```\n\n### $id:value\n\nType: `config`\n\nImposta l'`id` dell'istanza.\n\nL'identificatore seleziona il componente in `SETTER('#value/method')` e `CONFIG('#value', ...)`.\n\nExample: Chiama un'istanza tramite il suo identificatore\n```html\n<ui-component name=\"tab\" config=\"$id:first\"></ui-component>\n<ui-component name=\"tab\" config=\"$id:second\"></ui-component>\n\n<script>\nCOMPONENT('tab', function(self) {\n    self.open = () => console.log('open', self.id);\n});\n\nSETTER('#second/open');\n// logs: open second\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nChiama una funzione quando il componente è configurato.\n\nLa funzione riceve l'istanza. Un `?` nel valore viene sostituito con il path del plugin genitore.\n\nExample: Esegui una funzione con l'istanza\n```html\n<ui-component name=\"chart\" config=\"$init:FUNC.chartready\"></ui-component>\n\n<script>\nFUNC.chartready = function(component) {\n    console.log(component.name);\n};\n\nCOMPONENT('chart', function(self) {});\n// logs: chart\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nChiama una funzione dopo ogni modifica del valore.\n\nLa funzione riceve `value`, `path` e `flags`, gli stessi argomenti del delegate `setter`.\n\nExample: Osserva il valore dall'esterno\n```html\n<ui-component name=\"input\" path=\"common.name\" config=\"$setter:FUNC.changed\"></ui-component>\n\n<script>\nFUNC.changed = function(value, path) {\n    value && console.log(path, value);\n};\n\nCOMPONENT('input', function(self) {});\n\nSET('common.name', 'Peter');\n// logs: common.name Peter\n</script>\n```\n\n### =key:path\n\nType: `config`\n\nMantiene la chiave di configurazione `key` uguale al valore in un path.\n\nLa chiave viene impostata quando il componente si inizializza e a ogni modifica nel path. `configure` viene chiamato ogni volta.\n\nExample: Controlla una chiave di configurazione dal modello\n```html\n<ui-component name=\"list\" config=\"=limit:common.limit\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.configure = function(key, value) {\n        key === 'limit' && value && console.log('limit', value);\n    };\n});\n\nSET('common.limit', 50);\n// logs: limit 50\n</script>\n```\n\n### =:path\n\nType: `config`\n\nApplica come configurazione l'oggetto presente in un path.\n\nOgni chiave dell'oggetto viene impostata con `reconfigure()` quando il componente si inizializza e a ogni modifica nel path. Il path deve contenere un oggetto quando il componente si inizializza.\n\nExample: Configura un componente da un oggetto\n```html\n<ui-component name=\"list\" config=\"=:common.options\"></ui-component>\n\n<script>\nvar common = { options: { limit: 10 } };\n\nCOMPONENT('list', function(self, config) {\n    self.make = () => setTimeout(() => console.log(config.limit), 50);\n});\n// logs: 10\n</script>\n```\n\n### type:name\n\nType: `config`\n\nConverte il valore che il componente scrive con `getter()`.\n\nI valori supportati sono `number`, `currency`, `float`, `boolean`, `bool`, `date` e `datetime`. Qualsiasi altro valore lascia invariato l'input.\n\nExample: Memorizza un numero\n```html\n<ui-component name=\"amount\" path=\"common.price\" config=\"type:number\"><input /></ui-component>\n\n<script>\nCOMPONENT('amount', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('1 250.5').trigger('change');\nsetTimeout(() => console.log(common.price, typeof(common.price)), 300);\n// logs: 1250.5 number\n</script>\n```\n\n### format:value\n\nType: `config`\n\nIl formato di data usato per analizzare l'input quando `type` è `date` o `datetime`.\n\nSenza questa chiave, viene usato il formato in `DEF.dateformat`.\n\nExample: Analizza un formato di data personalizzato\n```html\n<ui-component name=\"date\" path=\"common.date\" config=\"type:date;format:dd.MM.yyyy\"><input /></ui-component>\n\n<script>\nCOMPONENT('date', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('15.01.2024').trigger('change');\nsetTimeout(() => console.log(common.date.format('yyyy-MM-dd')), 300);\n// logs: 2024-01-15\n</script>\n```\n\n### touched:true\n\nType: `config`\n\nSegna il componente come toccato e imposta la classe `ui-touched` sull'elemento.\n\n### modified:true\n\nType: `config`\n\nSegna il componente come modificato e imposta la classe `ui-modified` sull'elemento.\n\n### invalid:true\n\nType: `config`\n\nSegna il componente come non valido e imposta la classe `ui-invalid` sull'elemento.\n\nIl valore viene sovrascritto ogni volta che il componente esegue la validazione. Quando un delegate `validate` restituisce una stringa, la chiave contiene quella stringa.\n\n### disabled:true\n\nType: `config`\n\nSegna il componente come disabilitato e imposta la classe `ui-disabled` sull'elemento.\n\nExample: Classi di stato\n```html\n<ui-component name=\"field\" config=\"disabled:true;touched:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n</script>\n```\n\n### required:true\n\nType: `config`\n\nSegna il componente come obbligatorio.\n\nLa chiave viene impostata dal comando `required` di [ui-bind](../ui-bind/) e corrisponde al flag `@required` quando i componenti vengono cercati per path. Un componente la legge nel proprio codice.\n","entries":[{"type":"property","name":"name","signature":"name=\"component\"","since":"","deprecated":false},{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"source","signature":"source=\"URL\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:name","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:value","since":"","deprecated":false},{"type":"config","name":"$init","signature":"$init:path","since":"","deprecated":false},{"type":"config","name":"$setter","signature":"$setter:path","since":"","deprecated":false},{"type":"config","name":"=key","signature":"=key:path","since":"","deprecated":false},{"type":"config","name":"=","signature":"=:path","since":"","deprecated":false},{"type":"config","name":"type","signature":"type:name","since":"","deprecated":false},{"type":"config","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"config","name":"touched","signature":"touched:true","since":"","deprecated":false},{"type":"config","name":"modified","signature":"modified:true","since":"","deprecated":false},{"type":"config","name":"invalid","signature":"invalid:true","since":"","deprecated":false},{"type":"config","name":"disabled","signature":"disabled:true","since":"","deprecated":false},{"type":"config","name":"required","signature":"required:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaEBko61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/ui-component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"ui-component","summary":"Atribúty a konfiguračné kľúče elementu ui-component.","markdown":"---\ntitle: ui-component\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/ui-component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-component\n\n> Atribúty a konfiguračné kľúče elementu ui-component.\n\nElement `<ui-component>` umiestni na stránku inštanciu komponentu deklarovaného pomocou `COMPONENT()`. Jeho atribúty sa čítajú raz, pri vytvorení elementu. Ako s ním pracovať, vysvetľuje príručka [Používanie komponentov](../../guides/using-components/) a samotnú inštanciu opisuje stránka [Component](../component/).\n\n## API\n\n### name=\"component\"\n\nType: `property`\n\nNázov komponentu deklarovaného pomocou `COMPONENT()`. Atribút je povinný: element bez neho sa ignoruje.\n\nKeď deklarácia s týmto názvom neexistuje, knižnica ju stiahne z adresy v atribúte `source` alebo z adresy v `DEF.fallback`.\n\nNázov, ktorý sa začína na `LAZY ` (napríklad `LAZY dialog`), odloží vytvorenie inštancie až do prvého volania `SETTER()` pre daný komponent.\n\nExample: Vytvor komponent pri prvom volaní SETTER()\n```html\n<ui-component name=\"LAZY dialog\"></ui-component>\n\n<script>\nCOMPONENT('dialog', function(self) {\n    console.log('created');\n    self.show = function(title) {\n        console.log('show', title);\n    };\n});\n\n// The instance does not exist yet. This call creates it and then runs show().\nSETTER('dialog/show', 'Hello');\n// logs: created\n// logs: show Hello\n</script>\n```\n\n### path=\"path\"\n\nType: `property`\n\nPath hodnoty, ktorú komponent číta a zapisuje.\n\nHodnota sa odovzdá do `setter` komponentu a každá zmena na path ho zavolá znova. Znak `?` sa nahradí path nadradeného pluginu. Bez tohto atribútu alebo s hodnotou `null` komponent nemá path. Pozri [Paths](../../guides/paths/).\n\nExample: Naviaž komponent na path\n```html\n<ui-component name=\"label\" path=\"common.title\"></ui-component>\n\n<script>\nCOMPONENT('label', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n});\n\nSET('common.title', 'Hello');\nconsole.log($('ui-component').text());\n// logs: Hello\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nKonfigurácia inštancie.\n\nKľúče a hodnoty sa oddeľujú znakom `:`, dvojice znakom `;`. Ak chceš tieto znaky použiť v hodnote, zapíš `\\;` a `\\:`. Hodnoty `true` a `false` sa zmenia na booleovské hodnoty a číselné hodnoty na čísla. Všetko ostatné zostáva reťazcom.\n\nKľúče atribútu prepíšu predvolenú konfiguráciu odovzdanú do `COMPONENT()`.\n\nExample: Prečítaj konfiguráciu\n```html\n<ui-component name=\"box\" config=\"title:Orders;limit:10;open:true;note:a\\;b\"></ui-component>\n\n<script>\nCOMPONENT('box', 'limit:5;color:red', function(self, config) {\n    console.log(JSON.stringify(config));\n});\n// logs: {\"limit\":10,\"color\":\"red\",\"title\":\"Orders\",\"open\":true,\"note\":\"a;b\"}\n</script>\n```\n\n### default=\"expression\"\n\nType: `property`\n\nVýraz JavaScriptu, ktorý určuje predvolenú hodnotu path.\n\nVýraz sa vyhodnotí pri inicializácii komponentu, keď je hodnota na path `null` alebo `undefined`. Výsledok sa zapíše na path bez druhého volania `setter`. Znova sa vyhodnotí, keď upozornenie s flagom `@default` nájde prázdnu hodnotu.\n\nExample: Vyplň prázdny path\n```html\n<ui-component name=\"field\" path=\"common.count\" default=\"10\"></ui-component>\n<ui-component name=\"field\" path=\"common.tags\" default=\"['a', 'b']\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nconsole.log(common.count, common.tags.join());\n// logs: 10 a,b\n</script>\n```\n\n### source=\"URL\"\n\nType: `property`\n\nAdresa deklarácie, ktorá sa použije, keď komponent nie je na stránke deklarovaný.\n\nObsah na adrese sa importuje raz pre všetky elementy s rovnakým názvom a čakajúce inštancie sa vytvoria potom.\n\nExample: Načítaj deklaráciu z vlastného servera\n```html\n<ui-component name=\"clock\" source=\"/components/clock.html\"></ui-component>\n```\n\n### plugin=\"path\"\n\nType: `property`\n\nVytvorí plugin priamo na elemente.\n\nHodnota má rovnaký tvar ako atribút `path` elementu [ui-plugin](../ui-plugin/). Plugin sa vytvorí ako prvý a znak `?` v path komponentu odkazuje naň.\n\nExample: Komponent s vlastným pluginom\n```html\n<ui-component name=\"total\" plugin=\"orders\" path=\"?.sum\"></ui-component>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = function() {\n        exports.set('sum', 25);\n    };\n});\n\nCOMPONENT('total', function(self) {\n    self.setter = function(value) {\n        self.text(value);\n    };\n    self.make = function() {\n        console.log(self.path.toString(), self.plugin.name);\n    };\n});\n// logs: orders.sum orders\n</script>\n```\n\n### $assign:path\n\nType: `config`\n\nZapíše inštanciu komponentu na path.\n\nExample: Uchovaj si odkaz na inštanciu\n```html\n<ui-component name=\"grid\" config=\"$assign:common.grid\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = () => console.log('reloaded');\n});\n\ncommon.grid.reload();\n// logs: reloaded\n</script>\n```\n\n### $class:name\n\nType: `config`\n\nPrepne triedu CSS na elemente, keď je komponent nakonfigurovaný.\n\nExample: Pridaj triedu, keď je komponent pripravený\n```html\n<ui-component name=\"panel\" config=\"$class:ready\"></ui-component>\n\n<script>\nCOMPONENT('panel', function(self) {});\n</script>\n```\n\n### $id:value\n\nType: `config`\n\nNastaví `id` inštancie.\n\nIdentifikátor vyberá komponent v `SETTER('#value/method')` a `CONFIG('#value', ...)`.\n\nExample: Zavolaj jednu inštanciu podľa jej identifikátora\n```html\n<ui-component name=\"tab\" config=\"$id:first\"></ui-component>\n<ui-component name=\"tab\" config=\"$id:second\"></ui-component>\n\n<script>\nCOMPONENT('tab', function(self) {\n    self.open = () => console.log('open', self.id);\n});\n\nSETTER('#second/open');\n// logs: open second\n</script>\n```\n\n### $init:path\n\nType: `config`\n\nZavolá funkciu, keď je komponent nakonfigurovaný.\n\nFunkcia dostane inštanciu. Znak `?` v hodnote sa nahradí path nadradeného pluginu.\n\nExample: Spusti funkciu s inštanciou\n```html\n<ui-component name=\"chart\" config=\"$init:FUNC.chartready\"></ui-component>\n\n<script>\nFUNC.chartready = function(component) {\n    console.log(component.name);\n};\n\nCOMPONENT('chart', function(self) {});\n// logs: chart\n</script>\n```\n\n### $setter:path\n\nType: `config`\n\nZavolá funkciu po každej zmene hodnoty.\n\nFunkcia dostane `value`, `path` a `flags`, teda rovnaké argumenty ako delegate `setter`.\n\nExample: Sleduj hodnotu zvonka\n```html\n<ui-component name=\"input\" path=\"common.name\" config=\"$setter:FUNC.changed\"></ui-component>\n\n<script>\nFUNC.changed = function(value, path) {\n    value && console.log(path, value);\n};\n\nCOMPONENT('input', function(self) {});\n\nSET('common.name', 'Peter');\n// logs: common.name Peter\n</script>\n```\n\n### =key:path\n\nType: `config`\n\nUdržiava konfiguračný kľúč `key` rovný hodnote na path.\n\nKľúč sa nastaví pri inicializácii komponentu a pri každej zmene na path. Zakaždým sa zavolá `configure`.\n\nExample: Riaď konfiguračný kľúč z modelu\n```html\n<ui-component name=\"list\" config=\"=limit:common.limit\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.configure = function(key, value) {\n        key === 'limit' && value && console.log('limit', value);\n    };\n});\n\nSET('common.limit', 50);\n// logs: limit 50\n</script>\n```\n\n### =:path\n\nType: `config`\n\nPoužije objekt na path ako konfiguráciu.\n\nKaždý kľúč objektu sa nastaví pomocou `reconfigure()` pri inicializácii komponentu a pri každej zmene na path. Pri inicializácii komponentu musí path obsahovať objekt.\n\nExample: Nakonfiguruj komponent z objektu\n```html\n<ui-component name=\"list\" config=\"=:common.options\"></ui-component>\n\n<script>\nvar common = { options: { limit: 10 } };\n\nCOMPONENT('list', function(self, config) {\n    self.make = () => setTimeout(() => console.log(config.limit), 50);\n});\n// logs: 10\n</script>\n```\n\n### type:name\n\nType: `config`\n\nPrevedie hodnotu, ktorú komponent zapisuje pomocou `getter()`.\n\nPodporované hodnoty sú `number`, `currency`, `float`, `boolean`, `bool`, `date` a `datetime`. Každá iná hodnota ponechá vstup nezmenený.\n\nExample: Ulož číslo\n```html\n<ui-component name=\"amount\" path=\"common.price\" config=\"type:number\"><input /></ui-component>\n\n<script>\nCOMPONENT('amount', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('1 250.5').trigger('change');\nsetTimeout(() => console.log(common.price, typeof(common.price)), 300);\n// logs: 1250.5 number\n</script>\n```\n\n### format:value\n\nType: `config`\n\nFormát dátumu použitý na analýzu vstupu, keď je `type` nastavený na `date` alebo `datetime`.\n\nBez tohto kľúča sa použije formát v `DEF.dateformat`.\n\nExample: Analyzuj vlastný formát dátumu\n```html\n<ui-component name=\"date\" path=\"common.date\" config=\"type:date;format:dd.MM.yyyy\"><input /></ui-component>\n\n<script>\nCOMPONENT('date', function(self) {\n    self.make = () => self.autobind20();\n});\n\n$('input').val('15.01.2024').trigger('change');\nsetTimeout(() => console.log(common.date.format('yyyy-MM-dd')), 300);\n// logs: 2024-01-15\n</script>\n```\n\n### touched:true\n\nType: `config`\n\nOznačí komponent ako dotknutý a nastaví na elemente triedu `ui-touched`.\n\n### modified:true\n\nType: `config`\n\nOznačí komponent ako upravený a nastaví na elemente triedu `ui-modified`.\n\n### invalid:true\n\nType: `config`\n\nOznačí komponent ako neplatný a nastaví na elemente triedu `ui-invalid`.\n\nHodnota sa prepíše pri každej validácii komponentu. Keď delegate `validate` vráti reťazec, kľúč obsahuje tento reťazec.\n\n### disabled:true\n\nType: `config`\n\nOznačí komponent ako zakázaný a nastaví na elemente triedu `ui-disabled`.\n\nExample: Stavové triedy\n```html\n<ui-component name=\"field\" config=\"disabled:true;touched:true\"></ui-component>\n\n<script>\nCOMPONENT('field', function(self) {});\n</script>\n```\n\n### required:true\n\nType: `config`\n\nOznačí komponent ako povinný.\n\nKľúč nastavuje príkaz `required` elementu [ui-bind](../ui-bind/) a zodpovedá mu flag `@required` pri vyhľadávaní komponentov podľa path. Komponent ho číta vo vlastnom kóde.\n","entries":[{"type":"property","name":"name","signature":"name=\"component\"","since":"","deprecated":false},{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"default","signature":"default=\"expression\"","since":"","deprecated":false},{"type":"property","name":"source","signature":"source=\"URL\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"$assign","signature":"$assign:path","since":"","deprecated":false},{"type":"config","name":"$class","signature":"$class:name","since":"","deprecated":false},{"type":"config","name":"$id","signature":"$id:value","since":"","deprecated":false},{"type":"config","name":"$init","signature":"$init:path","since":"","deprecated":false},{"type":"config","name":"$setter","signature":"$setter:path","since":"","deprecated":false},{"type":"config","name":"=key","signature":"=key:path","since":"","deprecated":false},{"type":"config","name":"=","signature":"=:path","since":"","deprecated":false},{"type":"config","name":"type","signature":"type:name","since":"","deprecated":false},{"type":"config","name":"format","signature":"format:value","since":"","deprecated":false},{"type":"config","name":"touched","signature":"touched:true","since":"","deprecated":false},{"type":"config","name":"modified","signature":"modified:true","since":"","deprecated":false},{"type":"config","name":"invalid","signature":"invalid:true","since":"","deprecated":false},{"type":"config","name":"disabled","signature":"disabled:true","since":"","deprecated":false},{"type":"config","name":"required","signature":"required:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcOG2ad61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"Component","summary":"The properties, the methods and the delegates of a component instance.","markdown":"---\ntitle: Component\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Component\n\n> The properties, the methods and the delegates of a component instance.\n\nA component instance is the first argument of the function given to `COMPONENT()`. It is created for each [ui-component](../ui-component/) element. The [Creating components](../../guides/creating-components/) guide shows how the parts work together.\n\n## API\n\n### id\n\nType: `property`\n\nThe identifier of the instance.\n\nReturns: `String` The identifier of the instance.\n\nThe value is generated, and the `$id` config key replaces it.\n\n### ID\n\nType: `property`\n\nThe generated identifier of the instance.\n\nReturns: `String` The generated identifier of the instance.\n\nThe `$id` config key does not change it.\n\n### name\n\nType: `property`\n\nThe name of the component.\n\nReturns: `String` The name of the component.\n\n### path\n\nType: `property`\n\nThe path of the component, or `null` when the element has none.\n\nReturns: `Path` The path of the component, or `null` when the element has none.\n\nSee [Path](../path/).\n\n### config\n\nType: `property`\n\nThe current configuration.\n\nReturns: `Object` The current configuration.\n\nChange it with `reconfigure()`, so that `configure` is called.\n\n### element\n\nType: `property`\n\nThe `<ui-component>` element as a jQuery object.\n\nReturns: `jQuery` The `<ui-component>` element as a jQuery object.\n\n### dom\n\nType: `property`\n\nThe `<ui-component>` element.\n\nReturns: `HTMLElement` The `<ui-component>` element.\n\n### plugin\n\nType: `property`\n\nThe parent plugin, or `null`.\n\nReturns: `Plugin` The parent plugin, or `null`.\n\nSee [Plugin](../plugin/).\n\n### scope\n\nType: `property`\n\nThe object that paths are resolved against, which is `window`.\n\nReturns: `Object` The object that paths are resolved against, which is `window`.\n\n### cls\n\nType: `property`\n\nThe CSS class name of the component, for example `ui-grid`.\n\nReturns: `String` The CSS class name of the component, for example `ui-grid`.\n\nThe class is not added to the element automatically.\n\n### def\n\nType: `property`\n\nA function that returns the value of the `default` attribute. It exists only when the attribute is used.\n\nReturns: `Function` A function that returns the value of the `default` attribute. It exists only when the attribute is used.\n\n### ready\n\nType: `property`\n\nIs `true` once the instance starts to initialize.\n\nReturns: `Boolean` Is `true` once the instance starts to initialize.\n\n### init()\n\nType: `delegate`\n\nRuns once per declaration, for the first instance of the component.\n\nIt runs ahead of `make`. Use it for work shared by all instances.\n\nExample: The order of the delegates\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.init = () => console.log('init');\n    self.make = () => console.log('make');\n    self.configure = key => console.log('configure', key);\n    self.setter = () => console.log('setter');\n    self.done = () => console.log('done');\n});\n// logs: init\n// logs: make\n// logs: setter\n// logs: done\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nRuns when the instance is created.\n\nBuild the content of the element here.\n\n### configure(key, value, init, prev)\n\nType: `delegate`\n\nRuns for each config key when the configuration changes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The config key. |\n| `value` | `Object` | yes |  | The new value. |\n| `init` | `Boolean` | yes |  | `true` during the initialization. |\n| `prev` | `Object` | yes |  | The previous value, or `null` during the initialization. |\n\nIt runs for all keys when the component initializes.\n\nExample: React to a config key\n```html\n<ui-component name=\"demo\" config=\"title:Hello\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.configure = function(key, value, init, prev) {\n        key === 'title' && console.log(value, !!init, prev);\n    };\n    self.make = () => setTimeout(() => self.reconfigure({ title: 'Bye' }), 100);\n});\n// logs: Hello true null\n// logs: Bye false Hello\n</script>\n```\n\n### setter(value, path, flags)\n\nType: `delegate`\n\nReceives each change of the value at the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The current value. |\n| `path` | `String` | yes |  | The path that changed. |\n| `flags` | `Object` | yes |  | The flags of the change, for example `{ init: 1 }`. |\n\nThe default implementation writes the value to the first `input`, `textarea` or `select` inside the element. A checkbox is checked when the value, as text, is `true`, `1`, `on`, `yes` or `ok`. Assign your own function to render the value.\n\nExample: Render the value\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.setter = function(value, path, flags) {\n        console.log(value, path, JSON.stringify(flags));\n    };\n});\n\nSET('common.value @touched', 5);\n// logs: 5 common.value {\"touched\":1}\n</script>\n```\n\n### setter2(value, path, flags)\n\nType: `delegate`\n\nReceives each change of the value, including the changes written with `rewrite()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The current value. |\n| `path` | `String` | yes |  | The path that changed. |\n| `flags` | `Object` | yes |  | The flags of the change. |\n\nExample: See the values that skip the setter\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = value => value && console.log('setter', value);\n    self.setter2 = value => value && console.log('setter2', value);\n});\n\ncom.rewrite(1);\n// logs: setter2 1\n</script>\n```\n\n### getter(value, [realtime])\n\nType: `delegate`\n\nProcesses a value entered by the user and writes it to the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The entered value. |\n| `realtime` | `Boolean` | no | `false` | Writes the value without calling the `setter`. |\n\nThe value goes through the function set with `parser()` and is converted according to the `type` config key. With `realtime`, the value is written without calling the `setter`.\n\nExample: Write a value from code\n```js\ncom.getter('5');\nconsole.log(common.value);\n// logs: 5\n```\n\n### validate(value)\n\nType: `delegate`\n\nDecides whether the value is valid.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value to check. |\n\nReturns: `Boolean` The result of the validation. A string is also accepted.\n\nReturn `true` or an empty string for a valid value. A returned string is stored in `config.invalid` as the message, and any other result sets `config.invalid` to `true`. The method runs after each change of the value.\n\nExample: Require a value\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.validate = value => value ? true : 'The value is required';\n});\n\nconsole.log(com.config.invalid);\n// logs: The value is required\nSET('common.value', 'x');\nconsole.log(com.config.invalid);\n// logs: false\n</script>\n```\n\n### state()\n\nType: `delegate`\n\nRuns when the state of the component changes.\n\nRead the state from `config.touched`, `config.modified`, `config.invalid` and `config.disabled`.\n\nExample: Follow the state\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.state = () => console.log(!!config.touched);\n});\n\ncom.touch();\n// logs: true\n</script>\n```\n\n### state2(component)\n\nType: `delegate`\n\nRuns when another component with the same path reports its state.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | The component that reports the state. |\n\nThe report is made with `validate2()` or with the `notify` flag of `bind()`.\n\nExample: Listen to a sibling\n```html\n<ui-component name=\"a\" path=\"common.value\"></ui-component>\n<ui-component name=\"b\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('a', function(self) {\n    window.com = self;\n});\n\nCOMPONENT('b', function(self) {\n    self.state2 = component => console.log(component.name);\n});\n\ncom.validate2();\n// logs: a\n</script>\n```\n\n### done()\n\nType: `delegate`\n\nRuns at the end of the initialization, when the value is set.\n\n### destroy()\n\nType: `delegate`\n\nRuns when the instance is removed.\n\nIt is called by `remove()`, and by the regular cleanup for elements that left the page. Release timers and global handlers here.\n\nExample: Clean up\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.destroy = () => console.log('destroyed');\n});\n\ncom.remove();\n// logs: destroyed\n</script>\n```\n\n### get()\n\nType: `method`\n\nReads the value at the path of the component.\n\nReturns: `Object` The value, or `null` without a path.\n\nExample: Read the value\n```js\nSET('common.value', 1);\nconsole.log(com.get());\n// logs: 1\n```\n\n### set(value, [flags])\n\nType: `method`\n\nWrites a value to the path and notifies everything bound to it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value to write. |\n| `flags` | `String` | no |  | Flags such as `@touched @modified`. |\n\nExample: Write the value\n```js\ncom.set(5, '@touched');\nconsole.log(common.value);\n// logs: 5\n```\n\n### rewrite(value, [flags])\n\nType: `method`\n\nWrites a value to the path without calling the `setter` of this instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value to write. |\n| `flags` | `String` | no |  | Flags such as `@touched @modified`. |\n\nOther components and watchers are notified.\n\nExample: Write without rendering\n```js\ncom.rewrite(7);\nconsole.log(com.get());\n// logs: 7\n```\n\n### modify(value, [flags])\n\nType: `method`\n\nWrites a value and marks the component as touched and modified.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value to write. |\n| `flags` | `String` | no |  | Flags such as `@touched @modified`. |\n\nExample: Write a value entered by the user\n```js\ncom.modify('x');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### push(value)\n\nType: `method`\n\nAdds a value to the array at the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The value to write. |\n\nAn empty path is initialized with a new array and a single value is wrapped in an array.\n\nExample: Add an item\n```js\ncom.push('a');\ncom.push('b');\nconsole.log(common.value.join());\n// logs: a,b\n```\n\n### upd([flags])\n\nType: `method`\n\nNotifies everything bound to the path, without changing the value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | no |  | Flags such as `@touched @modified`. |\n\nThe method is also available as `update()`.\n\nExample: Announce a change made directly\n```js\ncommon.value = 5;\ncom.upd();\nconsole.log(com.get());\n// logs: 5\n```\n\n### refresh()\n\nType: `method`\n\nCalls the `setter` with the current value.\n\nExample: Render again\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = (value, path, flags) => flags.refresh && console.log('refresh');\n});\n\ncom.refresh();\n// logs: refresh\n</script>\n```\n\n### setPath(path)\n\nType: `method`\n\nChanges the path of the component.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The new path. |\n\nA `?` is replaced with the path of the parent plugin. The `setter` is not called until the next change, so call `refresh()` to render the new value.\n\nExample: Point the component to another value\n```js\ncom.setPath('common.other');\nconsole.log(com.path.toString());\n// logs: common.other\n```\n\n### makepath(path)\n\nType: `method`\n\nReplaces the `?` in a path with the path of the parent plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nReturns: `String` The resulting path.\n\nExample: Resolve a relative path\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => console.log(self.makepath('?.items'));\n});\n// logs: orders.items\n</script>\n```\n\n### bind(flags, [value])\n\nType: `method`\n\nChanges the state of the component and optionally writes a value without calling the `setter`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | The flags. |\n| `value` | `Object` | no |  | The value to write. |\n\nThe flags are separated with a space, a comma or `|`, with or without `@`:\n\n| Flag | Effect |\n| --- | --- |\n| `touched`, `touch` | Marks the component as touched. |\n| `modified`, `changed`, `modify`, `change` | Marks the component as modified. |\n| `reset` | Clears the touched and modified state. |\n| `validate` | Runs the validation. |\n| `notify` | Calls `state2` of the other components with the same path. |\n| `setter` | Calls the `setter`. |\n\nExample: Mark a value as entered by the user\n```js\ncom.bind('@touched @modified', 'x');\nconsole.log(com.get(), com.element.attr('class'));\n// logs: x ui-touched ui-modified\n```\n\n### touch()\n\nType: `method`\n\nMarks the component as touched and runs the validation.\n\nExample: Mark as touched\n```js\ncom.touch();\nconsole.log(com.config.touched);\n// logs: 1\n```\n\n### change()\n\nType: `method`\n\nMarks the component as touched and modified and runs the validation.\n\nExample: Mark as changed\n```js\ncom.change();\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### reset([noemit])\n\nType: `method`\n\nClears the touched and modified state.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noemit` | `Boolean` | no | `false` | Skips the validation. |\n\nThe validation runs unless `noemit` is `true`.\n\nExample: Clear the state\n```js\ncom.change();\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);\n// logs: 0 0\n```\n\n### isInvalid()\n\nType: `method`\n\nTells whether the component is touched and invalid.\n\nReturns: `Boolean` A truthy value when the component is touched and invalid.\n\nExample: Show an error only after the user was here\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.validate = value => !!value;\n});\n\nconsole.log(!!com.isInvalid());\n// logs: false\ncom.touch();\nconsole.log(!!com.isInvalid());\n// logs: true\n</script>\n```\n\n### validate2([value])\n\nType: `method`\n\nRuns the validation and calls `state2` of the other components with the same path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | no |  | The value to validate. The default is the current value. |\n\n### reconfigure(value)\n\nType: `method`\n\nChanges the configuration and calls `configure` for each key.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | The keys to change. |\n\nThe value is an object or a string in the form `key:value;key:value`. It accepts the special keys of the [ui-component](../ui-component/) element, such as `$class` and `=key`.\n\nExample: Change the configuration\n```js\ncom.reconfigure('title:Orders;limit:5');\nconsole.log(com.config.title, com.config.limit);\n// logs: Orders 5\n```\n\n### watchconfig(key, path)\n\nType: `method`\n\nKeeps a config key equal to the value at a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The config key, or `null`. |\n| `path` | `String` | yes |  | The path to observe. |\n\nWith `null` as the key, the object at the path is applied as the configuration.\n\nExample: Follow a value\n```js\ncom.watchconfig('limit', 'common.limit');\nSET('common.limit', 10);\nconsole.log(com.config.limit);\n// logs: 10\n```\n\n### formatter(fn)\n\nType: `method`\n\nSets a function that converts the value for display, or converts a value with it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | A function `(path, value, type, format)` that returns the value to display, or the value to convert. |\n\nReturns: `Object` The converted value, when a value is given.\n\nWith a function as the argument, the default `setter` uses it from then on. With any other value, the method returns the converted value.\n\nExample: Format a price\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.formatter((path, value) => value ? '$' + value : '');\n});\n\nSET('common.value', 7);\nconsole.log($('input').val());\n// logs: $7\n</script>\n```\n\n### parser(fn)\n\nType: `method`\n\nSets a function that converts the entered value for the model, or converts a value with it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | A function `(path, value, type, format)` that returns the value to store, or the value to convert. |\n\nReturns: `Object` The converted value, when a value is given.\n\nWith a function as the argument, `getter()` uses it from then on. With any other value, the method returns the converted value.\n\nExample: Parse a price\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.parser((path, value) => value.replace('$', ''));\n});\n\ncom.getter('$9');\nconsole.log(common.value);\n// logs: 9\n</script>\n```\n\n### autobind20([delay], [realtimebinding])\n\nType: `method`\n\nConnects the `input`, `select` and `textarea` inside the element with the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `200` | The delay in milliseconds. |\n| `realtimebinding` | `Boolean` | no | `false` | Calls the `setter` also while the user types. |\n\nThe value is written after the delay, and the touched and modified states are updated from the user events.\n\nExample: Bind an input\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => self.autobind20(50);\n});\n\n$('input').val('typed').trigger('input');\nsetTimeout(() => console.log(common.value), 200);\n// logs: typed\n</script>\n```\n\n### autofill([enabled])\n\nType: `method`\n\nWrites the values that the browser fills in on its own to the model.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enabled` | `Boolean` | no | `true` | `false` turns the feature off. |\n\nA browser can fill a form with saved data, such as a name or an address, without any input event. One second after the library starts, it reads the first `input`, `textarea` or `select` of each component that calls this method, and a value found there is written to the path with the flags `@change` and `@init`. The parser of the component converts the value first.\n\nIt works with the default `setter`. Components with a `default` attribute, `select` elements and range inputs are skipped. `autofill(false)` turns it off.\n\nExample: Keep a value filled in by the browser\n```html\n<ui-component name=\"login\" path=\"form.email\"><input type=\"email\" /></ui-component>\n\n<script>\nCOMPONENT('login', function(self) {\n    self.autofill();\n});\n\n// the browser fills the input with a saved address\nsetTimeout(() => $('input').val('ann@example.com'), 100);\n\nsetTimeout(() => console.log(GET('form.email')), 1500);\n// logs: ann@example.com\n</script>\n```\n\n### readonly()\n\nType: `method`\n\nTurns the component into a display without `getter`, `setter` and validation.\n\n### blind()\n\nType: `method`\n\nExcludes the component from notifications and from searches by path.\n\n### singleton()\n\nType: `method`\n\nAllows only one instance of the component.\n\nOther `<ui-component>` elements with the same name are removed.\n\nExample: Keep one instance\n```html\n<ui-component name=\"demo\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.singleton();\n});\n\nconsole.log($('ui-component').length);\n// logs: 1\n</script>\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nCalls a function on each change at a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path to observe. |\n| `callback` | `Function` | yes |  | A function `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Calls the function right away with the current value. |\n\nJoin several paths with `+`. With a function as the first argument, the path of the component is observed. A `?` is replaced with the path of the parent plugin.\n\nExample: Observe another path\n```js\ncom.watch('common.user', (value, flags, path) => console.log(value, path));\nSET('common.user', 'Anna');\n// logs: Anna common.user\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nRemoves watchers registered with `watch()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The observed path. |\n| `callback` | `Function` | no |  | The watcher to remove. |\n\nWithout `callback`, all the watchers of the path registered by this component are removed. With a function as the only argument, the watcher of the component path is removed. Join several paths with `+`. A `?` is replaced with the path of the parent plugin.\n\nExample: Stop observing a path\n```js\nvar log = value => console.log('changed', value);\n\ncom.watch('common.count', log);\nSET('common.count', 1);\ncom.unwatch('common.count', log);\nSET('common.count', 2);\n// logs: changed 1\n```\n\n### datasource(path, callback, [init])\n\nType: `method`\n\nObserves a path with data for the component.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path to observe. |\n| `callback` | `Function` | yes |  | A function `(value, flags, path)`. |\n| `init` | `Boolean` | no | `true` | Set `false` to skip the first call. |\n\nReturns: `Component` The instance.\n\nThe function is called with the current value when the component initializes, unless `init` is `false`, and on each change. A new call replaces the data source registered before, and `datasource(null)` removes it.\n\nExample: Render items from a path\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nvar common = { items: ['a'] };\n\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.datasource('common.items', value => console.log(value.join()));\n    };\n});\n\nSET('common.items', ['a', 'b']);\n// logs: a\n// logs: a,b\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nRegisters a handler of a global event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The event name. |\n| `callback` | `Function` | yes |  | The handler. |\n\nJoin several event names with `+`. See [Events](../events/).\n\nExample: Handle an event\n```js\nvar handler = value => console.log(value);\ncom.on('refresh', handler);\nEMIT('refresh', 1);\ncom.off('refresh', handler);\nEMIT('refresh', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nRemoves a handler of a global event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The event name. |\n| `callback` | `Function` | no |  | The handler to remove. |\n\nWithout a callback, all handlers of the event registered on this instance are removed.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nEmits a global event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The event name. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nExample: Emit an event\n```js\nON('saved', value => console.log(value));\ncom.emit('saved', 'ok');\n// logs: ok\n```\n\n### command(name, callback)\n\nType: `method`\n\nRegisters a command of this instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The command name. |\n| `callback` | `Function` | yes |  | The handler. |\n\nExample: Register and run a command\n```js\ncom.command('clear', value => console.log('clear', value));\ncom.CMD('clear', 1);\n// logs: clear 1\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nRuns a command registered on this instance with `command()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The command name. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n| `e` | `Object` | no |  | The fifth argument. |\n\n### GET(path)\n\nType: `method`\n\nReads a value from a path. A `?` is replaced with the path of the parent plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nReturns: `Object` The value.\n\nExample: Work with the model of the plugin\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.SET('?.count', 3);\n        console.log(self.GET('?.count'));\n    };\n});\n// logs: 3\n</script>\n```\n\n### SET(path, value)\n\nType: `method`\n\nWrites a value to a path and notifies everything bound to it. A `?` is replaced with the path of the parent plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n| `value` | `Object` | yes |  | The value to write. |\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a function or a plugin method.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | For example `FUNC.save`, `?/save` or `@save`. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nA `?` is replaced with the path of the parent plugin. A name that starts with `@` calls a method of the closest parent component.\n\nExample: Call a method of the parent component\n```html\n<ui-component name=\"parent\">\n    <ui-component name=\"child\"></ui-component>\n</ui-component>\n\n<script>\nCOMPONENT('parent', function(self) {\n    self.refreshlist = value => console.log('parent', value);\n});\n\nCOMPONENT('child', function(self) {\n    window.com = self;\n});\n\ncom.EXEC('@refreshlist', 1);\n// logs: parent 1\n</script>\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a plugin method or a global function, or writes the first argument to the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The method, the function or the path. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nThe form `plugin/method` calls a method of the plugin and a name of a global function calls that function. Any other name is a path that receives `a`.\n\nExample: Write to a path\n```js\ncom.SEEX('common.status', 'done');\nconsole.log(common.status);\n// logs: done\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a method of components in the whole page, in the form `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The target, for example `grid/refresh`. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nExample: Call a method of another component\n```html\n<ui-component name=\"grid\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.SETTER('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### find(selector)\n\nType: `method`\n\nFinds elements inside the component.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | A selector, or an object with selectors. |\n\nReturns: `jQuery` The found elements, or an object of them.\n\nWith an object, the method searches for each selector and returns an object with the same keys.\n\nExample: Find elements\n```html\n<ui-component name=\"demo\"><input /><b></b></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\nconsole.log(com.find('input').length, com.find({ title: 'b' }).title.length);\n// logs: 1 1\n</script>\n```\n\n### closest(selector)\n\nType: `method`\n\nFinds the closest parent that matches a selector.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | A jQuery selector. |\n\nReturns: `jQuery` The found element.\n\nExample: Find a parent\n```js\nconsole.log(com.closest('body')[0].tagName);\n// logs: BODY\n```\n\n### parent([selector])\n\nType: `method`\n\nFinds a parent element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | The selector. |\n\nReturns: `jQuery` The found element.\n\nWithout an argument, the method returns the direct parent. These values are also supported:\n\n| Selector | Result |\n| --- | --- |\n| `auto` | The closest parent with a height set in its style, or `window` |\n| `window` | The `window` object as jQuery |\n| `document` | The `document` as jQuery |\n| `parent` followed by a number | The parent that many levels above the direct parent |\n| anything else | The closest parent that matches the selector |\n\nExample: Read the direct parent\n```js\nconsole.log(com.parent()[0].tagName);\n// logs: BODY\n```\n\n### html([value])\n\nType: `method`\n\nReads or replaces the HTML of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | The new content. |\n\nReturns: `jQuery` The element, or the current HTML without an argument.\n\nAn array is joined into one string.\n\nExample: Set the content\n```js\ncom.html(['<b>', 'Hello', '</b>']);\nconsole.log(com.html());\n// logs: <b>Hello</b>\n```\n\n### text([value])\n\nType: `method`\n\nReads or replaces the text of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | The new text. |\n\nReturns: `jQuery` The element, or the current text without an argument.\n\nAn array is joined into one string.\n\nExample: Set the text\n```js\ncom.text('Hello');\nconsole.log(com.text());\n// logs: Hello\n```\n\n### append(value)\n\nType: `method`\n\nAdds HTML to the end of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | The content. |\n\nReturns: `jQuery` The element.\n\nAn array is joined into one string.\n\nExample: Add content\n```js\ncom.append('<i></i>');\ncom.append(['<b>', '</b>']);\nconsole.log(com.html());\n// logs: <i></i><b></b>\n```\n\n### empty()\n\nType: `method`\n\nRemoves the content of the element.\n\nReturns: `Component` The instance.\n\n### attr(name, [value])\n\nType: `method`\n\nReads or sets an attribute of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The attribute. |\n| `value` | `String` | no |  | The new value. |\n\nReturns: `Object` The value when reading, the instance when setting.\n\nExample: Attributes\n```js\ncom.attr('title', 'Hello');\ncom.attrd('id', 5);\nconsole.log(com.attr('title'), com.attrd('id'));\n// logs: Hello 5\n```\n\n### attrd(name, [value])\n\nType: `method`\n\nReads or sets a `data-` attribute of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name without the `data-` prefix. |\n| `value` | `String` | no |  | The new value. |\n\nReturns: `String` The value when reading.\n\n### css(name, [value])\n\nType: `method`\n\nReads or sets a CSS property of the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The property. |\n| `value` | `String` | no |  | The new value. |\n\nReturns: `Object` The value when reading, the instance when setting.\n\nExample: Change a style\n```js\ncom.css('color', 'red');\nconsole.log(com.css('color'));\n// logs: rgb(255, 0, 0)\n```\n\n### aclass(name, [timeout])\n\nType: `method`\n\nAdds a CSS class to the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The class. |\n| `timeout` | `Number` | no |  | A delay in milliseconds. |\n\nReturns: `Component` The instance.\n\nExample: Work with classes\n```js\ncom.aclass('a b');\ncom.rclass('a');\ncom.tclass('c');\nconsole.log(com.element.attr('class'), com.hclass('c'));\n// logs: b c true\n```\n\n### rclass([name], [timeout])\n\nType: `method`\n\nRemoves a CSS class from the element, or all classes without an argument.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | The class. |\n| `timeout` | `Number` | no |  | A delay in milliseconds. |\n\nReturns: `Component` The instance.\n\n### rclass2(search)\n\nType: `method`\n\nRemoves all CSS classes that contain a text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String` | yes |  | The text to search for. |\n\nReturns: `Component` The instance.\n\nExample: Remove a group of classes\n```js\ncom.aclass('size-1 size-2 box');\ncom.rclass2('size-');\nconsole.log(com.element.attr('class'));\n// logs: box\n```\n\n### tclass(name, [enable])\n\nType: `method`\n\nToggles a CSS class on the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The class. |\n| `enable` | `Boolean` | no |  | Forces the state of the class. |\n\nReturns: `Component` The instance.\n\n### hclass(name)\n\nType: `method`\n\nTells whether the element has a CSS class.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The class. |\n\nReturns: `Boolean` `true` when the class is present.\n\n### width()\n\nType: `method`\n\nReturns the width of the element in pixels.\n\nReturns: `Number` The width.\n\n### height()\n\nType: `method`\n\nReturns the height of the element in pixels.\n\nReturns: `Number` The height.\n\n### event(name, [selector], callback)\n\nType: `method`\n\nRegisters a DOM event handler on the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The DOM event. |\n| `selector` | `String` | no |  | Limits the event to matching children. |\n| `callback` | `Function` | yes |  | The handler. |\n\nReturns: `Component` The instance.\n\nThe arguments are passed to the jQuery `.on()` method.\n\nExample: Handle a click\n```html\n<ui-component name=\"demo\"><button>Save</button></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.event('click', 'button', () => console.log('clicked'));\n    };\n});\n\n$('button').trigger('click');\n// logs: clicked\n</script>\n```\n\n### autofocus([selector])\n\nType: `method`\n\nMoves the focus to the first visible control inside the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | The elements to focus. |\n\nReturns: `Component` The instance.\n\nThe default selector is `input,select,textarea`. When no control can take the focus yet, the method tries again every 200 milliseconds, 15 times at most. The focus is not moved on mobile devices.\n\nExample: Focus the first input\n```html\n<ui-component name=\"demo\"><input id=\"first\" /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.autofocus();\nconsole.log(document.activeElement.id);\n// logs: first\n</script>\n```\n\n### import(url, [callback], [prepare])\n\nType: `method`\n\nDownloads content and appends it to the element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The address. |\n| `callback` | `Function` | no |  | Runs when the content is in the page. |\n| `prepare` | `Function` | no |  | A function `(html)` that returns the content to insert. |\n\nSee `IMPORT()` in [Importing content](../../guides/importing/).\n\nExample: Import a part\n```js\ncom.import('/parts/help.html', () => console.log(com.html()), html => html + '<hr>');\n// logs: <p>Help</p><hr>\n```\n\n### replace(target, [remove])\n\nType: `method`\n\nMoves the component to another element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Element` | yes |  | The new element, as a selector, a DOM element or jQuery. |\n| `remove` | `Boolean` | no | `false` | Removes the original element. |\n\nReturns: `Component` The instance.\n\nWith `remove`, the original element is removed from the page.\n\nExample: Move the component\n```js\ncom.replace('#box', true);\nconsole.log(com.dom.id, $('ui-component').length);\n// logs: box 0\n```\n\n### remove()\n\nType: `method`\n\nCalls `destroy` and removes the component and its element.\n\n### icon(value)\n\nType: `method`\n\nAdds the icon prefix in `DEF.iconprefix` to an icon name.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | The icon name. |\n\nReturns: `String` The CSS classes of the icon.\n\nA value with a space already contains its prefix and stays unchanged.\n\nExample: Build icon classes\n```js\nconsole.log(com.icon('home'));\n// logs: ti ti-home\nconsole.log(com.icon('fa fa-home'));\n// logs: fa fa-home\n```\n\n### caniuse(name)\n\nType: `method`\n\nFinds the first declared component in a list of names separated with a comma or `|`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The names. |\n\nReturns: `String` The found name, or `false`.\n\nExample: Choose an available component\n```js\nconsole.log(com.caniuse('missing,demo'));\n// logs: demo\nconsole.log(com.caniuse('missing|demo'));\n// logs: demo\nconsole.log(com.caniuse('missing'));\n// logs: false\n```\n\n### parseSource(value)\n\nType: `method`\n\nParses a list in the form `id|name|icon,id|name|icon`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | The list. |\n\nReturns: `Array` Objects with `id`, `name` and `icon`.\n\nThe method is also available as `parsesource()`. When the `type` config key is `number`, the identifiers are converted to numbers.\n\nExample: Parse a list\n```js\nvar items = com.parseSource('1|One,2|Two|home');\nconsole.log(JSON.stringify(items[1]));\n// logs: {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n","entries":[{"type":"property","name":"id","signature":"id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"ID","since":"","deprecated":false},{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"def","signature":"def","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"delegate","name":"init()","signature":"init()","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"configure()","signature":"configure(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter()","signature":"setter(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"setter2()","signature":"setter2(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"getter()","signature":"getter(value, [realtime])","since":"","deprecated":false},{"type":"delegate","name":"validate()","signature":"validate(value)","since":"","deprecated":false},{"type":"delegate","name":"state()","signature":"state()","since":"","deprecated":false},{"type":"delegate","name":"state2()","signature":"state2(component)","since":"","deprecated":false},{"type":"delegate","name":"done()","signature":"done()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(value, [flags])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"rewrite(value, [flags])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"modify(value, [flags])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(value)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd([flags])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"refresh()","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"setPath(path)","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"touch()","signature":"touch()","since":"","deprecated":false},{"type":"method","name":"change()","signature":"change()","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"reset([noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"validate2([value])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"reconfigure(value)","since":"","deprecated":false},{"type":"method","name":"watchconfig()","signature":"watchconfig(key, path)","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"formatter(fn)","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"parser(fn)","since":"","deprecated":false},{"type":"method","name":"autobind20()","signature":"autobind20([delay], [realtimebinding])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"autofill([enabled])","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"readonly()","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"blind()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"singleton()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"empty()","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"css()","signature":"css(name, [value])","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"aclass(name, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"rclass([name], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"tclass(name, [enable])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"hclass(name)","since":"","deprecated":false},{"type":"method","name":"width()","signature":"width()","since":"","deprecated":false},{"type":"method","name":"height()","signature":"height()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"import(url, [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"replace(target, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"remove()","since":"","deprecated":false},{"type":"method","name":"icon()","signature":"icon(value)","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"caniuse(name)","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"parseSource(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcOG2ad61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"Komponente","summary":"Die Eigenschaften, Methoden und Delegates einer Komponenteninstanz.","markdown":"---\ntitle: Komponente\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Komponente\n\n> Die Eigenschaften, Methoden und Delegates einer Komponenteninstanz.\n\nEine Komponenteninstanz ist das erste Argument der Funktion, die an `COMPONENT()` übergeben wird. Für jedes Element [ui-component](../ui-component/) wird eine Instanz erstellt. Die Anleitung [Komponenten erstellen](../../guides/creating-components/) zeigt, wie die Teile zusammenspielen.\n\n## API\n\n### id\n\nType: `property`\n\nDer Bezeichner der Instanz.\n\nReturns: `String` Der Bezeichner der Instanz.\n\nDer Wert wird generiert, und der Config-Key `$id` ersetzt ihn.\n\n### ID\n\nType: `property`\n\nDer generierte Bezeichner der Instanz.\n\nReturns: `String` Der generierte Bezeichner der Instanz.\n\nDer Config-Key `$id` ändert ihn nicht.\n\n### name\n\nType: `property`\n\nDer Name der Komponente.\n\nReturns: `String` Der Name der Komponente.\n\n### path\n\nType: `property`\n\nDer Path der Komponente oder `null`, wenn das Element keinen hat.\n\nReturns: `Path` Der Path der Komponente oder `null`, wenn das Element keinen hat.\n\nSiehe [Path](../path/).\n\n### config\n\nType: `property`\n\nDie aktuelle Konfiguration.\n\nReturns: `Object` Die aktuelle Konfiguration.\n\nÄndere sie mit `reconfigure()`, damit `configure` aufgerufen wird.\n\n### element\n\nType: `property`\n\nDas Element `<ui-component>` als jQuery-Objekt.\n\nReturns: `jQuery` Das Element `<ui-component>` als jQuery-Objekt.\n\n### dom\n\nType: `property`\n\nDas Element `<ui-component>`.\n\nReturns: `HTMLElement` Das Element `<ui-component>`.\n\n### plugin\n\nType: `property`\n\nDas übergeordnete Plugin oder `null`.\n\nReturns: `Plugin` Das übergeordnete Plugin oder `null`.\n\nSiehe [Plugin](../plugin/).\n\n### scope\n\nType: `property`\n\nDas Objekt, gegen das Paths aufgelöst werden, also `window`.\n\nReturns: `Object` Das Objekt, gegen das Paths aufgelöst werden, also `window`.\n\n### cls\n\nType: `property`\n\nDer CSS-Klassenname der Komponente, zum Beispiel `ui-grid`.\n\nReturns: `String` Der CSS-Klassenname der Komponente, zum Beispiel `ui-grid`.\n\nDie Klasse wird dem Element nicht automatisch hinzugefügt.\n\n### def\n\nType: `property`\n\nEine Funktion, die den Wert des Attributs `default` zurückgibt. Diese Funktion existiert nur, wenn das Attribut verwendet wird.\n\nReturns: `Function` Eine Funktion, die den Wert des Attributs `default` zurückgibt. Diese Funktion existiert nur, wenn das Attribut verwendet wird.\n\n### ready\n\nType: `property`\n\nIst `true`, sobald die Instanz mit der Initialisierung beginnt.\n\nReturns: `Boolean` Ist `true`, sobald die Instanz mit der Initialisierung beginnt.\n\n### init()\n\nType: `delegate`\n\nWird einmal pro Deklaration ausgeführt, für die erste Instanz der Komponente.\n\nLäuft vor `make`. Nutze es für Arbeit, die alle Instanzen teilen.\n\nExample: Die Reihenfolge der Delegates\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.init = () => console.log('init');\n    self.make = () => console.log('make');\n    self.configure = key => console.log('configure', key);\n    self.setter = () => console.log('setter');\n    self.done = () => console.log('done');\n});\n// logs: init\n// logs: make\n// logs: setter\n// logs: done\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nWird ausgeführt, wenn die Instanz erstellt wird.\n\nBaue hier den Inhalt des Elements auf.\n\n### configure(key, value, init, prev)\n\nType: `delegate`\n\nWird für jeden Config-Key ausgeführt, wenn sich die Konfiguration ändert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Config-Key. |\n| `value` | `Object` | yes |  | Der neue Wert. |\n| `init` | `Boolean` | yes |  | `true` während der Initialisierung. |\n| `prev` | `Object` | yes |  | Der vorherige Wert oder `null` während der Initialisierung. |\n\nLäuft beim Initialisieren der Komponente für alle Schlüssel.\n\nExample: Auf einen Config-Key reagieren\n```html\n<ui-component name=\"demo\" config=\"title:Hello\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.configure = function(key, value, init, prev) {\n        key === 'title' && console.log(value, !!init, prev);\n    };\n    self.make = () => setTimeout(() => self.reconfigure({ title: 'Bye' }), 100);\n});\n// logs: Hello true null\n// logs: Bye false Hello\n</script>\n```\n\n### setter(value, path, flags)\n\nType: `delegate`\n\nErhält jede Änderung des Werts am Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der aktuelle Wert. |\n| `path` | `String` | yes |  | Der Path, der sich geändert hat. |\n| `flags` | `Object` | yes |  | Die Flags der Änderung, zum Beispiel `{ init: 1 }`. |\n\nDie Standardimplementierung schreibt den Wert in das erste `input`, `textarea` oder `select` innerhalb des Elements. Eine Checkbox wird angehakt, wenn der Wert als Text `true`, `1`, `on`, `yes` oder `ok` ist. Weise eine eigene Funktion zu, um den Wert zu rendern.\n\nExample: Wert rendern\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.setter = function(value, path, flags) {\n        console.log(value, path, JSON.stringify(flags));\n    };\n});\n\nSET('common.value @touched', 5);\n// logs: 5 common.value {\"touched\":1}\n</script>\n```\n\n### setter2(value, path, flags)\n\nType: `delegate`\n\nErhält jede Änderung des Werts, auch die mit `rewrite()` geschriebenen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der aktuelle Wert. |\n| `path` | `String` | yes |  | Der Path, der sich geändert hat. |\n| `flags` | `Object` | yes |  | Die Flags der Änderung. |\n\nExample: Werte sehen, die den Setter überspringen\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = value => value && console.log('setter', value);\n    self.setter2 = value => value && console.log('setter2', value);\n});\n\ncom.rewrite(1);\n// logs: setter2 1\n</script>\n```\n\n### getter(value, [realtime])\n\nType: `delegate`\n\nVerarbeitet einen vom Benutzer eingegebenen Wert und schreibt ihn an den Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der eingegebene Wert. |\n| `realtime` | `Boolean` | no | `false` | Schreibt den Wert, ohne den `setter` aufzurufen. |\n\nDer Wert durchläuft die mit `parser()` gesetzte Funktion und wird gemäß dem Config-Key `type` umgewandelt. Mit `realtime` wird der Wert geschrieben, ohne den `setter` aufzurufen.\n\nExample: Wert per Code schreiben\n```js\ncom.getter('5');\nconsole.log(common.value);\n// logs: 5\n```\n\n### validate(value)\n\nType: `delegate`\n\nEntscheidet, ob der Wert gültig ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der zu prüfende Wert. |\n\nReturns: `Boolean` Das Ergebnis der Validierung. Auch ein String wird akzeptiert.\n\nGib für einen gültigen Wert `true` oder einen leeren String zurück. Ein zurückgegebener String wird als Meldung in `config.invalid` gespeichert, jedes andere Ergebnis setzt `config.invalid` auf `true`. Die Methode wird nach jeder Änderung des Werts ausgeführt.\n\nExample: Wert verlangen\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.validate = value => value ? true : 'The value is required';\n});\n\nconsole.log(com.config.invalid);\n// logs: The value is required\nSET('common.value', 'x');\nconsole.log(com.config.invalid);\n// logs: false\n</script>\n```\n\n### state()\n\nType: `delegate`\n\nWird ausgeführt, wenn sich der Zustand der Komponente ändert.\n\nLies den Zustand aus `config.touched`, `config.modified`, `config.invalid` und `config.disabled`.\n\nExample: Zustand verfolgen\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.state = () => console.log(!!config.touched);\n});\n\ncom.touch();\n// logs: true\n</script>\n```\n\n### state2(component)\n\nType: `delegate`\n\nWird ausgeführt, wenn eine andere Komponente mit demselben Path ihren Zustand meldet.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Die Komponente, die den Zustand meldet. |\n\nDie Meldung erfolgt mit `validate2()` oder mit dem Flag `notify` von `bind()`.\n\nExample: Auf eine Nachbarkomponente hören\n```html\n<ui-component name=\"a\" path=\"common.value\"></ui-component>\n<ui-component name=\"b\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('a', function(self) {\n    window.com = self;\n});\n\nCOMPONENT('b', function(self) {\n    self.state2 = component => console.log(component.name);\n});\n\ncom.validate2();\n// logs: a\n</script>\n```\n\n### done()\n\nType: `delegate`\n\nWird am Ende der Initialisierung ausgeführt, wenn der Wert gesetzt ist.\n\n### destroy()\n\nType: `delegate`\n\nWird ausgeführt, wenn die Instanz entfernt wird.\n\nWird von `remove()` aufgerufen und von der regelmäßigen Bereinigung für Elemente, die die Seite verlassen haben. Gib hier Timer und globale Handler frei.\n\nExample: Aufräumen\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.destroy = () => console.log('destroyed');\n});\n\ncom.remove();\n// logs: destroyed\n</script>\n```\n\n### get()\n\nType: `method`\n\nLiest den Wert am Path der Komponente.\n\nReturns: `Object` Der Wert oder `null`, wenn es keinen Path gibt.\n\nExample: Wert lesen\n```js\nSET('common.value', 1);\nconsole.log(com.get());\n// logs: 1\n```\n\n### set(value, [flags])\n\nType: `method`\n\nSchreibt einen Wert an den Path und benachrichtigt alles, was daran gebunden ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der zu schreibende Wert. |\n| `flags` | `String` | no |  | Flags wie `@touched @modified`. |\n\nExample: Wert schreiben\n```js\ncom.set(5, '@touched');\nconsole.log(common.value);\n// logs: 5\n```\n\n### rewrite(value, [flags])\n\nType: `method`\n\nSchreibt einen Wert an den Path, ohne den `setter` dieser Instanz aufzurufen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der zu schreibende Wert. |\n| `flags` | `String` | no |  | Flags wie `@touched @modified`. |\n\nAndere Komponenten und Watcher werden benachrichtigt.\n\nExample: Schreiben ohne Rendern\n```js\ncom.rewrite(7);\nconsole.log(com.get());\n// logs: 7\n```\n\n### modify(value, [flags])\n\nType: `method`\n\nSchreibt einen Wert und markiert die Komponente als berührt und geändert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der zu schreibende Wert. |\n| `flags` | `String` | no |  | Flags wie `@touched @modified`. |\n\nExample: Vom Benutzer eingegebenen Wert schreiben\n```js\ncom.modify('x');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### push(value)\n\nType: `method`\n\nFügt dem Array am Path einen Wert hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Der zu schreibende Wert. |\n\nEin leerer Path wird mit einem neuen Array initialisiert, und ein einzelner Wert wird in ein Array verpackt.\n\nExample: Eintrag hinzufügen\n```js\ncom.push('a');\ncom.push('b');\nconsole.log(common.value.join());\n// logs: a,b\n```\n\n### upd([flags])\n\nType: `method`\n\nBenachrichtigt alles, was an den Path gebunden ist, ohne den Wert zu ändern.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | no |  | Flags wie `@touched @modified`. |\n\nDie Methode steht auch als `update()` zur Verfügung.\n\nExample: Direkt vorgenommene Änderung melden\n```js\ncommon.value = 5;\ncom.upd();\nconsole.log(com.get());\n// logs: 5\n```\n\n### refresh()\n\nType: `method`\n\nRuft den `setter` mit dem aktuellen Wert auf.\n\nExample: Erneut rendern\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = (value, path, flags) => flags.refresh && console.log('refresh');\n});\n\ncom.refresh();\n// logs: refresh\n</script>\n```\n\n### setPath(path)\n\nType: `method`\n\nÄndert den Path der Komponente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der neue Path. |\n\nEin `?` wird durch den Path des übergeordneten Plugins ersetzt. Der `setter` wird erst bei der nächsten Änderung aufgerufen, rufe also `refresh()` auf, um den neuen Wert zu rendern.\n\nExample: Komponente auf einen anderen Wert verweisen\n```js\ncom.setPath('common.other');\nconsole.log(com.path.toString());\n// logs: common.other\n```\n\n### makepath(path)\n\nType: `method`\n\nErsetzt das `?` in einem Path durch den Path des übergeordneten Plugins.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nReturns: `String` Der resultierende Path.\n\nExample: Relativen Path auflösen\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => console.log(self.makepath('?.items'));\n});\n// logs: orders.items\n</script>\n```\n\n### bind(flags, [value])\n\nType: `method`\n\nÄndert den Zustand der Komponente und schreibt optional einen Wert, ohne den `setter` aufzurufen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Die Flags. |\n| `value` | `Object` | no |  | Der zu schreibende Wert. |\n\nDie Flags werden durch ein Leerzeichen, ein Komma oder `|` getrennt, mit oder ohne `@`:\n\n| Flag | Wirkung |\n| --- | --- |\n| `touched`, `touch` | Markiert die Komponente als berührt. |\n| `modified`, `changed`, `modify`, `change` | Markiert die Komponente als geändert. |\n| `reset` | Löscht den Zustand berührt und geändert. |\n| `validate` | Führt die Validierung aus. |\n| `notify` | Ruft `state2` der anderen Komponenten mit demselben Path auf. |\n| `setter` | Ruft den `setter` auf. |\n\nExample: Wert als vom Benutzer eingegeben markieren\n```js\ncom.bind('@touched @modified', 'x');\nconsole.log(com.get(), com.element.attr('class'));\n// logs: x ui-touched ui-modified\n```\n\n### touch()\n\nType: `method`\n\nMarkiert die Komponente als berührt und führt die Validierung aus.\n\nExample: Als berührt markieren\n```js\ncom.touch();\nconsole.log(com.config.touched);\n// logs: 1\n```\n\n### change()\n\nType: `method`\n\nMarkiert die Komponente als berührt und geändert und führt die Validierung aus.\n\nExample: Als geändert markieren\n```js\ncom.change();\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### reset([noemit])\n\nType: `method`\n\nLöscht den Zustand berührt und geändert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noemit` | `Boolean` | no | `false` | Überspringt die Validierung. |\n\nDie Validierung läuft, es sei denn, `noemit` ist `true`.\n\nExample: Zustand löschen\n```js\ncom.change();\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);\n// logs: 0 0\n```\n\n### isInvalid()\n\nType: `method`\n\nGibt an, ob die Komponente berührt und ungültig ist.\n\nReturns: `Boolean` Ein truthy Wert, wenn die Komponente berührt und ungültig ist.\n\nExample: Fehler erst anzeigen, nachdem der Benutzer hier war\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.validate = value => !!value;\n});\n\nconsole.log(!!com.isInvalid());\n// logs: false\ncom.touch();\nconsole.log(!!com.isInvalid());\n// logs: true\n</script>\n```\n\n### validate2([value])\n\nType: `method`\n\nFührt die Validierung aus und ruft `state2` der anderen Komponenten mit demselben Path auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | no |  | Der zu validierende Wert. Standardmäßig der aktuelle Wert. |\n\n### reconfigure(value)\n\nType: `method`\n\nÄndert die Konfiguration und ruft `configure` für jeden Schlüssel auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Die zu ändernden Schlüssel. |\n\nDer Wert ist ein Objekt oder ein String in der Form `key:value;key:value`. Er akzeptiert die speziellen Schlüssel des Elements [ui-component](../ui-component/), etwa `$class` und `=key`.\n\nExample: Konfiguration ändern\n```js\ncom.reconfigure('title:Orders;limit:5');\nconsole.log(com.config.title, com.config.limit);\n// logs: Orders 5\n```\n\n### watchconfig(key, path)\n\nType: `method`\n\nHält einen Config-Key gleich dem Wert an einem Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Config-Key oder `null`. |\n| `path` | `String` | yes |  | Der zu beobachtende Path. |\n\nMit `null` als Schlüssel wird das Objekt am Path als Konfiguration angewendet.\n\nExample: Einem Wert folgen\n```js\ncom.watchconfig('limit', 'common.limit');\nSET('common.limit', 10);\nconsole.log(com.config.limit);\n// logs: 10\n```\n\n### formatter(fn)\n\nType: `method`\n\nSetzt eine Funktion, die den Wert für die Anzeige umwandelt, oder wandelt damit einen Wert um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | Eine Funktion `(path, value, type, format)`, die den anzuzeigenden Wert zurückgibt, oder der umzuwandelnde Wert. |\n\nReturns: `Object` Der umgewandelte Wert, wenn ein Wert angegeben ist.\n\nMit einer Funktion als Argument verwendet der Standard-`setter` sie von da an. Mit jedem anderen Wert gibt die Methode den umgewandelten Wert zurück.\n\nExample: Preis formatieren\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.formatter((path, value) => value ? '$' + value : '');\n});\n\nSET('common.value', 7);\nconsole.log($('input').val());\n// logs: $7\n</script>\n```\n\n### parser(fn)\n\nType: `method`\n\nSetzt eine Funktion, die den eingegebenen Wert für das Modell umwandelt, oder wandelt damit einen Wert um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | Eine Funktion `(path, value, type, format)`, die den zu speichernden Wert zurückgibt, oder der umzuwandelnde Wert. |\n\nReturns: `Object` Der umgewandelte Wert, wenn ein Wert angegeben ist.\n\nMit einer Funktion als Argument verwendet `getter()` sie von da an. Mit jedem anderen Wert gibt die Methode den umgewandelten Wert zurück.\n\nExample: Preis parsen\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.parser((path, value) => value.replace('$', ''));\n});\n\ncom.getter('$9');\nconsole.log(common.value);\n// logs: 9\n</script>\n```\n\n### autobind20([delay], [realtimebinding])\n\nType: `method`\n\nVerbindet `input`, `select` und `textarea` innerhalb des Elements mit dem Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `200` | Die Verzögerung in Millisekunden. |\n| `realtimebinding` | `Boolean` | no | `false` | Ruft den `setter` auch auf, während der Benutzer tippt. |\n\nDer Wert wird nach der Verzögerung geschrieben, und die Zustände berührt und geändert werden anhand der Benutzer-Events aktualisiert.\n\nExample: Eingabefeld binden\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => self.autobind20(50);\n});\n\n$('input').val('typed').trigger('input');\nsetTimeout(() => console.log(common.value), 200);\n// logs: typed\n</script>\n```\n\n### autofill([enabled])\n\nType: `method`\n\nSchreibt die Werte, die der Browser selbst ausfüllt, in das Modell.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enabled` | `Boolean` | no | `true` | `false` schaltet die Funktion aus. |\n\nEin Browser kann ein Formular mit gespeicherten Daten wie einem Namen oder einer Adresse ausfüllen, ohne dass ein Eingabe-Event ausgelöst wird. Eine Sekunde nach dem Start liest die Bibliothek das erste `input`, `textarea` oder `select` jeder Komponente, die diese Methode aufruft, und ein dort gefundener Wert wird mit den Flags `@change` und `@init` in den Path geschrieben. Der Parser der Komponente wandelt den Wert vorher um.\n\nDas funktioniert mit dem Standard-`setter`. Komponenten mit dem Attribut `default`, `select`-Elemente und Range-Inputs werden übersprungen. `autofill(false)` schaltet es aus.\n\nExample: Einen vom Browser ausgefüllten Wert behalten\n```html\n<ui-component name=\"login\" path=\"form.email\"><input type=\"email\" /></ui-component>\n\n<script>\nCOMPONENT('login', function(self) {\n    self.autofill();\n});\n\n// the browser fills the input with a saved address\nsetTimeout(() => $('input').val('ann@example.com'), 100);\n\nsetTimeout(() => console.log(GET('form.email')), 1500);\n// logs: ann@example.com\n</script>\n```\n\n### readonly()\n\nType: `method`\n\nMacht die Komponente zu einer reinen Anzeige ohne `getter`, `setter` und Validierung.\n\n### blind()\n\nType: `method`\n\nSchließt die Komponente von Benachrichtigungen und von der Suche nach Path aus.\n\n### singleton()\n\nType: `method`\n\nErlaubt nur eine Instanz der Komponente.\n\nAndere `<ui-component>`-Elemente mit demselben Namen werden entfernt.\n\nExample: Nur eine Instanz behalten\n```html\n<ui-component name=\"demo\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.singleton();\n});\n\nconsole.log($('ui-component').length);\n// logs: 1\n</script>\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nRuft bei jeder Änderung an einem Path eine Funktion auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der zu beobachtende Path. |\n| `callback` | `Function` | yes |  | Eine Funktion `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Ruft die Funktion sofort mit dem aktuellen Wert auf. |\n\nVerbinde mehrere Paths mit `+`. Mit einer Funktion als erstem Argument wird der Path der Komponente beobachtet. Ein `?` wird durch den Path des übergeordneten Plugins ersetzt.\n\nExample: Anderen Path beobachten\n```js\ncom.watch('common.user', (value, flags, path) => console.log(value, path));\nSET('common.user', 'Anna');\n// logs: Anna common.user\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nEntfernt Watcher, die mit `watch()` registriert wurden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der beobachtete Path. |\n| `callback` | `Function` | no |  | Der Watcher, der entfernt werden soll. |\n\nOhne `callback` werden alle Watcher des Paths entfernt, die diese Komponente registriert hat. Mit einer Funktion als einzigem Argument wird der Watcher des Paths der Komponente entfernt. Verbinde mehrere Paths mit `+`. Ein `?` wird durch den Path des übergeordneten Plugins ersetzt.\n\nExample: Einen Path nicht mehr beobachten\n```js\nvar log = value => console.log('changed', value);\n\ncom.watch('common.count', log);\nSET('common.count', 1);\ncom.unwatch('common.count', log);\nSET('common.count', 2);\n// logs: changed 1\n```\n\n### datasource(path, callback, [init])\n\nType: `method`\n\nBeobachtet einen Path mit Daten für die Komponente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der zu beobachtende Path. |\n| `callback` | `Function` | yes |  | Eine Funktion `(value, flags, path)`. |\n| `init` | `Boolean` | no | `true` | Setze `false`, um den ersten Aufruf zu überspringen. |\n\nReturns: `Component` Die Instanz.\n\nDie Funktion wird beim Initialisieren der Komponente mit dem aktuellen Wert aufgerufen, sofern `init` nicht `false` ist, und bei jeder Änderung. Ein neuer Aufruf ersetzt die zuvor registrierte Datenquelle, und `datasource(null)` entfernt sie.\n\nExample: Einträge aus einem Path rendern\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nvar common = { items: ['a'] };\n\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.datasource('common.items', value => console.log(value.join()));\n    };\n});\n\nSET('common.items', ['a', 'b']);\n// logs: a\n// logs: a,b\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nRegistriert einen Handler für ein globales Event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Event-Name. |\n| `callback` | `Function` | yes |  | Der Handler. |\n\nVerbinde mehrere Event-Namen mit `+`. Siehe [Events](../events/).\n\nExample: Event behandeln\n```js\nvar handler = value => console.log(value);\ncom.on('refresh', handler);\nEMIT('refresh', 1);\ncom.off('refresh', handler);\nEMIT('refresh', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nEntfernt einen Handler eines globalen Events.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Event-Name. |\n| `callback` | `Function` | no |  | Der zu entfernende Handler. |\n\nOhne Callback werden alle Handler des Events entfernt, die auf dieser Instanz registriert sind.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nLöst ein globales Event aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Event-Name. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nExample: Event auslösen\n```js\nON('saved', value => console.log(value));\ncom.emit('saved', 'ok');\n// logs: ok\n```\n\n### command(name, callback)\n\nType: `method`\n\nRegistriert einen Befehl dieser Instanz.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Befehlsname. |\n| `callback` | `Function` | yes |  | Der Handler. |\n\nExample: Befehl registrieren und ausführen\n```js\ncom.command('clear', value => console.log('clear', value));\ncom.CMD('clear', 1);\n// logs: clear 1\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nFührt einen Befehl aus, der auf dieser Instanz mit `command()` registriert wurde.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Befehlsname. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n| `e` | `Object` | no |  | Das fünfte Argument. |\n\n### GET(path)\n\nType: `method`\n\nLiest einen Wert von einem Path. Ein `?` wird durch den Path des übergeordneten Plugins ersetzt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nReturns: `Object` Der Wert.\n\nExample: Mit dem Modell des Plugins arbeiten\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.SET('?.count', 3);\n        console.log(self.GET('?.count'));\n    };\n});\n// logs: 3\n</script>\n```\n\n### SET(path, value)\n\nType: `method`\n\nSchreibt einen Wert an einen Path und benachrichtigt alles, was daran gebunden ist. Ein `?` wird durch den Path des übergeordneten Plugins ersetzt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n| `value` | `Object` | yes |  | Der zu schreibende Wert. |\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuft eine Funktion oder eine Plugin-Methode auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Zum Beispiel `FUNC.save`, `?/save` oder `@save`. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nEin `?` wird durch den Path des übergeordneten Plugins ersetzt. Ein Name, der mit `@` beginnt, ruft eine Methode der nächsten übergeordneten Komponente auf.\n\nExample: Methode der übergeordneten Komponente aufrufen\n```html\n<ui-component name=\"parent\">\n    <ui-component name=\"child\"></ui-component>\n</ui-component>\n\n<script>\nCOMPONENT('parent', function(self) {\n    self.refreshlist = value => console.log('parent', value);\n});\n\nCOMPONENT('child', function(self) {\n    window.com = self;\n});\n\ncom.EXEC('@refreshlist', 1);\n// logs: parent 1\n</script>\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuft eine Plugin-Methode oder eine globale Funktion auf oder schreibt das erste Argument an den Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Methode, die Funktion oder der Path. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nDie Form `plugin/method` ruft eine Methode des Plugins auf, und der Name einer globalen Funktion ruft diese Funktion auf. Jeder andere Name ist ein Path, der `a` erhält.\n\nExample: In einen Path schreiben\n```js\ncom.SEEX('common.status', 'done');\nconsole.log(common.status);\n// logs: done\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuft auf der gesamten Seite eine Methode von Komponenten auf, in der Form `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Das Ziel, zum Beispiel `grid/refresh`. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nExample: Methode einer anderen Komponente aufrufen\n```html\n<ui-component name=\"grid\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.SETTER('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### find(selector)\n\nType: `method`\n\nFindet Elemente innerhalb der Komponente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Ein Selektor oder ein Objekt mit Selektoren. |\n\nReturns: `jQuery` Die gefundenen Elemente oder ein Objekt mit ihnen.\n\nMit einem Objekt sucht die Methode nach jedem Selektor und gibt ein Objekt mit denselben Schlüsseln zurück.\n\nExample: Elemente finden\n```html\n<ui-component name=\"demo\"><input /><b></b></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\nconsole.log(com.find('input').length, com.find({ title: 'b' }).title.length);\n// logs: 1 1\n</script>\n```\n\n### closest(selector)\n\nType: `method`\n\nFindet das nächste übergeordnete Element, das zu einem Selektor passt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Ein jQuery-Selektor. |\n\nReturns: `jQuery` Das gefundene Element.\n\nExample: Übergeordnetes Element finden\n```js\nconsole.log(com.closest('body')[0].tagName);\n// logs: BODY\n```\n\n### parent([selector])\n\nType: `method`\n\nFindet ein übergeordnetes Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Der Selektor. |\n\nReturns: `jQuery` Das gefundene Element.\n\nOhne Argument gibt die Methode das direkte übergeordnete Element zurück. Diese Werte werden ebenfalls unterstützt:\n\n| Selektor | Ergebnis |\n| --- | --- |\n| `auto` | Das nächste übergeordnete Element mit einer im Style gesetzten Höhe oder `window` |\n| `window` | Das Objekt `window` als jQuery |\n| `document` | Das `document` als jQuery |\n| `parent` gefolgt von einer Zahl | Das übergeordnete Element, das so viele Ebenen über dem direkten übergeordneten Element liegt |\n| alles andere | Das nächste übergeordnete Element, das zum Selektor passt |\n\nExample: Direktes übergeordnetes Element lesen\n```js\nconsole.log(com.parent()[0].tagName);\n// logs: BODY\n```\n\n### html([value])\n\nType: `method`\n\nLiest oder ersetzt das HTML des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | Der neue Inhalt. |\n\nReturns: `jQuery` Das Element oder, ohne Argument, das aktuelle HTML.\n\nEin Array wird zu einem String zusammengefügt.\n\nExample: Inhalt setzen\n```js\ncom.html(['<b>', 'Hello', '</b>']);\nconsole.log(com.html());\n// logs: <b>Hello</b>\n```\n\n### text([value])\n\nType: `method`\n\nLiest oder ersetzt den Text des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | Der neue Text. |\n\nReturns: `jQuery` Das Element oder, ohne Argument, der aktuelle Text.\n\nEin Array wird zu einem String zusammengefügt.\n\nExample: Text setzen\n```js\ncom.text('Hello');\nconsole.log(com.text());\n// logs: Hello\n```\n\n### append(value)\n\nType: `method`\n\nFügt HTML am Ende des Elements hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Der Inhalt. |\n\nReturns: `jQuery` Das Element.\n\nEin Array wird zu einem String zusammengefügt.\n\nExample: Inhalt hinzufügen\n```js\ncom.append('<i></i>');\ncom.append(['<b>', '</b>']);\nconsole.log(com.html());\n// logs: <i></i><b></b>\n```\n\n### empty()\n\nType: `method`\n\nEntfernt den Inhalt des Elements.\n\nReturns: `Component` Die Instanz.\n\n### attr(name, [value])\n\nType: `method`\n\nLiest oder setzt ein Attribut des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Das Attribut. |\n| `value` | `String` | no |  | Der neue Wert. |\n\nReturns: `Object` Beim Lesen der Wert, beim Setzen die Instanz.\n\nExample: Attribute\n```js\ncom.attr('title', 'Hello');\ncom.attrd('id', 5);\nconsole.log(com.attr('title'), com.attrd('id'));\n// logs: Hello 5\n```\n\n### attrd(name, [value])\n\nType: `method`\n\nLiest oder setzt ein `data-`-Attribut des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name ohne das Präfix `data-`. |\n| `value` | `String` | no |  | Der neue Wert. |\n\nReturns: `String` Der Wert beim Lesen.\n\n### css(name, [value])\n\nType: `method`\n\nLiest oder setzt eine CSS-Eigenschaft des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Eigenschaft. |\n| `value` | `String` | no |  | Der neue Wert. |\n\nReturns: `Object` Beim Lesen der Wert, beim Setzen die Instanz.\n\nExample: Style ändern\n```js\ncom.css('color', 'red');\nconsole.log(com.css('color'));\n// logs: rgb(255, 0, 0)\n```\n\n### aclass(name, [timeout])\n\nType: `method`\n\nFügt dem Element eine CSS-Klasse hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Klasse. |\n| `timeout` | `Number` | no |  | Eine Verzögerung in Millisekunden. |\n\nReturns: `Component` Die Instanz.\n\nExample: Mit Klassen arbeiten\n```js\ncom.aclass('a b');\ncom.rclass('a');\ncom.tclass('c');\nconsole.log(com.element.attr('class'), com.hclass('c'));\n// logs: b c true\n```\n\n### rclass([name], [timeout])\n\nType: `method`\n\nEntfernt eine CSS-Klasse vom Element oder, ohne Argument, alle Klassen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Die Klasse. |\n| `timeout` | `Number` | no |  | Eine Verzögerung in Millisekunden. |\n\nReturns: `Component` Die Instanz.\n\n### rclass2(search)\n\nType: `method`\n\nEntfernt alle CSS-Klassen, die einen Text enthalten.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String` | yes |  | Der zu suchende Text. |\n\nReturns: `Component` Die Instanz.\n\nExample: Gruppe von Klassen entfernen\n```js\ncom.aclass('size-1 size-2 box');\ncom.rclass2('size-');\nconsole.log(com.element.attr('class'));\n// logs: box\n```\n\n### tclass(name, [enable])\n\nType: `method`\n\nSchaltet eine CSS-Klasse am Element um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Klasse. |\n| `enable` | `Boolean` | no |  | Erzwingt den Zustand der Klasse. |\n\nReturns: `Component` Die Instanz.\n\n### hclass(name)\n\nType: `method`\n\nGibt an, ob das Element eine CSS-Klasse hat.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Klasse. |\n\nReturns: `Boolean` `true`, wenn die Klasse vorhanden ist.\n\n### width()\n\nType: `method`\n\nGibt die Breite des Elements in Pixeln zurück.\n\nReturns: `Number` Die Breite.\n\n### height()\n\nType: `method`\n\nGibt die Höhe des Elements in Pixeln zurück.\n\nReturns: `Number` Die Höhe.\n\n### event(name, [selector], callback)\n\nType: `method`\n\nRegistriert einen DOM-Event-Handler auf dem Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Das DOM-Event. |\n| `selector` | `String` | no |  | Beschränkt das Event auf passende Kindelemente. |\n| `callback` | `Function` | yes |  | Der Handler. |\n\nReturns: `Component` Die Instanz.\n\nDie Argumente werden an die jQuery-Methode `.on()` übergeben.\n\nExample: Klick behandeln\n```html\n<ui-component name=\"demo\"><button>Save</button></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.event('click', 'button', () => console.log('clicked'));\n    };\n});\n\n$('button').trigger('click');\n// logs: clicked\n</script>\n```\n\n### autofocus([selector])\n\nType: `method`\n\nVerschiebt den Fokus auf das erste sichtbare Formularelement innerhalb des Elements.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Die zu fokussierenden Elemente. |\n\nReturns: `Component` Die Instanz.\n\nDer Standardselektor ist `input,select,textarea`. Kann noch kein Steuerelement den Fokus erhalten, versucht die Methode es alle 200 Millisekunden erneut, höchstens 15-mal. Auf Mobilgeräten wird der Fokus nicht verschoben.\n\nExample: Erstes Eingabefeld fokussieren\n```html\n<ui-component name=\"demo\"><input id=\"first\" /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.autofocus();\nconsole.log(document.activeElement.id);\n// logs: first\n</script>\n```\n\n### import(url, [callback], [prepare])\n\nType: `method`\n\nLädt Inhalt herunter und hängt ihn an das Element an.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die Adresse. |\n| `callback` | `Function` | no |  | Wird ausgeführt, wenn der Inhalt auf der Seite ist. |\n| `prepare` | `Function` | no |  | Eine Funktion `(html)`, die den einzufügenden Inhalt zurückgibt. |\n\nSiehe `IMPORT()` in [Inhalte importieren](../../guides/importing/).\n\nExample: Teil importieren\n```js\ncom.import('/parts/help.html', () => console.log(com.html()), html => html + '<hr>');\n// logs: <p>Help</p><hr>\n```\n\n### replace(target, [remove])\n\nType: `method`\n\nVerschiebt die Komponente in ein anderes Element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Element` | yes |  | Das neue Element als Selektor, DOM-Element oder jQuery. |\n| `remove` | `Boolean` | no | `false` | Entfernt das ursprüngliche Element. |\n\nReturns: `Component` Die Instanz.\n\nMit `remove` wird das ursprüngliche Element von der Seite entfernt.\n\nExample: Komponente verschieben\n```js\ncom.replace('#box', true);\nconsole.log(com.dom.id, $('ui-component').length);\n// logs: box 0\n```\n\n### remove()\n\nType: `method`\n\nRuft `destroy` auf und entfernt die Komponente und ihr Element.\n\n### icon(value)\n\nType: `method`\n\nFügt einem Icon-Namen das Icon-Präfix aus `DEF.iconprefix` hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Der Icon-Name. |\n\nReturns: `String` Die CSS-Klassen des Icons.\n\nEin Wert mit Leerzeichen enthält sein Präfix bereits und bleibt unverändert.\n\nExample: Icon-Klassen bilden\n```js\nconsole.log(com.icon('home'));\n// logs: ti ti-home\nconsole.log(com.icon('fa fa-home'));\n// logs: fa fa-home\n```\n\n### caniuse(name)\n\nType: `method`\n\nFindet die erste deklarierte Komponente in einer durch Kommas oder `|` getrennten Liste von Namen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Namen. |\n\nReturns: `String` Der gefundene Name oder `false`.\n\nExample: Verfügbare Komponente auswählen\n```js\nconsole.log(com.caniuse('missing,demo'));\n// logs: demo\nconsole.log(com.caniuse('missing|demo'));\n// logs: demo\nconsole.log(com.caniuse('missing'));\n// logs: false\n```\n\n### parseSource(value)\n\nType: `method`\n\nParst eine Liste in der Form `id|name|icon,id|name|icon`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Die Liste. |\n\nReturns: `Array` Objekte mit `id`, `name` und `icon`.\n\nDie Methode steht auch als `parsesource()` zur Verfügung. Hat der Config-Key `type` den Wert `number`, werden die Bezeichner in Zahlen umgewandelt.\n\nExample: Liste parsen\n```js\nvar items = com.parseSource('1|One,2|Two|home');\nconsole.log(JSON.stringify(items[1]));\n// logs: {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n","entries":[{"type":"property","name":"id","signature":"id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"ID","since":"","deprecated":false},{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"def","signature":"def","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"delegate","name":"init()","signature":"init()","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"configure()","signature":"configure(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter()","signature":"setter(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"setter2()","signature":"setter2(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"getter()","signature":"getter(value, [realtime])","since":"","deprecated":false},{"type":"delegate","name":"validate()","signature":"validate(value)","since":"","deprecated":false},{"type":"delegate","name":"state()","signature":"state()","since":"","deprecated":false},{"type":"delegate","name":"state2()","signature":"state2(component)","since":"","deprecated":false},{"type":"delegate","name":"done()","signature":"done()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(value, [flags])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"rewrite(value, [flags])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"modify(value, [flags])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(value)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd([flags])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"refresh()","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"setPath(path)","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"touch()","signature":"touch()","since":"","deprecated":false},{"type":"method","name":"change()","signature":"change()","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"reset([noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"validate2([value])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"reconfigure(value)","since":"","deprecated":false},{"type":"method","name":"watchconfig()","signature":"watchconfig(key, path)","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"formatter(fn)","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"parser(fn)","since":"","deprecated":false},{"type":"method","name":"autobind20()","signature":"autobind20([delay], [realtimebinding])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"autofill([enabled])","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"readonly()","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"blind()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"singleton()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"empty()","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"css()","signature":"css(name, [value])","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"aclass(name, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"rclass([name], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"tclass(name, [enable])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"hclass(name)","since":"","deprecated":false},{"type":"method","name":"width()","signature":"width()","since":"","deprecated":false},{"type":"method","name":"height()","signature":"height()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"import(url, [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"replace(target, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"remove()","since":"","deprecated":false},{"type":"method","name":"icon()","signature":"icon(value)","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"caniuse(name)","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"parseSource(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcOG2ad61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Component","summary":"Las propiedades, los métodos y los delegates de una instancia de componente.","markdown":"---\ntitle: Component\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Component\n\n> Las propiedades, los métodos y los delegates de una instancia de componente.\n\nUna instancia de componente es el primer argumento de la función que se pasa a `COMPONENT()`. Se crea una por cada elemento [ui-component](../ui-component/). La guía [Crear componentes](../../guides/creating-components/) muestra cómo funcionan las partes en conjunto.\n\n## API\n\n### id\n\nType: `property`\n\nEl identificador de la instancia.\n\nReturns: `String` El identificador de la instancia.\n\nEl valor se genera, y la clave de configuración `$id` lo sustituye.\n\n### ID\n\nType: `property`\n\nEl identificador generado de la instancia.\n\nReturns: `String` El identificador generado de la instancia.\n\nLa clave de configuración `$id` no lo cambia.\n\n### name\n\nType: `property`\n\nEl nombre del componente.\n\nReturns: `String` El nombre del componente.\n\n### path\n\nType: `property`\n\nEl path del componente, o `null` cuando el elemento no tiene ninguno.\n\nReturns: `Path` El path del componente, o `null` cuando el elemento no tiene ninguno.\n\nConsulta [Path](../path/).\n\n### config\n\nType: `property`\n\nLa configuración actual.\n\nReturns: `Object` La configuración actual.\n\nCámbiala con `reconfigure()`, para que se llame a `configure`.\n\n### element\n\nType: `property`\n\nEl elemento `<ui-component>` como objeto jQuery.\n\nReturns: `jQuery` El elemento `<ui-component>` como objeto jQuery.\n\n### dom\n\nType: `property`\n\nEl elemento `<ui-component>`.\n\nReturns: `HTMLElement` El elemento `<ui-component>`.\n\n### plugin\n\nType: `property`\n\nEl plugin padre, o `null`.\n\nReturns: `Plugin` El plugin padre, o `null`.\n\nConsulta [Plugin](../plugin/).\n\n### scope\n\nType: `property`\n\nEl objeto sobre el que se resuelven los paths, que es `window`.\n\nReturns: `Object` El objeto sobre el que se resuelven los paths, que es `window`.\n\n### cls\n\nType: `property`\n\nEl nombre de la clase CSS del componente, por ejemplo `ui-grid`.\n\nReturns: `String` El nombre de la clase CSS del componente, por ejemplo `ui-grid`.\n\nLa clase no se añade al elemento automáticamente.\n\n### def\n\nType: `property`\n\nUna función que devuelve el valor del atributo `default`. Solo existe cuando se usa el atributo.\n\nReturns: `Function` Una función que devuelve el valor del atributo `default`. Solo existe cuando se usa el atributo.\n\n### ready\n\nType: `property`\n\nEs `true` en cuanto la instancia empieza a inicializarse.\n\nReturns: `Boolean` Es `true` en cuanto la instancia empieza a inicializarse.\n\n### init()\n\nType: `delegate`\n\nSe ejecuta una vez por declaración, para la primera instancia del componente.\n\nSe ejecuta antes de `make`. Úsalo para el trabajo que comparten todas las instancias.\n\nExample: El orden de los delegates\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.init = () => console.log('init');\n    self.make = () => console.log('make');\n    self.configure = key => console.log('configure', key);\n    self.setter = () => console.log('setter');\n    self.done = () => console.log('done');\n});\n// logs: init\n// logs: make\n// logs: setter\n// logs: done\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nSe ejecuta cuando se crea la instancia.\n\nConstruye aquí el contenido del elemento.\n\n### configure(key, value, init, prev)\n\nType: `delegate`\n\nSe ejecuta para cada clave de configuración cuando cambia la configuración.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clave de configuración. |\n| `value` | `Object` | yes |  | El nuevo valor. |\n| `init` | `Boolean` | yes |  | `true` durante la inicialización. |\n| `prev` | `Object` | yes |  | El valor anterior, o `null` durante la inicialización. |\n\nSe ejecuta para todas las claves cuando el componente se inicializa.\n\nExample: Reaccionar a una clave de configuración\n```html\n<ui-component name=\"demo\" config=\"title:Hello\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.configure = function(key, value, init, prev) {\n        key === 'title' && console.log(value, !!init, prev);\n    };\n    self.make = () => setTimeout(() => self.reconfigure({ title: 'Bye' }), 100);\n});\n// logs: Hello true null\n// logs: Bye false Hello\n</script>\n```\n\n### setter(value, path, flags)\n\nType: `delegate`\n\nRecibe cada cambio del valor del path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor actual. |\n| `path` | `String` | yes |  | El path que ha cambiado. |\n| `flags` | `Object` | yes |  | Los flags del cambio, por ejemplo `{ init: 1 }`. |\n\nLa implementación predeterminada escribe el valor en el primer `input`, `textarea` o `select` que hay dentro del elemento. Una casilla de verificación se marca cuando el valor, como texto, es `true`, `1`, `on`, `yes` u `ok`. Asigna tu propia función para renderizar el valor.\n\nExample: Renderizar el valor\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.setter = function(value, path, flags) {\n        console.log(value, path, JSON.stringify(flags));\n    };\n});\n\nSET('common.value @touched', 5);\n// logs: 5 common.value {\"touched\":1}\n</script>\n```\n\n### setter2(value, path, flags)\n\nType: `delegate`\n\nRecibe cada cambio del valor, incluidos los cambios escritos con `rewrite()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor actual. |\n| `path` | `String` | yes |  | El path que ha cambiado. |\n| `flags` | `Object` | yes |  | Los flags del cambio. |\n\nExample: Ver los valores que se saltan el setter\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = value => value && console.log('setter', value);\n    self.setter2 = value => value && console.log('setter2', value);\n});\n\ncom.rewrite(1);\n// logs: setter2 1\n</script>\n```\n\n### getter(value, [realtime])\n\nType: `delegate`\n\nProcesa un valor introducido por el usuario y lo escribe en el path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor introducido. |\n| `realtime` | `Boolean` | no | `false` | Escribe el valor sin llamar al `setter`. |\n\nEl valor pasa por la función establecida con `parser()` y se convierte según la clave de configuración `type`. Con `realtime`, el valor se escribe sin llamar al `setter`.\n\nExample: Escribir un valor desde el código\n```js\ncom.getter('5');\nconsole.log(common.value);\n// logs: 5\n```\n\n### validate(value)\n\nType: `delegate`\n\nDecide si el valor es válido.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor que se comprueba. |\n\nReturns: `Boolean` El resultado de la validación. También se acepta una cadena.\n\nDevuelve `true` o una cadena vacía para un valor válido. Una cadena devuelta se guarda en `config.invalid` como mensaje, y cualquier otro resultado pone `config.invalid` a `true`. El método se ejecuta después de cada cambio del valor.\n\nExample: Exigir un valor\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.validate = value => value ? true : 'The value is required';\n});\n\nconsole.log(com.config.invalid);\n// logs: The value is required\nSET('common.value', 'x');\nconsole.log(com.config.invalid);\n// logs: false\n</script>\n```\n\n### state()\n\nType: `delegate`\n\nSe ejecuta cuando cambia el estado del componente.\n\nLee el estado de `config.touched`, `config.modified`, `config.invalid` y `config.disabled`.\n\nExample: Seguir el estado\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.state = () => console.log(!!config.touched);\n});\n\ncom.touch();\n// logs: true\n</script>\n```\n\n### state2(component)\n\nType: `delegate`\n\nSe ejecuta cuando otro componente con el mismo path informa de su estado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | El componente que informa del estado. |\n\nEl aviso se hace con `validate2()` o con el flag `notify` de `bind()`.\n\nExample: Escuchar a un componente hermano\n```html\n<ui-component name=\"a\" path=\"common.value\"></ui-component>\n<ui-component name=\"b\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('a', function(self) {\n    window.com = self;\n});\n\nCOMPONENT('b', function(self) {\n    self.state2 = component => console.log(component.name);\n});\n\ncom.validate2();\n// logs: a\n</script>\n```\n\n### done()\n\nType: `delegate`\n\nSe ejecuta al final de la inicialización, cuando el valor está establecido.\n\n### destroy()\n\nType: `delegate`\n\nSe ejecuta cuando se elimina la instancia.\n\nLo llaman `remove()` y la limpieza periódica de los elementos que han salido de la página. Libera aquí los temporizadores y los manejadores globales.\n\nExample: Limpiar\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.destroy = () => console.log('destroyed');\n});\n\ncom.remove();\n// logs: destroyed\n</script>\n```\n\n### get()\n\nType: `method`\n\nLee el valor del path del componente.\n\nReturns: `Object` El valor, o `null` si no hay path.\n\nExample: Leer el valor\n```js\nSET('common.value', 1);\nconsole.log(com.get());\n// logs: 1\n```\n\n### set(value, [flags])\n\nType: `method`\n\nEscribe un valor en el path y notifica a todo lo que está enlazado a él.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor que se va a escribir. |\n| `flags` | `String` | no |  | Flags como `@touched @modified`. |\n\nExample: Escribir el valor\n```js\ncom.set(5, '@touched');\nconsole.log(common.value);\n// logs: 5\n```\n\n### rewrite(value, [flags])\n\nType: `method`\n\nEscribe un valor en el path sin llamar al `setter` de esta instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor que se va a escribir. |\n| `flags` | `String` | no |  | Flags como `@touched @modified`. |\n\nSe notifica a los demás componentes y a los observadores.\n\nExample: Escribir sin renderizar\n```js\ncom.rewrite(7);\nconsole.log(com.get());\n// logs: 7\n```\n\n### modify(value, [flags])\n\nType: `method`\n\nEscribe un valor y marca el componente como tocado y modificado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor que se va a escribir. |\n| `flags` | `String` | no |  | Flags como `@touched @modified`. |\n\nExample: Escribir un valor introducido por el usuario\n```js\ncom.modify('x');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### push(value)\n\nType: `method`\n\nAñade un valor al array del path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | El valor que se va a escribir. |\n\nUn path vacío se inicializa con un array nuevo y un valor individual se envuelve en un array.\n\nExample: Añadir un elemento\n```js\ncom.push('a');\ncom.push('b');\nconsole.log(common.value.join());\n// logs: a,b\n```\n\n### upd([flags])\n\nType: `method`\n\nNotifica a todo lo que está enlazado al path, sin cambiar el valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | no |  | Flags como `@touched @modified`. |\n\nEl método también está disponible como `update()`.\n\nExample: Anunciar un cambio hecho directamente\n```js\ncommon.value = 5;\ncom.upd();\nconsole.log(com.get());\n// logs: 5\n```\n\n### refresh()\n\nType: `method`\n\nLlama al `setter` con el valor actual.\n\nExample: Volver a renderizar\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = (value, path, flags) => flags.refresh && console.log('refresh');\n});\n\ncom.refresh();\n// logs: refresh\n</script>\n```\n\n### setPath(path)\n\nType: `method`\n\nCambia el path del componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El nuevo path. |\n\nUn `?` se sustituye por el path del plugin padre. No se llama al `setter` hasta el siguiente cambio, así que llama a `refresh()` para renderizar el nuevo valor.\n\nExample: Apuntar el componente a otro valor\n```js\ncom.setPath('common.other');\nconsole.log(com.path.toString());\n// logs: common.other\n```\n\n### makepath(path)\n\nType: `method`\n\nSustituye el `?` de un path por el path del plugin padre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nReturns: `String` El path resultante.\n\nExample: Resolver un path relativo\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => console.log(self.makepath('?.items'));\n});\n// logs: orders.items\n</script>\n```\n\n### bind(flags, [value])\n\nType: `method`\n\nCambia el estado del componente y, opcionalmente, escribe un valor sin llamar al `setter`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Los flags. |\n| `value` | `Object` | no |  | El valor que se va a escribir. |\n\nLos flags se separan con un espacio, una coma o `|`, con o sin `@`:\n\n| Flag | Efecto |\n| --- | --- |\n| `touched`, `touch` | Marca el componente como tocado. |\n| `modified`, `changed`, `modify`, `change` | Marca el componente como modificado. |\n| `reset` | Borra el estado de tocado y modificado. |\n| `validate` | Ejecuta la validación. |\n| `notify` | Llama a `state2` de los demás componentes con el mismo path. |\n| `setter` | Llama al `setter`. |\n\nExample: Marcar un valor como introducido por el usuario\n```js\ncom.bind('@touched @modified', 'x');\nconsole.log(com.get(), com.element.attr('class'));\n// logs: x ui-touched ui-modified\n```\n\n### touch()\n\nType: `method`\n\nMarca el componente como tocado y ejecuta la validación.\n\nExample: Marcar como tocado\n```js\ncom.touch();\nconsole.log(com.config.touched);\n// logs: 1\n```\n\n### change()\n\nType: `method`\n\nMarca el componente como tocado y modificado y ejecuta la validación.\n\nExample: Marcar como modificado\n```js\ncom.change();\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### reset([noemit])\n\nType: `method`\n\nBorra el estado de tocado y modificado.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noemit` | `Boolean` | no | `false` | Omite la validación. |\n\nLa validación se ejecuta salvo que `noemit` sea `true`.\n\nExample: Borrar el estado\n```js\ncom.change();\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);\n// logs: 0 0\n```\n\n### isInvalid()\n\nType: `method`\n\nIndica si el componente está tocado y no es válido.\n\nReturns: `Boolean` Un valor truthy cuando el componente está tocado y no es válido.\n\nExample: Mostrar un error solo después de que el usuario haya pasado por aquí\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.validate = value => !!value;\n});\n\nconsole.log(!!com.isInvalid());\n// logs: false\ncom.touch();\nconsole.log(!!com.isInvalid());\n// logs: true\n</script>\n```\n\n### validate2([value])\n\nType: `method`\n\nEjecuta la validación y llama a `state2` de los demás componentes con el mismo path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | no |  | El valor que se valida. De forma predeterminada, es el valor actual. |\n\n### reconfigure(value)\n\nType: `method`\n\nCambia la configuración y llama a `configure` para cada clave.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Las claves que se cambian. |\n\nEl valor es un objeto o una cadena con la forma `key:value;key:value`. Acepta las claves especiales del elemento [ui-component](../ui-component/), como `$class` y `=key`.\n\nExample: Cambiar la configuración\n```js\ncom.reconfigure('title:Orders;limit:5');\nconsole.log(com.config.title, com.config.limit);\n// logs: Orders 5\n```\n\n### watchconfig(key, path)\n\nType: `method`\n\nMantiene una clave de configuración igual al valor de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clave de configuración, o `null`. |\n| `path` | `String` | yes |  | El path que se va a observar. |\n\nCon `null` como clave, el objeto del path se aplica como configuración.\n\nExample: Seguir un valor\n```js\ncom.watchconfig('limit', 'common.limit');\nSET('common.limit', 10);\nconsole.log(com.config.limit);\n// logs: 10\n```\n\n### formatter(fn)\n\nType: `method`\n\nEstablece una función que convierte el valor para mostrarlo, o convierte un valor con ella.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | Una función `(path, value, type, format)` que devuelve el valor que se muestra, o el valor que se convierte. |\n\nReturns: `Object` El valor convertido, cuando se indica un valor.\n\nCon una función como argumento, el `setter` predeterminado la usa a partir de entonces. Con cualquier otro valor, el método devuelve el valor convertido.\n\nExample: Dar formato a un precio\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.formatter((path, value) => value ? '$' + value : '');\n});\n\nSET('common.value', 7);\nconsole.log($('input').val());\n// logs: $7\n</script>\n```\n\n### parser(fn)\n\nType: `method`\n\nEstablece una función que convierte el valor introducido para el modelo, o convierte un valor con ella.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | Una función `(path, value, type, format)` que devuelve el valor que se guarda, o el valor que se convierte. |\n\nReturns: `Object` El valor convertido, cuando se indica un valor.\n\nCon una función como argumento, `getter()` la usa a partir de entonces. Con cualquier otro valor, el método devuelve el valor convertido.\n\nExample: Analizar un precio\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.parser((path, value) => value.replace('$', ''));\n});\n\ncom.getter('$9');\nconsole.log(common.value);\n// logs: 9\n</script>\n```\n\n### autobind20([delay], [realtimebinding])\n\nType: `method`\n\nConecta con el path los `input`, `select` y `textarea` que hay dentro del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `200` | El retardo en milisegundos. |\n| `realtimebinding` | `Boolean` | no | `false` | Llama al `setter` también mientras el usuario escribe. |\n\nEl valor se escribe después del retardo, y los estados de tocado y modificado se actualizan a partir de los eventos del usuario.\n\nExample: Enlazar un input\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => self.autobind20(50);\n});\n\n$('input').val('typed').trigger('input');\nsetTimeout(() => console.log(common.value), 200);\n// logs: typed\n</script>\n```\n\n### autofill([enabled])\n\nType: `method`\n\nEscribe en el modelo los valores que el navegador rellena por su cuenta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enabled` | `Boolean` | no | `true` | `false` desactiva la función. |\n\nUn navegador puede rellenar un formulario con datos guardados, como un nombre o una dirección, sin ningún evento de entrada. Un segundo después de que arranque la biblioteca, esta lee el primer `input`, `textarea` o `select` de cada componente que llama a este método, y el valor que encuentra se escribe en el path con los flags `@change` y `@init`. Antes, el parser del componente convierte el valor.\n\nFunciona con el `setter` predeterminado. Se omiten los componentes con un atributo `default`, los elementos `select` y los inputs de tipo range. `autofill(false)` lo desactiva.\n\nExample: Conservar un valor rellenado por el navegador\n```html\n<ui-component name=\"login\" path=\"form.email\"><input type=\"email\" /></ui-component>\n\n<script>\nCOMPONENT('login', function(self) {\n    self.autofill();\n});\n\n// the browser fills the input with a saved address\nsetTimeout(() => $('input').val('ann@example.com'), 100);\n\nsetTimeout(() => console.log(GET('form.email')), 1500);\n// logs: ann@example.com\n</script>\n```\n\n### readonly()\n\nType: `method`\n\nConvierte el componente en un elemento de visualización sin `getter`, `setter` ni validación.\n\n### blind()\n\nType: `method`\n\nExcluye el componente de las notificaciones y de las búsquedas por path.\n\n### singleton()\n\nType: `method`\n\nPermite una sola instancia del componente.\n\nLos demás elementos `<ui-component>` con el mismo nombre se eliminan.\n\nExample: Conservar una sola instancia\n```html\n<ui-component name=\"demo\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.singleton();\n});\n\nconsole.log($('ui-component').length);\n// logs: 1\n</script>\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nLlama a una función en cada cambio de un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path que se va a observar. |\n| `callback` | `Function` | yes |  | Una función `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Llama a la función de inmediato con el valor actual. |\n\nUne varios paths con `+`. Con una función como primer argumento, se observa el path del componente. Un `?` se sustituye por el path del plugin padre.\n\nExample: Observar otro path\n```js\ncom.watch('common.user', (value, flags, path) => console.log(value, path));\nSET('common.user', 'Anna');\n// logs: Anna common.user\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nElimina observadores registrados con `watch()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path observado. |\n| `callback` | `Function` | no |  | El observador que se va a eliminar. |\n\nSin `callback`, se eliminan todos los observadores del path que ha registrado este componente. Con una función como único argumento, se elimina el observador del path del componente. Une varios paths con `+`. Un `?` se sustituye por el path del plugin padre.\n\nExample: Dejar de observar un path\n```js\nvar log = value => console.log('changed', value);\n\ncom.watch('common.count', log);\nSET('common.count', 1);\ncom.unwatch('common.count', log);\nSET('common.count', 2);\n// logs: changed 1\n```\n\n### datasource(path, callback, [init])\n\nType: `method`\n\nObserva un path con datos para el componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path que se va a observar. |\n| `callback` | `Function` | yes |  | Una función `(value, flags, path)`. |\n| `init` | `Boolean` | no | `true` | Establece `false` para omitir la primera llamada. |\n\nReturns: `Component` La instancia.\n\nLa función se llama con el valor actual cuando el componente se inicializa, salvo que `init` sea `false`, y en cada cambio. Una nueva llamada sustituye la fuente de datos registrada antes, y `datasource(null)` la elimina.\n\nExample: Renderizar elementos desde un path\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nvar common = { items: ['a'] };\n\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.datasource('common.items', value => console.log(value.join()));\n    };\n});\n\nSET('common.items', ['a', 'b']);\n// logs: a\n// logs: a,b\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nRegistra un manejador de un evento global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `callback` | `Function` | yes |  | El manejador. |\n\nUne varios nombres de evento con `+`. Consulta [Eventos](../events/).\n\nExample: Gestionar un evento\n```js\nvar handler = value => console.log(value);\ncom.on('refresh', handler);\nEMIT('refresh', 1);\ncom.off('refresh', handler);\nEMIT('refresh', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nElimina un manejador de un evento global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `callback` | `Function` | no |  | El manejador que se va a eliminar. |\n\nSin callback, se eliminan todos los manejadores del evento registrados en esta instancia.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nEmite un evento global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nExample: Emitir un evento\n```js\nON('saved', value => console.log(value));\ncom.emit('saved', 'ok');\n// logs: ok\n```\n\n### command(name, callback)\n\nType: `method`\n\nRegistra un comando de esta instancia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del comando. |\n| `callback` | `Function` | yes |  | El manejador. |\n\nExample: Registrar y ejecutar un comando\n```js\ncom.command('clear', value => console.log('clear', value));\ncom.CMD('clear', 1);\n// logs: clear 1\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nEjecuta un comando registrado en esta instancia con `command()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del comando. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n| `e` | `Object` | no |  | El quinto argumento. |\n\n### GET(path)\n\nType: `method`\n\nLee un valor de un path. Un `?` se sustituye por el path del plugin padre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nReturns: `Object` El valor.\n\nExample: Trabajar con el modelo del plugin\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.SET('?.count', 3);\n        console.log(self.GET('?.count'));\n    };\n});\n// logs: 3\n</script>\n```\n\n### SET(path, value)\n\nType: `method`\n\nEscribe un valor en un path y notifica a todo lo que está enlazado a él. Un `?` se sustituye por el path del plugin padre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n| `value` | `Object` | yes |  | El valor que se va a escribir. |\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a una función o a un método de un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Por ejemplo `FUNC.save`, `?/save` o `@save`. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nUn `?` se sustituye por el path del plugin padre. Un nombre que empieza por `@` llama a un método del componente padre más cercano.\n\nExample: Llamar a un método del componente padre\n```html\n<ui-component name=\"parent\">\n    <ui-component name=\"child\"></ui-component>\n</ui-component>\n\n<script>\nCOMPONENT('parent', function(self) {\n    self.refreshlist = value => console.log('parent', value);\n});\n\nCOMPONENT('child', function(self) {\n    window.com = self;\n});\n\ncom.EXEC('@refreshlist', 1);\n// logs: parent 1\n</script>\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a un método de un plugin o a una función global, o escribe el primer argumento en el path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El método, la función o el path. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nLa forma `plugin/method` llama a un método del plugin y el nombre de una función global llama a esa función. Cualquier otro nombre es un path que recibe `a`.\n\nExample: Escribir en un path\n```js\ncom.SEEX('common.status', 'done');\nconsole.log(common.status);\n// logs: done\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a un método de los componentes de toda la página, con la forma `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El destino, por ejemplo `grid/refresh`. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nExample: Llamar a un método de otro componente\n```html\n<ui-component name=\"grid\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.SETTER('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### find(selector)\n\nType: `method`\n\nBusca elementos dentro del componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selector, o un objeto con selectores. |\n\nReturns: `jQuery` Los elementos encontrados, o un objeto con ellos.\n\nCon un objeto, el método busca cada selector y devuelve un objeto con las mismas claves.\n\nExample: Buscar elementos\n```html\n<ui-component name=\"demo\"><input /><b></b></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\nconsole.log(com.find('input').length, com.find({ title: 'b' }).title.length);\n// logs: 1 1\n</script>\n```\n\n### closest(selector)\n\nType: `method`\n\nBusca el padre más cercano que coincide con un selector.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selector de jQuery. |\n\nReturns: `jQuery` El elemento encontrado.\n\nExample: Buscar un padre\n```js\nconsole.log(com.closest('body')[0].tagName);\n// logs: BODY\n```\n\n### parent([selector])\n\nType: `method`\n\nBusca un elemento padre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | El selector. |\n\nReturns: `jQuery` El elemento encontrado.\n\nSin argumento, el método devuelve el padre directo. También se admiten estos valores:\n\n| Selector | Resultado |\n| --- | --- |\n| `auto` | El padre más cercano con una altura definida en su estilo, o `window` |\n| `window` | El objeto `window` como jQuery |\n| `document` | El `document` como jQuery |\n| `parent` seguido de un número | El padre que está ese número de niveles por encima del padre directo |\n| cualquier otro valor | El padre más cercano que coincide con el selector |\n\nExample: Leer el padre directo\n```js\nconsole.log(com.parent()[0].tagName);\n// logs: BODY\n```\n\n### html([value])\n\nType: `method`\n\nLee o sustituye el HTML del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | El contenido nuevo. |\n\nReturns: `jQuery` El elemento o, sin argumento, el HTML actual.\n\nUn array se une en una sola cadena.\n\nExample: Establecer el contenido\n```js\ncom.html(['<b>', 'Hello', '</b>']);\nconsole.log(com.html());\n// logs: <b>Hello</b>\n```\n\n### text([value])\n\nType: `method`\n\nLee o sustituye el texto del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | El nuevo texto. |\n\nReturns: `jQuery` El elemento o, sin argumento, el texto actual.\n\nUn array se une en una sola cadena.\n\nExample: Establecer el texto\n```js\ncom.text('Hello');\nconsole.log(com.text());\n// logs: Hello\n```\n\n### append(value)\n\nType: `method`\n\nAñade HTML al final del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | El contenido. |\n\nReturns: `jQuery` El elemento.\n\nUn array se une en una sola cadena.\n\nExample: Añadir contenido\n```js\ncom.append('<i></i>');\ncom.append(['<b>', '</b>']);\nconsole.log(com.html());\n// logs: <i></i><b></b>\n```\n\n### empty()\n\nType: `method`\n\nElimina el contenido del elemento.\n\nReturns: `Component` La instancia.\n\n### attr(name, [value])\n\nType: `method`\n\nLee o establece un atributo del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El atributo. |\n| `value` | `String` | no |  | El nuevo valor. |\n\nReturns: `Object` El valor al leer, la instancia al establecer.\n\nExample: Atributos\n```js\ncom.attr('title', 'Hello');\ncom.attrd('id', 5);\nconsole.log(com.attr('title'), com.attrd('id'));\n// logs: Hello 5\n```\n\n### attrd(name, [value])\n\nType: `method`\n\nLee o establece un atributo `data-` del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre sin el prefijo `data-`. |\n| `value` | `String` | no |  | El nuevo valor. |\n\nReturns: `String` El valor al leer.\n\n### css(name, [value])\n\nType: `method`\n\nLee o establece una propiedad CSS del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La propiedad. |\n| `value` | `String` | no |  | El nuevo valor. |\n\nReturns: `Object` El valor al leer, la instancia al establecer.\n\nExample: Cambiar un estilo\n```js\ncom.css('color', 'red');\nconsole.log(com.css('color'));\n// logs: rgb(255, 0, 0)\n```\n\n### aclass(name, [timeout])\n\nType: `method`\n\nAñade una clase CSS al elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La clase. |\n| `timeout` | `Number` | no |  | Un retardo en milisegundos. |\n\nReturns: `Component` La instancia.\n\nExample: Trabajar con clases\n```js\ncom.aclass('a b');\ncom.rclass('a');\ncom.tclass('c');\nconsole.log(com.element.attr('class'), com.hclass('c'));\n// logs: b c true\n```\n\n### rclass([name], [timeout])\n\nType: `method`\n\nQuita una clase CSS del elemento o, sin argumento, todas las clases.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | La clase. |\n| `timeout` | `Number` | no |  | Un retardo en milisegundos. |\n\nReturns: `Component` La instancia.\n\n### rclass2(search)\n\nType: `method`\n\nQuita todas las clases CSS que contienen un texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String` | yes |  | El texto que se busca. |\n\nReturns: `Component` La instancia.\n\nExample: Quitar un grupo de clases\n```js\ncom.aclass('size-1 size-2 box');\ncom.rclass2('size-');\nconsole.log(com.element.attr('class'));\n// logs: box\n```\n\n### tclass(name, [enable])\n\nType: `method`\n\nAlterna una clase CSS en el elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La clase. |\n| `enable` | `Boolean` | no |  | Fuerza el estado de la clase. |\n\nReturns: `Component` La instancia.\n\n### hclass(name)\n\nType: `method`\n\nIndica si el elemento tiene una clase CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La clase. |\n\nReturns: `Boolean` `true` cuando la clase está presente.\n\n### width()\n\nType: `method`\n\nDevuelve el ancho del elemento en píxeles.\n\nReturns: `Number` El ancho.\n\n### height()\n\nType: `method`\n\nDevuelve la altura del elemento en píxeles.\n\nReturns: `Number` La altura.\n\n### event(name, [selector], callback)\n\nType: `method`\n\nRegistra un manejador de eventos DOM en el elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El evento DOM. |\n| `selector` | `String` | no |  | Limita el evento a los hijos que coinciden. |\n| `callback` | `Function` | yes |  | El manejador. |\n\nReturns: `Component` La instancia.\n\nLos argumentos se pasan al método `.on()` de jQuery.\n\nExample: Gestionar un clic\n```html\n<ui-component name=\"demo\"><button>Save</button></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.event('click', 'button', () => console.log('clicked'));\n    };\n});\n\n$('button').trigger('click');\n// logs: clicked\n</script>\n```\n\n### autofocus([selector])\n\nType: `method`\n\nMueve el foco al primer control visible que hay dentro del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Los elementos que se enfocan. |\n\nReturns: `Component` La instancia.\n\nEl selector predeterminado es `input,select,textarea`. Si todavía ningún control puede recibir el foco, el método lo vuelve a intentar cada 200 milisegundos, 15 veces como máximo. En los dispositivos móviles el foco no se mueve.\n\nExample: Enfocar el primer input\n```html\n<ui-component name=\"demo\"><input id=\"first\" /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.autofocus();\nconsole.log(document.activeElement.id);\n// logs: first\n</script>\n```\n\n### import(url, [callback], [prepare])\n\nType: `method`\n\nDescarga contenido y lo añade al final del elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La dirección. |\n| `callback` | `Function` | no |  | Se ejecuta cuando el contenido está en la página. |\n| `prepare` | `Function` | no |  | Una función `(html)` que devuelve el contenido que se inserta. |\n\nConsulta `IMPORT()` en [Importar contenido](../../guides/importing/).\n\nExample: Importar una parte\n```js\ncom.import('/parts/help.html', () => console.log(com.html()), html => html + '<hr>');\n// logs: <p>Help</p><hr>\n```\n\n### replace(target, [remove])\n\nType: `method`\n\nMueve el componente a otro elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Element` | yes |  | El nuevo elemento, como selector, elemento DOM o jQuery. |\n| `remove` | `Boolean` | no | `false` | Elimina el elemento original. |\n\nReturns: `Component` La instancia.\n\nCon `remove`, el elemento original se elimina de la página.\n\nExample: Mover el componente\n```js\ncom.replace('#box', true);\nconsole.log(com.dom.id, $('ui-component').length);\n// logs: box 0\n```\n\n### remove()\n\nType: `method`\n\nLlama a `destroy` y elimina el componente y su elemento.\n\n### icon(value)\n\nType: `method`\n\nAñade a un nombre de icono el prefijo de iconos de `DEF.iconprefix`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | El nombre del icono. |\n\nReturns: `String` Las clases CSS del icono.\n\nUn valor con un espacio ya contiene su prefijo y no cambia.\n\nExample: Construir clases de iconos\n```js\nconsole.log(com.icon('home'));\n// logs: ti ti-home\nconsole.log(com.icon('fa fa-home'));\n// logs: fa fa-home\n```\n\n### caniuse(name)\n\nType: `method`\n\nBusca el primer componente declarado en una lista de nombres separados por comas o por `|`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Los nombres. |\n\nReturns: `String` El nombre encontrado, o `false`.\n\nExample: Elegir un componente disponible\n```js\nconsole.log(com.caniuse('missing,demo'));\n// logs: demo\nconsole.log(com.caniuse('missing|demo'));\n// logs: demo\nconsole.log(com.caniuse('missing'));\n// logs: false\n```\n\n### parseSource(value)\n\nType: `method`\n\nAnaliza una lista con la forma `id|name|icon,id|name|icon`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | La lista. |\n\nReturns: `Array` Objetos con `id`, `name` e `icon`.\n\nEl método también está disponible como `parsesource()`. Cuando la clave de configuración `type` es `number`, los identificadores se convierten en números.\n\nExample: Analizar una lista\n```js\nvar items = com.parseSource('1|One,2|Two|home');\nconsole.log(JSON.stringify(items[1]));\n// logs: {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n","entries":[{"type":"property","name":"id","signature":"id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"ID","since":"","deprecated":false},{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"def","signature":"def","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"delegate","name":"init()","signature":"init()","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"configure()","signature":"configure(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter()","signature":"setter(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"setter2()","signature":"setter2(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"getter()","signature":"getter(value, [realtime])","since":"","deprecated":false},{"type":"delegate","name":"validate()","signature":"validate(value)","since":"","deprecated":false},{"type":"delegate","name":"state()","signature":"state()","since":"","deprecated":false},{"type":"delegate","name":"state2()","signature":"state2(component)","since":"","deprecated":false},{"type":"delegate","name":"done()","signature":"done()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(value, [flags])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"rewrite(value, [flags])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"modify(value, [flags])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(value)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd([flags])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"refresh()","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"setPath(path)","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"touch()","signature":"touch()","since":"","deprecated":false},{"type":"method","name":"change()","signature":"change()","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"reset([noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"validate2([value])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"reconfigure(value)","since":"","deprecated":false},{"type":"method","name":"watchconfig()","signature":"watchconfig(key, path)","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"formatter(fn)","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"parser(fn)","since":"","deprecated":false},{"type":"method","name":"autobind20()","signature":"autobind20([delay], [realtimebinding])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"autofill([enabled])","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"readonly()","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"blind()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"singleton()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"empty()","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"css()","signature":"css(name, [value])","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"aclass(name, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"rclass([name], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"tclass(name, [enable])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"hclass(name)","since":"","deprecated":false},{"type":"method","name":"width()","signature":"width()","since":"","deprecated":false},{"type":"method","name":"height()","signature":"height()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"import(url, [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"replace(target, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"remove()","since":"","deprecated":false},{"type":"method","name":"icon()","signature":"icon(value)","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"caniuse(name)","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"parseSource(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcOG2ad61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Component","summary":"Les propriétés, les méthodes et les delegates d'une instance de composant.","markdown":"---\ntitle: Component\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Component\n\n> Les propriétés, les méthodes et les delegates d'une instance de composant.\n\nUne instance de composant est le premier argument de la fonction fournie à `COMPONENT()`. Elle est créée pour chaque élément [ui-component](../ui-component/). Le guide [Créer des composants](../../guides/creating-components/) montre comment les différentes parties fonctionnent ensemble.\n\n## API\n\n### id\n\nType: `property`\n\nL'identifiant de l'instance.\n\nReturns: `String` L'identifiant de l'instance.\n\nLa valeur est générée, et la clé de configuration `$id` la remplace.\n\n### ID\n\nType: `property`\n\nL'identifiant généré de l'instance.\n\nReturns: `String` L'identifiant généré de l'instance.\n\nLa clé de configuration `$id` ne le modifie pas.\n\n### name\n\nType: `property`\n\nLe nom du composant.\n\nReturns: `String` Le nom du composant.\n\n### path\n\nType: `property`\n\nLe path du composant, ou `null` quand l'élément n'en a pas.\n\nReturns: `Path` Le path du composant, ou `null` quand l'élément n'en a pas.\n\nVoir [Path](../path/).\n\n### config\n\nType: `property`\n\nLa configuration actuelle.\n\nReturns: `Object` La configuration actuelle.\n\nModifie-la avec `reconfigure()`, pour que `configure` soit appelé.\n\n### element\n\nType: `property`\n\nL'élément `<ui-component>` sous forme d'objet jQuery.\n\nReturns: `jQuery` L'élément `<ui-component>` sous forme d'objet jQuery.\n\n### dom\n\nType: `property`\n\nL'élément `<ui-component>`.\n\nReturns: `HTMLElement` L'élément `<ui-component>`.\n\n### plugin\n\nType: `property`\n\nLe plugin parent, ou `null`.\n\nReturns: `Plugin` Le plugin parent, ou `null`.\n\nVoir [Plugin](../plugin/).\n\n### scope\n\nType: `property`\n\nL'objet par rapport auquel les paths sont résolus, c'est-à-dire `window`.\n\nReturns: `Object` L'objet par rapport auquel les paths sont résolus, c'est-à-dire `window`.\n\n### cls\n\nType: `property`\n\nLe nom de la classe CSS du composant, par exemple `ui-grid`.\n\nReturns: `String` Le nom de la classe CSS du composant, par exemple `ui-grid`.\n\nLa classe n'est pas ajoutée automatiquement à l'élément.\n\n### def\n\nType: `property`\n\nUne fonction qui renvoie la valeur de l'attribut `default`. Elle n'existe que si l'attribut est utilisé.\n\nReturns: `Function` Une fonction qui renvoie la valeur de l'attribut `default`. Elle n'existe que si l'attribut est utilisé.\n\n### ready\n\nType: `property`\n\nVaut `true` dès que l'instance commence à s'initialiser.\n\nReturns: `Boolean` Vaut `true` dès que l'instance commence à s'initialiser.\n\n### init()\n\nType: `delegate`\n\nS'exécute une fois par déclaration, pour la première instance du composant.\n\nIl s'exécute avant `make`. Utilise-le pour le travail partagé par toutes les instances.\n\nExample: L'ordre des delegates\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.init = () => console.log('init');\n    self.make = () => console.log('make');\n    self.configure = key => console.log('configure', key);\n    self.setter = () => console.log('setter');\n    self.done = () => console.log('done');\n});\n// logs: init\n// logs: make\n// logs: setter\n// logs: done\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nS'exécute quand l'instance est créée.\n\nConstruis ici le contenu de l'élément.\n\n### configure(key, value, init, prev)\n\nType: `delegate`\n\nS'exécute pour chaque clé de configuration quand la configuration change.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clé de configuration. |\n| `value` | `Object` | yes |  | La nouvelle valeur. |\n| `init` | `Boolean` | yes |  | `true` pendant l'initialisation. |\n| `prev` | `Object` | yes |  | La valeur précédente, ou `null` pendant l'initialisation. |\n\nIl s'exécute pour toutes les clés quand le composant s'initialise.\n\nExample: Réagir à une clé de configuration\n```html\n<ui-component name=\"demo\" config=\"title:Hello\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.configure = function(key, value, init, prev) {\n        key === 'title' && console.log(value, !!init, prev);\n    };\n    self.make = () => setTimeout(() => self.reconfigure({ title: 'Bye' }), 100);\n});\n// logs: Hello true null\n// logs: Bye false Hello\n</script>\n```\n\n### setter(value, path, flags)\n\nType: `delegate`\n\nReçoit chaque modification de la valeur du path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur actuelle. |\n| `path` | `String` | yes |  | Le path qui a changé. |\n| `flags` | `Object` | yes |  | Les flags de la modification, par exemple `{ init: 1 }`. |\n\nL'implémentation par défaut écrit la valeur dans le premier `input`, `textarea` ou `select` de l'élément. Une case à cocher est cochée quand la valeur, sous forme de texte, vaut `true`, `1`, `on`, `yes` ou `ok`. Assigne ta propre fonction pour afficher la valeur.\n\nExample: Afficher la valeur\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.setter = function(value, path, flags) {\n        console.log(value, path, JSON.stringify(flags));\n    };\n});\n\nSET('common.value @touched', 5);\n// logs: 5 common.value {\"touched\":1}\n</script>\n```\n\n### setter2(value, path, flags)\n\nType: `delegate`\n\nReçoit chaque modification de la valeur, y compris celles écrites avec `rewrite()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur actuelle. |\n| `path` | `String` | yes |  | Le path qui a changé. |\n| `flags` | `Object` | yes |  | Les flags de la modification. |\n\nExample: Voir les valeurs qui contournent le setter\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = value => value && console.log('setter', value);\n    self.setter2 = value => value && console.log('setter2', value);\n});\n\ncom.rewrite(1);\n// logs: setter2 1\n</script>\n```\n\n### getter(value, [realtime])\n\nType: `delegate`\n\nTraite une valeur saisie par l'utilisateur et l'écrit dans le path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur saisie. |\n| `realtime` | `Boolean` | no | `false` | Écrit la valeur sans appeler le `setter`. |\n\nLa valeur passe par la fonction définie avec `parser()` et est convertie selon la clé de configuration `type`. Avec `realtime`, la valeur est écrite sans appeler le `setter`.\n\nExample: Écrire une valeur depuis le code\n```js\ncom.getter('5');\nconsole.log(common.value);\n// logs: 5\n```\n\n### validate(value)\n\nType: `delegate`\n\nDécide si la valeur est valide.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur à vérifier. |\n\nReturns: `Boolean` Le résultat de la validation. Une chaîne est aussi acceptée.\n\nRenvoie `true` ou une chaîne vide pour une valeur valide. Une chaîne renvoyée est stockée dans `config.invalid` comme message, et tout autre résultat définit `config.invalid` à `true`. La méthode s'exécute après chaque modification de la valeur.\n\nExample: Exiger une valeur\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.validate = value => value ? true : 'The value is required';\n});\n\nconsole.log(com.config.invalid);\n// logs: The value is required\nSET('common.value', 'x');\nconsole.log(com.config.invalid);\n// logs: false\n</script>\n```\n\n### state()\n\nType: `delegate`\n\nS'exécute quand l'état du composant change.\n\nLis l'état dans `config.touched`, `config.modified`, `config.invalid` et `config.disabled`.\n\nExample: Suivre l'état\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.state = () => console.log(!!config.touched);\n});\n\ncom.touch();\n// logs: true\n</script>\n```\n\n### state2(component)\n\nType: `delegate`\n\nS'exécute quand un autre composant ayant le même path signale son état.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Le composant qui signale l'état. |\n\nLe signalement se fait avec `validate2()` ou avec le flag `notify` de `bind()`.\n\nExample: Écouter un composant voisin\n```html\n<ui-component name=\"a\" path=\"common.value\"></ui-component>\n<ui-component name=\"b\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('a', function(self) {\n    window.com = self;\n});\n\nCOMPONENT('b', function(self) {\n    self.state2 = component => console.log(component.name);\n});\n\ncom.validate2();\n// logs: a\n</script>\n```\n\n### done()\n\nType: `delegate`\n\nS'exécute à la fin de l'initialisation, quand la valeur est définie.\n\n### destroy()\n\nType: `delegate`\n\nS'exécute quand l'instance est supprimée.\n\nIl est appelé par `remove()` et par le nettoyage régulier pour les éléments qui ont quitté la page. Libère ici les minuteurs et les gestionnaires globaux.\n\nExample: Nettoyer\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.destroy = () => console.log('destroyed');\n});\n\ncom.remove();\n// logs: destroyed\n</script>\n```\n\n### get()\n\nType: `method`\n\nLit la valeur située au path du composant.\n\nReturns: `Object` La valeur, ou `null` sans path.\n\nExample: Lire la valeur\n```js\nSET('common.value', 1);\nconsole.log(com.get());\n// logs: 1\n```\n\n### set(value, [flags])\n\nType: `method`\n\nÉcrit une valeur dans le path et notifie tout ce qui y est lié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur à écrire. |\n| `flags` | `String` | no |  | Des flags comme `@touched @modified`. |\n\nExample: Écrire la valeur\n```js\ncom.set(5, '@touched');\nconsole.log(common.value);\n// logs: 5\n```\n\n### rewrite(value, [flags])\n\nType: `method`\n\nÉcrit une valeur dans le path sans appeler le `setter` de cette instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur à écrire. |\n| `flags` | `String` | no |  | Des flags comme `@touched @modified`. |\n\nLes autres composants et les observateurs sont notifiés.\n\nExample: Écrire sans effectuer le rendu\n```js\ncom.rewrite(7);\nconsole.log(com.get());\n// logs: 7\n```\n\n### modify(value, [flags])\n\nType: `method`\n\nÉcrit une valeur et marque le composant comme touché et modifié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur à écrire. |\n| `flags` | `String` | no |  | Des flags comme `@touched @modified`. |\n\nExample: Écrire une valeur saisie par l'utilisateur\n```js\ncom.modify('x');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### push(value)\n\nType: `method`\n\nAjoute une valeur au tableau situé au path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | La valeur à écrire. |\n\nUn path vide est initialisé avec un nouveau tableau et une valeur seule est placée dans un tableau.\n\nExample: Ajouter un élément\n```js\ncom.push('a');\ncom.push('b');\nconsole.log(common.value.join());\n// logs: a,b\n```\n\n### upd([flags])\n\nType: `method`\n\nNotifie tout ce qui est lié au path, sans modifier la valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | no |  | Des flags comme `@touched @modified`. |\n\nLa méthode est aussi disponible sous le nom `update()`.\n\nExample: Annoncer une modification faite directement\n```js\ncommon.value = 5;\ncom.upd();\nconsole.log(com.get());\n// logs: 5\n```\n\n### refresh()\n\nType: `method`\n\nAppelle le `setter` avec la valeur actuelle.\n\nExample: Effectuer à nouveau le rendu\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = (value, path, flags) => flags.refresh && console.log('refresh');\n});\n\ncom.refresh();\n// logs: refresh\n</script>\n```\n\n### setPath(path)\n\nType: `method`\n\nChange le path du composant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le nouveau path. |\n\nUn `?` est remplacé par le path du plugin parent. Le `setter` n'est pas appelé avant la prochaine modification : appelle donc `refresh()` pour afficher la nouvelle valeur.\n\nExample: Faire pointer le composant vers une autre valeur\n```js\ncom.setPath('common.other');\nconsole.log(com.path.toString());\n// logs: common.other\n```\n\n### makepath(path)\n\nType: `method`\n\nRemplace le `?` d'un path par le path du plugin parent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nReturns: `String` Le path obtenu.\n\nExample: Résoudre un path relatif\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => console.log(self.makepath('?.items'));\n});\n// logs: orders.items\n</script>\n```\n\n### bind(flags, [value])\n\nType: `method`\n\nChange l'état du composant et écrit éventuellement une valeur sans appeler le `setter`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Les flags. |\n| `value` | `Object` | no |  | La valeur à écrire. |\n\nLes flags sont séparés par une espace, une virgule ou `|`, avec ou sans `@` :\n\n| Flag | Effet |\n| --- | --- |\n| `touched`, `touch` | Marque le composant comme touché. |\n| `modified`, `changed`, `modify`, `change` | Marque le composant comme modifié. |\n| `reset` | Efface l'état touché et modifié. |\n| `validate` | Exécute la validation. |\n| `notify` | Appelle `state2` des autres composants ayant le même path. |\n| `setter` | Appelle le `setter`. |\n\nExample: Marquer une valeur comme saisie par l'utilisateur\n```js\ncom.bind('@touched @modified', 'x');\nconsole.log(com.get(), com.element.attr('class'));\n// logs: x ui-touched ui-modified\n```\n\n### touch()\n\nType: `method`\n\nMarque le composant comme touché et exécute la validation.\n\nExample: Marquer comme touché\n```js\ncom.touch();\nconsole.log(com.config.touched);\n// logs: 1\n```\n\n### change()\n\nType: `method`\n\nMarque le composant comme touché et modifié et exécute la validation.\n\nExample: Marquer comme modifié\n```js\ncom.change();\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### reset([noemit])\n\nType: `method`\n\nEfface l'état touché et modifié.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noemit` | `Boolean` | no | `false` | Ignore la validation. |\n\nLa validation s'exécute sauf si `noemit` vaut `true`.\n\nExample: Effacer l'état\n```js\ncom.change();\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);\n// logs: 0 0\n```\n\n### isInvalid()\n\nType: `method`\n\nIndique si le composant est touché et invalide.\n\nReturns: `Boolean` Une valeur truthy quand le composant est touché et invalide.\n\nExample: Afficher une erreur seulement après le passage de l'utilisateur\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.validate = value => !!value;\n});\n\nconsole.log(!!com.isInvalid());\n// logs: false\ncom.touch();\nconsole.log(!!com.isInvalid());\n// logs: true\n</script>\n```\n\n### validate2([value])\n\nType: `method`\n\nExécute la validation et appelle `state2` des autres composants ayant le même path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | no |  | La valeur à valider. Par défaut, il s'agit de la valeur actuelle. |\n\n### reconfigure(value)\n\nType: `method`\n\nModifie la configuration et appelle `configure` pour chaque clé.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Les clés à modifier. |\n\nLa valeur est un objet ou une chaîne de la forme `key:value;key:value`. Elle accepte les clés spéciales de l'élément [ui-component](../ui-component/), comme `$class` et `=key`.\n\nExample: Modifier la configuration\n```js\ncom.reconfigure('title:Orders;limit:5');\nconsole.log(com.config.title, com.config.limit);\n// logs: Orders 5\n```\n\n### watchconfig(key, path)\n\nType: `method`\n\nMaintient une clé de configuration égale à la valeur d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La clé de configuration, ou `null`. |\n| `path` | `String` | yes |  | Le path à observer. |\n\nAvec `null` comme clé, l'objet situé au path est appliqué comme configuration.\n\nExample: Suivre une valeur\n```js\ncom.watchconfig('limit', 'common.limit');\nSET('common.limit', 10);\nconsole.log(com.config.limit);\n// logs: 10\n```\n\n### formatter(fn)\n\nType: `method`\n\nDéfinit une fonction qui convertit la valeur pour l'affichage, ou convertit une valeur avec cette fonction.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | Une fonction `(path, value, type, format)` qui renvoie la valeur à afficher, ou la valeur à convertir. |\n\nReturns: `Object` La valeur convertie, quand une valeur est fournie.\n\nAvec une fonction comme argument, le `setter` par défaut l'utilise à partir de ce moment. Avec toute autre valeur, la méthode renvoie la valeur convertie.\n\nExample: Formater un prix\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.formatter((path, value) => value ? '$' + value : '');\n});\n\nSET('common.value', 7);\nconsole.log($('input').val());\n// logs: $7\n</script>\n```\n\n### parser(fn)\n\nType: `method`\n\nDéfinit une fonction qui convertit la valeur saisie pour le modèle de données, ou convertit une valeur avec cette fonction.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | Une fonction `(path, value, type, format)` qui renvoie la valeur à stocker, ou la valeur à convertir. |\n\nReturns: `Object` La valeur convertie, quand une valeur est fournie.\n\nAvec une fonction comme argument, `getter()` l'utilise à partir de ce moment. Avec toute autre valeur, la méthode renvoie la valeur convertie.\n\nExample: Analyser un prix\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.parser((path, value) => value.replace('$', ''));\n});\n\ncom.getter('$9');\nconsole.log(common.value);\n// logs: 9\n</script>\n```\n\n### autobind20([delay], [realtimebinding])\n\nType: `method`\n\nConnecte au path les `input`, `select` et `textarea` situés dans l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `200` | Le délai en millisecondes. |\n| `realtimebinding` | `Boolean` | no | `false` | Appelle le `setter` également pendant que l'utilisateur saisit. |\n\nLa valeur est écrite après le délai, et les états touché et modifié sont mis à jour à partir des événements de l'utilisateur.\n\nExample: Lier un champ de saisie\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => self.autobind20(50);\n});\n\n$('input').val('typed').trigger('input');\nsetTimeout(() => console.log(common.value), 200);\n// logs: typed\n</script>\n```\n\n### autofill([enabled])\n\nType: `method`\n\nÉcrit dans le modèle de données les valeurs que le navigateur remplit tout seul.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enabled` | `Boolean` | no | `true` | `false` désactive la fonction. |\n\nUn navigateur peut remplir un formulaire avec des données enregistrées, comme un nom ou une adresse, sans aucun événement de saisie. Une seconde après le démarrage de la bibliothèque, elle lit le premier `input`, `textarea` ou `select` de chaque composant qui appelle cette méthode, et une valeur trouvée est écrite dans le path avec les flags `@change` et `@init`. Le parser du composant convertit d'abord la valeur.\n\nCela fonctionne avec le `setter` par défaut. Les composants avec un attribut `default`, les éléments `select` et les champs de type range sont ignorés. `autofill(false)` désactive la fonction.\n\nExample: Conserver une valeur remplie par le navigateur\n```html\n<ui-component name=\"login\" path=\"form.email\"><input type=\"email\" /></ui-component>\n\n<script>\nCOMPONENT('login', function(self) {\n    self.autofill();\n});\n\n// the browser fills the input with a saved address\nsetTimeout(() => $('input').val('ann@example.com'), 100);\n\nsetTimeout(() => console.log(GET('form.email')), 1500);\n// logs: ann@example.com\n</script>\n```\n\n### readonly()\n\nType: `method`\n\nTransforme le composant en simple affichage, sans `getter`, `setter` ni validation.\n\n### blind()\n\nType: `method`\n\nExclut le composant des notifications et des recherches par path.\n\n### singleton()\n\nType: `method`\n\nN'autorise qu'une seule instance du composant.\n\nLes autres éléments `<ui-component>` portant le même nom sont supprimés.\n\nExample: Conserver une seule instance\n```html\n<ui-component name=\"demo\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.singleton();\n});\n\nconsole.log($('ui-component').length);\n// logs: 1\n</script>\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nAppelle une fonction à chaque modification d'un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path à observer. |\n| `callback` | `Function` | yes |  | Une fonction `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Appelle immédiatement la fonction avec la valeur actuelle. |\n\nJoins plusieurs paths avec `+`. Avec une fonction comme premier argument, c'est le path du composant qui est observé. Un `?` est remplacé par le path du plugin parent.\n\nExample: Observer un autre path\n```js\ncom.watch('common.user', (value, flags, path) => console.log(value, path));\nSET('common.user', 'Anna');\n// logs: Anna common.user\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nSupprime les observateurs enregistrés avec `watch()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path observé. |\n| `callback` | `Function` | no |  | L'observateur à supprimer. |\n\nSans `callback`, tous les observateurs du path enregistrés par ce composant sont supprimés. Avec une fonction comme seul argument, c'est l'observateur du path du composant qui est supprimé. Relie plusieurs paths avec `+`. Un `?` est remplacé par le path du plugin parent.\n\nExample: Arrêter d'observer un path\n```js\nvar log = value => console.log('changed', value);\n\ncom.watch('common.count', log);\nSET('common.count', 1);\ncom.unwatch('common.count', log);\nSET('common.count', 2);\n// logs: changed 1\n```\n\n### datasource(path, callback, [init])\n\nType: `method`\n\nObserve un path contenant des données pour le composant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path à observer. |\n| `callback` | `Function` | yes |  | Une fonction `(value, flags, path)`. |\n| `init` | `Boolean` | no | `true` | Indique `false` pour ignorer le premier appel. |\n\nReturns: `Component` L'instance.\n\nLa fonction est appelée avec la valeur actuelle quand le composant s'initialise, sauf si `init` vaut `false`, puis à chaque modification. Un nouvel appel remplace la source de données enregistrée auparavant, et `datasource(null)` la supprime.\n\nExample: Afficher des éléments à partir d'un path\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nvar common = { items: ['a'] };\n\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.datasource('common.items', value => console.log(value.join()));\n    };\n});\n\nSET('common.items', ['a', 'b']);\n// logs: a\n// logs: a,b\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nEnregistre un gestionnaire d'un événement global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `callback` | `Function` | yes |  | Le gestionnaire. |\n\nJoins plusieurs noms d'événements avec `+`. Voir [Événements](../events/).\n\nExample: Gérer un événement\n```js\nvar handler = value => console.log(value);\ncom.on('refresh', handler);\nEMIT('refresh', 1);\ncom.off('refresh', handler);\nEMIT('refresh', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nSupprime un gestionnaire d'un événement global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `callback` | `Function` | no |  | Le gestionnaire à supprimer. |\n\nSans callback, tous les gestionnaires de l'événement enregistrés sur cette instance sont supprimés.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nÉmet un événement global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nExample: Émettre un événement\n```js\nON('saved', value => console.log(value));\ncom.emit('saved', 'ok');\n// logs: ok\n```\n\n### command(name, callback)\n\nType: `method`\n\nEnregistre une commande de cette instance.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la commande. |\n| `callback` | `Function` | yes |  | Le gestionnaire. |\n\nExample: Enregistrer et exécuter une commande\n```js\ncom.command('clear', value => console.log('clear', value));\ncom.CMD('clear', 1);\n// logs: clear 1\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nExécute une commande enregistrée sur cette instance avec `command()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la commande. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n| `e` | `Object` | no |  | Le cinquième argument. |\n\n### GET(path)\n\nType: `method`\n\nLit une valeur depuis un path. Un `?` est remplacé par le path du plugin parent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nReturns: `Object` La valeur.\n\nExample: Travailler avec le modèle de données du plugin\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.SET('?.count', 3);\n        console.log(self.GET('?.count'));\n    };\n});\n// logs: 3\n</script>\n```\n\n### SET(path, value)\n\nType: `method`\n\nÉcrit une valeur dans un path et notifie tout ce qui y est lié. Un `?` est remplacé par le path du plugin parent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n| `value` | `Object` | yes |  | La valeur à écrire. |\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une fonction ou une méthode de plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Par exemple `FUNC.save`, `?/save` ou `@save`. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nUn `?` est remplacé par le path du plugin parent. Un nom qui commence par `@` appelle une méthode du composant parent le plus proche.\n\nExample: Appeler une méthode du composant parent\n```html\n<ui-component name=\"parent\">\n    <ui-component name=\"child\"></ui-component>\n</ui-component>\n\n<script>\nCOMPONENT('parent', function(self) {\n    self.refreshlist = value => console.log('parent', value);\n});\n\nCOMPONENT('child', function(self) {\n    window.com = self;\n});\n\ncom.EXEC('@refreshlist', 1);\n// logs: parent 1\n</script>\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une méthode de plugin ou une fonction globale, ou écrit le premier argument dans le path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La méthode, la fonction ou le path. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nLa forme `plugin/method` appelle une méthode du plugin et le nom d'une fonction globale appelle cette fonction. Tout autre nom est un path qui reçoit `a`.\n\nExample: Écrire dans un path\n```js\ncom.SEEX('common.status', 'done');\nconsole.log(common.status);\n// logs: done\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une méthode de composants dans toute la page, sous la forme `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La cible, par exemple `grid/refresh`. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nExample: Appeler une méthode d'un autre composant\n```html\n<ui-component name=\"grid\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.SETTER('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### find(selector)\n\nType: `method`\n\nTrouve des éléments à l'intérieur du composant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un sélecteur, ou un objet de sélecteurs. |\n\nReturns: `jQuery` Les éléments trouvés, ou un objet qui les contient.\n\nAvec un objet, la méthode recherche chaque sélecteur et renvoie un objet ayant les mêmes clés.\n\nExample: Trouver des éléments\n```html\n<ui-component name=\"demo\"><input /><b></b></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\nconsole.log(com.find('input').length, com.find({ title: 'b' }).title.length);\n// logs: 1 1\n</script>\n```\n\n### closest(selector)\n\nType: `method`\n\nTrouve le parent le plus proche qui correspond à un sélecteur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un sélecteur jQuery. |\n\nReturns: `jQuery` L'élément trouvé.\n\nExample: Trouver un parent\n```js\nconsole.log(com.closest('body')[0].tagName);\n// logs: BODY\n```\n\n### parent([selector])\n\nType: `method`\n\nTrouve un élément parent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Le sélecteur. |\n\nReturns: `jQuery` L'élément trouvé.\n\nSans argument, la méthode renvoie le parent direct. Ces valeurs sont aussi prises en charge :\n\n| Sélecteur | Résultat |\n| --- | --- |\n| `auto` | Le parent le plus proche dont le style définit une hauteur, ou `window` |\n| `window` | L'objet `window` sous forme jQuery |\n| `document` | Le `document` sous forme jQuery |\n| `parent` suivi d'un nombre | Le parent situé ce nombre de niveaux au-dessus du parent direct |\n| toute autre valeur | Le parent le plus proche qui correspond au sélecteur |\n\nExample: Lire le parent direct\n```js\nconsole.log(com.parent()[0].tagName);\n// logs: BODY\n```\n\n### html([value])\n\nType: `method`\n\nLit ou remplace le HTML de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | Le nouveau contenu. |\n\nReturns: `jQuery` L'élément, ou le HTML actuel sans argument.\n\nUn tableau est joint en une seule chaîne.\n\nExample: Définir le contenu\n```js\ncom.html(['<b>', 'Hello', '</b>']);\nconsole.log(com.html());\n// logs: <b>Hello</b>\n```\n\n### text([value])\n\nType: `method`\n\nLit ou remplace le texte de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | Le nouveau texte. |\n\nReturns: `jQuery` L'élément, ou le texte actuel sans argument.\n\nUn tableau est joint en une seule chaîne.\n\nExample: Définir le texte\n```js\ncom.text('Hello');\nconsole.log(com.text());\n// logs: Hello\n```\n\n### append(value)\n\nType: `method`\n\nAjoute du HTML à la fin de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Le contenu. |\n\nReturns: `jQuery` L'élément.\n\nUn tableau est joint en une seule chaîne.\n\nExample: Ajouter du contenu\n```js\ncom.append('<i></i>');\ncom.append(['<b>', '</b>']);\nconsole.log(com.html());\n// logs: <i></i><b></b>\n```\n\n### empty()\n\nType: `method`\n\nSupprime le contenu de l'élément.\n\nReturns: `Component` L'instance.\n\n### attr(name, [value])\n\nType: `method`\n\nLit ou définit un attribut de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | L'attribut. |\n| `value` | `String` | no |  | La nouvelle valeur. |\n\nReturns: `Object` La valeur en lecture, l'instance en écriture.\n\nExample: Attributs\n```js\ncom.attr('title', 'Hello');\ncom.attrd('id', 5);\nconsole.log(com.attr('title'), com.attrd('id'));\n// logs: Hello 5\n```\n\n### attrd(name, [value])\n\nType: `method`\n\nLit ou définit un attribut `data-` de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom sans le préfixe `data-`. |\n| `value` | `String` | no |  | La nouvelle valeur. |\n\nReturns: `String` La valeur en lecture.\n\n### css(name, [value])\n\nType: `method`\n\nLit ou définit une propriété CSS de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La propriété. |\n| `value` | `String` | no |  | La nouvelle valeur. |\n\nReturns: `Object` La valeur en lecture, l'instance en écriture.\n\nExample: Modifier un style\n```js\ncom.css('color', 'red');\nconsole.log(com.css('color'));\n// logs: rgb(255, 0, 0)\n```\n\n### aclass(name, [timeout])\n\nType: `method`\n\nAjoute une classe CSS à l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La classe. |\n| `timeout` | `Number` | no |  | Un délai en millisecondes. |\n\nReturns: `Component` L'instance.\n\nExample: Travailler avec les classes\n```js\ncom.aclass('a b');\ncom.rclass('a');\ncom.tclass('c');\nconsole.log(com.element.attr('class'), com.hclass('c'));\n// logs: b c true\n```\n\n### rclass([name], [timeout])\n\nType: `method`\n\nRetire une classe CSS de l'élément, ou toutes les classes sans argument.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | La classe. |\n| `timeout` | `Number` | no |  | Un délai en millisecondes. |\n\nReturns: `Component` L'instance.\n\n### rclass2(search)\n\nType: `method`\n\nRetire toutes les classes CSS qui contiennent un texte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String` | yes |  | Le texte à rechercher. |\n\nReturns: `Component` L'instance.\n\nExample: Retirer un groupe de classes\n```js\ncom.aclass('size-1 size-2 box');\ncom.rclass2('size-');\nconsole.log(com.element.attr('class'));\n// logs: box\n```\n\n### tclass(name, [enable])\n\nType: `method`\n\nBascule une classe CSS sur l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La classe. |\n| `enable` | `Boolean` | no |  | Force l'état de la classe. |\n\nReturns: `Component` L'instance.\n\n### hclass(name)\n\nType: `method`\n\nIndique si l'élément possède une classe CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La classe. |\n\nReturns: `Boolean` `true` quand la classe est présente.\n\n### width()\n\nType: `method`\n\nRenvoie la largeur de l'élément en pixels.\n\nReturns: `Number` La largeur.\n\n### height()\n\nType: `method`\n\nRenvoie la hauteur de l'élément en pixels.\n\nReturns: `Number` La hauteur.\n\n### event(name, [selector], callback)\n\nType: `method`\n\nEnregistre un gestionnaire d'événement DOM sur l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | L'événement DOM. |\n| `selector` | `String` | no |  | Limite l'événement aux enfants correspondants. |\n| `callback` | `Function` | yes |  | Le gestionnaire. |\n\nReturns: `Component` L'instance.\n\nLes arguments sont transmis à la méthode jQuery `.on()`.\n\nExample: Gérer un clic\n```html\n<ui-component name=\"demo\"><button>Save</button></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.event('click', 'button', () => console.log('clicked'));\n    };\n});\n\n$('button').trigger('click');\n// logs: clicked\n</script>\n```\n\n### autofocus([selector])\n\nType: `method`\n\nDéplace le focus vers le premier contrôle visible de l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Les éléments à cibler pour le focus. |\n\nReturns: `Component` L'instance.\n\nLe sélecteur par défaut est `input,select,textarea`. Quand aucun contrôle ne peut encore recevoir le focus, la méthode réessaie toutes les 200 millisecondes, 15 fois au maximum. Le focus n'est pas déplacé sur les appareils mobiles.\n\nExample: Donner le focus au premier champ de saisie\n```html\n<ui-component name=\"demo\"><input id=\"first\" /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.autofocus();\nconsole.log(document.activeElement.id);\n// logs: first\n</script>\n```\n\n### import(url, [callback], [prepare])\n\nType: `method`\n\nTélécharge du contenu et l'ajoute à l'élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'adresse. |\n| `callback` | `Function` | no |  | S'exécute quand le contenu est dans la page. |\n| `prepare` | `Function` | no |  | Une fonction `(html)` qui renvoie le contenu à insérer. |\n\nVoir `IMPORT()` dans [Importer du contenu](../../guides/importing/).\n\nExample: Importer une partie\n```js\ncom.import('/parts/help.html', () => console.log(com.html()), html => html + '<hr>');\n// logs: <p>Help</p><hr>\n```\n\n### replace(target, [remove])\n\nType: `method`\n\nDéplace le composant vers un autre élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Element` | yes |  | Le nouvel élément, sous forme de sélecteur, d'élément DOM ou d'objet jQuery. |\n| `remove` | `Boolean` | no | `false` | Supprime l'élément d'origine. |\n\nReturns: `Component` L'instance.\n\nAvec `remove`, l'élément d'origine est retiré de la page.\n\nExample: Déplacer le composant\n```js\ncom.replace('#box', true);\nconsole.log(com.dom.id, $('ui-component').length);\n// logs: box 0\n```\n\n### remove()\n\nType: `method`\n\nAppelle `destroy` et supprime le composant et son élément.\n\n### icon(value)\n\nType: `method`\n\nAjoute à un nom d'icône le préfixe d'icône de `DEF.iconprefix`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Le nom de l'icône. |\n\nReturns: `String` Les classes CSS de l'icône.\n\nUne valeur contenant une espace inclut déjà son préfixe et reste inchangée.\n\nExample: Construire les classes d'une icône\n```js\nconsole.log(com.icon('home'));\n// logs: ti ti-home\nconsole.log(com.icon('fa fa-home'));\n// logs: fa fa-home\n```\n\n### caniuse(name)\n\nType: `method`\n\nTrouve le premier composant déclaré dans une liste de noms séparés par une virgule ou par `|`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Les noms. |\n\nReturns: `String` Le nom trouvé, ou `false`.\n\nExample: Choisir un composant disponible\n```js\nconsole.log(com.caniuse('missing,demo'));\n// logs: demo\nconsole.log(com.caniuse('missing|demo'));\n// logs: demo\nconsole.log(com.caniuse('missing'));\n// logs: false\n```\n\n### parseSource(value)\n\nType: `method`\n\nAnalyse une liste de la forme `id|name|icon,id|name|icon`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | La liste. |\n\nReturns: `Array` Des objets avec `id`, `name` et `icon`.\n\nLa méthode est aussi disponible sous le nom `parsesource()`. Quand la clé de configuration `type` vaut `number`, les identifiants sont convertis en nombres.\n\nExample: Analyser une liste\n```js\nvar items = com.parseSource('1|One,2|Two|home');\nconsole.log(JSON.stringify(items[1]));\n// logs: {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n","entries":[{"type":"property","name":"id","signature":"id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"ID","since":"","deprecated":false},{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"def","signature":"def","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"delegate","name":"init()","signature":"init()","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"configure()","signature":"configure(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter()","signature":"setter(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"setter2()","signature":"setter2(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"getter()","signature":"getter(value, [realtime])","since":"","deprecated":false},{"type":"delegate","name":"validate()","signature":"validate(value)","since":"","deprecated":false},{"type":"delegate","name":"state()","signature":"state()","since":"","deprecated":false},{"type":"delegate","name":"state2()","signature":"state2(component)","since":"","deprecated":false},{"type":"delegate","name":"done()","signature":"done()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(value, [flags])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"rewrite(value, [flags])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"modify(value, [flags])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(value)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd([flags])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"refresh()","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"setPath(path)","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"touch()","signature":"touch()","since":"","deprecated":false},{"type":"method","name":"change()","signature":"change()","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"reset([noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"validate2([value])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"reconfigure(value)","since":"","deprecated":false},{"type":"method","name":"watchconfig()","signature":"watchconfig(key, path)","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"formatter(fn)","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"parser(fn)","since":"","deprecated":false},{"type":"method","name":"autobind20()","signature":"autobind20([delay], [realtimebinding])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"autofill([enabled])","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"readonly()","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"blind()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"singleton()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"empty()","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"css()","signature":"css(name, [value])","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"aclass(name, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"rclass([name], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"tclass(name, [enable])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"hclass(name)","since":"","deprecated":false},{"type":"method","name":"width()","signature":"width()","since":"","deprecated":false},{"type":"method","name":"height()","signature":"height()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"import(url, [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"replace(target, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"remove()","since":"","deprecated":false},{"type":"method","name":"icon()","signature":"icon(value)","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"caniuse(name)","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"parseSource(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcOG2ad61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Componente","summary":"Le proprietà, i metodi e i delegate di un'istanza di componente.","markdown":"---\ntitle: Componente\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Componente\n\n> Le proprietà, i metodi e i delegate di un'istanza di componente.\n\nUn'istanza di componente è il primo argomento della funzione passata a `COMPONENT()`. Viene creata per ogni elemento [ui-component](../ui-component/). La guida [Creare componenti](../../guides/creating-components/) mostra come le varie parti lavorano insieme.\n\n## API\n\n### id\n\nType: `property`\n\nL'identificatore dell'istanza.\n\nReturns: `String` L'identificatore dell'istanza.\n\nIl valore viene generato e la chiave di configurazione `$id` lo sostituisce.\n\n### ID\n\nType: `property`\n\nL'identificatore generato dell'istanza.\n\nReturns: `String` L'identificatore generato dell'istanza.\n\nLa chiave di configurazione `$id` non lo modifica.\n\n### name\n\nType: `property`\n\nIl nome del componente.\n\nReturns: `String` Il nome del componente.\n\n### path\n\nType: `property`\n\nIl path del componente, oppure `null` quando l'elemento non ne ha uno.\n\nReturns: `Path` Il path del componente, oppure `null` quando l'elemento non ne ha uno.\n\nVedi [Path](../path/).\n\n### config\n\nType: `property`\n\nLa configurazione corrente.\n\nReturns: `Object` La configurazione corrente.\n\nModificala con `reconfigure()`, in modo che venga chiamato `configure`.\n\n### element\n\nType: `property`\n\nL'elemento `<ui-component>` come oggetto jQuery.\n\nReturns: `jQuery` L'elemento `<ui-component>` come oggetto jQuery.\n\n### dom\n\nType: `property`\n\nL'elemento `<ui-component>`.\n\nReturns: `HTMLElement` L'elemento `<ui-component>`.\n\n### plugin\n\nType: `property`\n\nIl plugin genitore, oppure `null`.\n\nReturns: `Plugin` Il plugin genitore, oppure `null`.\n\nVedi [Plugin](../plugin/).\n\n### scope\n\nType: `property`\n\nL'oggetto rispetto al quale vengono risolti i path, cioè `window`.\n\nReturns: `Object` L'oggetto rispetto al quale vengono risolti i path, cioè `window`.\n\n### cls\n\nType: `property`\n\nIl nome della classe CSS del componente, ad esempio `ui-grid`.\n\nReturns: `String` Il nome della classe CSS del componente, ad esempio `ui-grid`.\n\nLa classe non viene aggiunta automaticamente all'elemento.\n\n### def\n\nType: `property`\n\nUna funzione che restituisce il valore dell'attributo `default`. Esiste solo quando l'attributo viene usato.\n\nReturns: `Function` Una funzione che restituisce il valore dell'attributo `default`. Esiste solo quando l'attributo viene usato.\n\n### ready\n\nType: `property`\n\nÈ `true` quando l'istanza inizia a inizializzarsi.\n\nReturns: `Boolean` È `true` quando l'istanza inizia a inizializzarsi.\n\n### init()\n\nType: `delegate`\n\nViene eseguito una volta per dichiarazione, per la prima istanza del componente.\n\nViene eseguito prima di `make`. Usalo per il lavoro condiviso da tutte le istanze.\n\nExample: L'ordine dei delegate\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.init = () => console.log('init');\n    self.make = () => console.log('make');\n    self.configure = key => console.log('configure', key);\n    self.setter = () => console.log('setter');\n    self.done = () => console.log('done');\n});\n// logs: init\n// logs: make\n// logs: setter\n// logs: done\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nViene eseguito quando viene creata l'istanza.\n\nCostruisci qui il contenuto dell'elemento.\n\n### configure(key, value, init, prev)\n\nType: `delegate`\n\nViene eseguito per ogni chiave di configurazione quando la configurazione cambia.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La chiave di configurazione. |\n| `value` | `Object` | yes |  | Il nuovo valore. |\n| `init` | `Boolean` | yes |  | `true` durante l'inizializzazione. |\n| `prev` | `Object` | yes |  | Il valore precedente, oppure `null` durante l'inizializzazione. |\n\nViene eseguito per tutte le chiavi quando il componente si inizializza.\n\nExample: Reagisci a una chiave di configurazione\n```html\n<ui-component name=\"demo\" config=\"title:Hello\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.configure = function(key, value, init, prev) {\n        key === 'title' && console.log(value, !!init, prev);\n    };\n    self.make = () => setTimeout(() => self.reconfigure({ title: 'Bye' }), 100);\n});\n// logs: Hello true null\n// logs: Bye false Hello\n</script>\n```\n\n### setter(value, path, flags)\n\nType: `delegate`\n\nRiceve ogni modifica del valore nel path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore corrente. |\n| `path` | `String` | yes |  | Il path che è cambiato. |\n| `flags` | `Object` | yes |  | I flag della modifica, ad esempio `{ init: 1 }`. |\n\nL'implementazione predefinita scrive il valore nel primo `input`, `textarea` o `select` all'interno dell'elemento. Una casella di controllo viene selezionata quando il valore, come testo, è `true`, `1`, `on`, `yes` o `ok`. Assegna una tua funzione per renderizzare il valore.\n\nExample: Renderizza il valore\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.setter = function(value, path, flags) {\n        console.log(value, path, JSON.stringify(flags));\n    };\n});\n\nSET('common.value @touched', 5);\n// logs: 5 common.value {\"touched\":1}\n</script>\n```\n\n### setter2(value, path, flags)\n\nType: `delegate`\n\nRiceve ogni modifica del valore, comprese quelle scritte con `rewrite()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore corrente. |\n| `path` | `String` | yes |  | Il path che è cambiato. |\n| `flags` | `Object` | yes |  | I flag della modifica. |\n\nExample: Vedi i valori che saltano il setter\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = value => value && console.log('setter', value);\n    self.setter2 = value => value && console.log('setter2', value);\n});\n\ncom.rewrite(1);\n// logs: setter2 1\n</script>\n```\n\n### getter(value, [realtime])\n\nType: `delegate`\n\nElabora un valore inserito dall'utente e lo scrive nel path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore inserito. |\n| `realtime` | `Boolean` | no | `false` | Scrive il valore senza chiamare il `setter`. |\n\nIl valore passa attraverso la funzione impostata con `parser()` e viene convertito in base alla chiave di configurazione `type`. Con `realtime`, il valore viene scritto senza chiamare il `setter`.\n\nExample: Scrivi un valore dal codice\n```js\ncom.getter('5');\nconsole.log(common.value);\n// logs: 5\n```\n\n### validate(value)\n\nType: `delegate`\n\nStabilisce se il valore è valido.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore da controllare. |\n\nReturns: `Boolean` Il risultato della validazione. È accettata anche una stringa.\n\nRestituisci `true` o una stringa vuota per un valore valido. Una stringa restituita viene memorizzata in `config.invalid` come messaggio, mentre qualsiasi altro risultato imposta `config.invalid` su `true`. Il metodo viene eseguito dopo ogni modifica del valore.\n\nExample: Richiedi un valore\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.validate = value => value ? true : 'The value is required';\n});\n\nconsole.log(com.config.invalid);\n// logs: The value is required\nSET('common.value', 'x');\nconsole.log(com.config.invalid);\n// logs: false\n</script>\n```\n\n### state()\n\nType: `delegate`\n\nViene eseguito quando cambia lo stato del componente.\n\nLeggi lo stato da `config.touched`, `config.modified`, `config.invalid` e `config.disabled`.\n\nExample: Segui lo stato\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.state = () => console.log(!!config.touched);\n});\n\ncom.touch();\n// logs: true\n</script>\n```\n\n### state2(component)\n\nType: `delegate`\n\nViene eseguito quando un altro componente con lo stesso path comunica il proprio stato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Il componente che comunica lo stato. |\n\nLa comunicazione avviene con `validate2()` o con il flag `notify` di `bind()`.\n\nExample: Ascolta un componente fratello\n```html\n<ui-component name=\"a\" path=\"common.value\"></ui-component>\n<ui-component name=\"b\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('a', function(self) {\n    window.com = self;\n});\n\nCOMPONENT('b', function(self) {\n    self.state2 = component => console.log(component.name);\n});\n\ncom.validate2();\n// logs: a\n</script>\n```\n\n### done()\n\nType: `delegate`\n\nViene eseguito alla fine dell'inizializzazione, quando il valore è impostato.\n\n### destroy()\n\nType: `delegate`\n\nViene eseguito quando l'istanza viene rimossa.\n\nViene chiamato da `remove()` e dalla pulizia periodica per gli elementi usciti dalla pagina. Rilascia qui i timer e i gestori globali.\n\nExample: Fai pulizia\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.destroy = () => console.log('destroyed');\n});\n\ncom.remove();\n// logs: destroyed\n</script>\n```\n\n### get()\n\nType: `method`\n\nLegge il valore nel path del componente.\n\nReturns: `Object` Il valore, oppure `null` senza un path.\n\nExample: Leggi il valore\n```js\nSET('common.value', 1);\nconsole.log(com.get());\n// logs: 1\n```\n\n### set(value, [flags])\n\nType: `method`\n\nScrive un valore nel path e notifica tutto ciò che è associato a esso.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore da scrivere. |\n| `flags` | `String` | no |  | Flag come `@touched @modified`. |\n\nExample: Scrivi il valore\n```js\ncom.set(5, '@touched');\nconsole.log(common.value);\n// logs: 5\n```\n\n### rewrite(value, [flags])\n\nType: `method`\n\nScrive un valore nel path senza chiamare il `setter` di questa istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore da scrivere. |\n| `flags` | `String` | no |  | Flag come `@touched @modified`. |\n\nGli altri componenti e gli osservatori vengono notificati.\n\nExample: Scrivi senza renderizzare\n```js\ncom.rewrite(7);\nconsole.log(com.get());\n// logs: 7\n```\n\n### modify(value, [flags])\n\nType: `method`\n\nScrive un valore e segna il componente come toccato e modificato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore da scrivere. |\n| `flags` | `String` | no |  | Flag come `@touched @modified`. |\n\nExample: Scrivi un valore inserito dall'utente\n```js\ncom.modify('x');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### push(value)\n\nType: `method`\n\nAggiunge un valore all'array nel path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Il valore da scrivere. |\n\nUn path vuoto viene inizializzato con un nuovo array e un valore singolo viene racchiuso in un array.\n\nExample: Aggiungi un elemento\n```js\ncom.push('a');\ncom.push('b');\nconsole.log(common.value.join());\n// logs: a,b\n```\n\n### upd([flags])\n\nType: `method`\n\nNotifica tutto ciò che è associato al path, senza modificare il valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | no |  | Flag come `@touched @modified`. |\n\nIl metodo è disponibile anche come `update()`.\n\nExample: Annuncia una modifica fatta direttamente\n```js\ncommon.value = 5;\ncom.upd();\nconsole.log(com.get());\n// logs: 5\n```\n\n### refresh()\n\nType: `method`\n\nChiama il `setter` con il valore corrente.\n\nExample: Renderizza di nuovo\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = (value, path, flags) => flags.refresh && console.log('refresh');\n});\n\ncom.refresh();\n// logs: refresh\n</script>\n```\n\n### setPath(path)\n\nType: `method`\n\nCambia il path del componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il nuovo path. |\n\nUn `?` viene sostituito con il path del plugin genitore. Il `setter` non viene chiamato fino alla modifica successiva, quindi chiama `refresh()` per renderizzare il nuovo valore.\n\nExample: Punta il componente a un altro valore\n```js\ncom.setPath('common.other');\nconsole.log(com.path.toString());\n// logs: common.other\n```\n\n### makepath(path)\n\nType: `method`\n\nSostituisce il `?` in un path con il path del plugin genitore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nReturns: `String` Il path risultante.\n\nExample: Risolvi un path relativo\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => console.log(self.makepath('?.items'));\n});\n// logs: orders.items\n</script>\n```\n\n### bind(flags, [value])\n\nType: `method`\n\nCambia lo stato del componente e, facoltativamente, scrive un valore senza chiamare il `setter`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | I flag. |\n| `value` | `Object` | no |  | Il valore da scrivere. |\n\nI flag sono separati da uno spazio, da una virgola o da `|`, con o senza `@`:\n\n| Flag | Effetto |\n| --- | --- |\n| `touched`, `touch` | Segna il componente come toccato. |\n| `modified`, `changed`, `modify`, `change` | Segna il componente come modificato. |\n| `reset` | Azzera lo stato toccato e modificato. |\n| `validate` | Esegue la validazione. |\n| `notify` | Chiama `state2` degli altri componenti con lo stesso path. |\n| `setter` | Chiama il `setter`. |\n\nExample: Segna un valore come inserito dall'utente\n```js\ncom.bind('@touched @modified', 'x');\nconsole.log(com.get(), com.element.attr('class'));\n// logs: x ui-touched ui-modified\n```\n\n### touch()\n\nType: `method`\n\nSegna il componente come toccato ed esegue la validazione.\n\nExample: Segna come toccato\n```js\ncom.touch();\nconsole.log(com.config.touched);\n// logs: 1\n```\n\n### change()\n\nType: `method`\n\nSegna il componente come toccato e modificato ed esegue la validazione.\n\nExample: Segna come modificato\n```js\ncom.change();\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### reset([noemit])\n\nType: `method`\n\nAzzera lo stato toccato e modificato.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noemit` | `Boolean` | no | `false` | Salta la validazione. |\n\nLa validazione viene eseguita a meno che `noemit` non sia `true`.\n\nExample: Azzera lo stato\n```js\ncom.change();\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);\n// logs: 0 0\n```\n\n### isInvalid()\n\nType: `method`\n\nIndica se il componente è toccato e non valido.\n\nReturns: `Boolean` Un valore truthy quando il componente è toccato e non valido.\n\nExample: Mostra un errore solo dopo che l'utente è passato di qui\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.validate = value => !!value;\n});\n\nconsole.log(!!com.isInvalid());\n// logs: false\ncom.touch();\nconsole.log(!!com.isInvalid());\n// logs: true\n</script>\n```\n\n### validate2([value])\n\nType: `method`\n\nEsegue la validazione e chiama `state2` degli altri componenti con lo stesso path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | no |  | Il valore da validare. Per impostazione predefinita è il valore corrente. |\n\n### reconfigure(value)\n\nType: `method`\n\nCambia la configurazione e chiama `configure` per ogni chiave.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Le chiavi da modificare. |\n\nIl valore è un oggetto o una stringa nella forma `key:value;key:value`. Accetta le chiavi speciali dell'elemento [ui-component](../ui-component/), come `$class` e `=key`.\n\nExample: Cambia la configurazione\n```js\ncom.reconfigure('title:Orders;limit:5');\nconsole.log(com.config.title, com.config.limit);\n// logs: Orders 5\n```\n\n### watchconfig(key, path)\n\nType: `method`\n\nMantiene una chiave di configurazione uguale al valore in un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | La chiave di configurazione, oppure `null`. |\n| `path` | `String` | yes |  | Il path da osservare. |\n\nCon `null` come chiave, l'oggetto nel path viene applicato come configurazione.\n\nExample: Segui un valore\n```js\ncom.watchconfig('limit', 'common.limit');\nSET('common.limit', 10);\nconsole.log(com.config.limit);\n// logs: 10\n```\n\n### formatter(fn)\n\nType: `method`\n\nImposta una funzione che converte il valore per la visualizzazione, oppure converte un valore con essa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | Una funzione `(path, value, type, format)` che restituisce il valore da visualizzare, oppure il valore da convertire. |\n\nReturns: `Object` Il valore convertito, quando viene passato un valore.\n\nCon una funzione come argomento, il `setter` predefinito la usa da quel momento in poi. Con qualsiasi altro valore, il metodo restituisce il valore convertito.\n\nExample: Formatta un prezzo\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.formatter((path, value) => value ? '$' + value : '');\n});\n\nSET('common.value', 7);\nconsole.log($('input').val());\n// logs: $7\n</script>\n```\n\n### parser(fn)\n\nType: `method`\n\nImposta una funzione che converte il valore inserito per il modello, oppure converte un valore con essa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | Una funzione `(path, value, type, format)` che restituisce il valore da memorizzare, oppure il valore da convertire. |\n\nReturns: `Object` Il valore convertito, quando viene passato un valore.\n\nCon una funzione come argomento, `getter()` la usa da quel momento in poi. Con qualsiasi altro valore, il metodo restituisce il valore convertito.\n\nExample: Analizza un prezzo\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.parser((path, value) => value.replace('$', ''));\n});\n\ncom.getter('$9');\nconsole.log(common.value);\n// logs: 9\n</script>\n```\n\n### autobind20([delay], [realtimebinding])\n\nType: `method`\n\nCollega al path gli elementi `input`, `select` e `textarea` all'interno dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `200` | Il ritardo in millisecondi. |\n| `realtimebinding` | `Boolean` | no | `false` | Chiama il `setter` anche mentre l'utente digita. |\n\nIl valore viene scritto dopo il ritardo, e gli stati toccato e modificato vengono aggiornati in base agli eventi dell'utente.\n\nExample: Associa un input\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => self.autobind20(50);\n});\n\n$('input').val('typed').trigger('input');\nsetTimeout(() => console.log(common.value), 200);\n// logs: typed\n</script>\n```\n\n### autofill([enabled])\n\nType: `method`\n\nScrive nel modello i valori che il browser compila da solo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enabled` | `Boolean` | no | `true` | `false` disattiva la funzione. |\n\nUn browser può compilare un modulo con dati salvati, come un nome o un indirizzo, senza alcun evento di input. Un secondo dopo l'avvio della libreria, legge il primo `input`, `textarea` o `select` di ogni componente che chiama questo metodo, e un valore trovato lì viene scritto nel path con i flag `@change` e `@init`. Il parser del componente converte prima il valore.\n\nFunziona con il `setter` predefinito. I componenti con un attributo `default`, gli elementi `select` e gli input di tipo range vengono saltati. `autofill(false)` lo disattiva.\n\nExample: Mantieni un valore compilato dal browser\n```html\n<ui-component name=\"login\" path=\"form.email\"><input type=\"email\" /></ui-component>\n\n<script>\nCOMPONENT('login', function(self) {\n    self.autofill();\n});\n\n// the browser fills the input with a saved address\nsetTimeout(() => $('input').val('ann@example.com'), 100);\n\nsetTimeout(() => console.log(GET('form.email')), 1500);\n// logs: ann@example.com\n</script>\n```\n\n### readonly()\n\nType: `method`\n\nTrasforma il componente in un semplice elemento di visualizzazione, senza `getter`, `setter` e validazione.\n\n### blind()\n\nType: `method`\n\nEsclude il componente dalle notifiche e dalle ricerche per path.\n\n### singleton()\n\nType: `method`\n\nConsente una sola istanza del componente.\n\nGli altri elementi `<ui-component>` con lo stesso nome vengono rimossi.\n\nExample: Mantieni una sola istanza\n```html\n<ui-component name=\"demo\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.singleton();\n});\n\nconsole.log($('ui-component').length);\n// logs: 1\n</script>\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nChiama una funzione a ogni modifica in un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path da osservare. |\n| `callback` | `Function` | yes |  | Una funzione `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Chiama subito la funzione con il valore corrente. |\n\nUnisci più path con `+`. Con una funzione come primo argomento, viene osservato il path del componente. Un `?` viene sostituito con il path del plugin genitore.\n\nExample: Osserva un altro path\n```js\ncom.watch('common.user', (value, flags, path) => console.log(value, path));\nSET('common.user', 'Anna');\n// logs: Anna common.user\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nRimuove gli osservatori registrati con `watch()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path osservato. |\n| `callback` | `Function` | no |  | L'osservatore da rimuovere. |\n\nSenza `callback`, vengono rimossi tutti gli osservatori del path registrati da questo componente. Con una funzione come unico argomento, viene rimosso l'osservatore del path del componente. Unisci più path con `+`. Un `?` viene sostituito con il path del plugin genitore.\n\nExample: Smetti di osservare un path\n```js\nvar log = value => console.log('changed', value);\n\ncom.watch('common.count', log);\nSET('common.count', 1);\ncom.unwatch('common.count', log);\nSET('common.count', 2);\n// logs: changed 1\n```\n\n### datasource(path, callback, [init])\n\nType: `method`\n\nOsserva un path con i dati per il componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path da osservare. |\n| `callback` | `Function` | yes |  | Una funzione `(value, flags, path)`. |\n| `init` | `Boolean` | no | `true` | Imposta `false` per saltare la prima chiamata. |\n\nReturns: `Component` L'istanza.\n\nLa funzione viene chiamata con il valore corrente quando il componente si inizializza, a meno che `init` non sia `false`, e a ogni modifica. Una nuova chiamata sostituisce la sorgente dati registrata prima e `datasource(null)` la rimuove.\n\nExample: Renderizza gli elementi da un path\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nvar common = { items: ['a'] };\n\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.datasource('common.items', value => console.log(value.join()));\n    };\n});\n\nSET('common.items', ['a', 'b']);\n// logs: a\n// logs: a,b\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nRegistra un gestore di un evento globale.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `callback` | `Function` | yes |  | Il gestore. |\n\nUnisci più nomi di eventi con `+`. Vedi [Eventi](../events/).\n\nExample: Gestisci un evento\n```js\nvar handler = value => console.log(value);\ncom.on('refresh', handler);\nEMIT('refresh', 1);\ncom.off('refresh', handler);\nEMIT('refresh', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nRimuove un gestore di un evento globale.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `callback` | `Function` | no |  | Il gestore da rimuovere. |\n\nSenza un callback, vengono rimossi tutti i gestori dell'evento registrati su questa istanza.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nEmette un evento globale.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nExample: Emetti un evento\n```js\nON('saved', value => console.log(value));\ncom.emit('saved', 'ok');\n// logs: ok\n```\n\n### command(name, callback)\n\nType: `method`\n\nRegistra un comando di questa istanza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del comando. |\n| `callback` | `Function` | yes |  | Il gestore. |\n\nExample: Registra ed esegui un comando\n```js\ncom.command('clear', value => console.log('clear', value));\ncom.CMD('clear', 1);\n// logs: clear 1\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nEsegue un comando registrato su questa istanza con `command()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del comando. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n| `e` | `Object` | no |  | Il quinto argomento. |\n\n### GET(path)\n\nType: `method`\n\nLegge un valore da un path. Un `?` viene sostituito con il path del plugin genitore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nReturns: `Object` Il valore.\n\nExample: Lavora con il modello del plugin\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.SET('?.count', 3);\n        console.log(self.GET('?.count'));\n    };\n});\n// logs: 3\n</script>\n```\n\n### SET(path, value)\n\nType: `method`\n\nScrive un valore in un path e notifica tutto ciò che è associato a esso. Un `?` viene sostituito con il path del plugin genitore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n| `value` | `Object` | yes |  | Il valore da scrivere. |\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nChiama una funzione o un metodo di un plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Ad esempio `FUNC.save`, `?/save` o `@save`. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nUn `?` viene sostituito con il path del plugin genitore. Un nome che inizia con `@` chiama un metodo del componente genitore più vicino.\n\nExample: Chiama un metodo del componente genitore\n```html\n<ui-component name=\"parent\">\n    <ui-component name=\"child\"></ui-component>\n</ui-component>\n\n<script>\nCOMPONENT('parent', function(self) {\n    self.refreshlist = value => console.log('parent', value);\n});\n\nCOMPONENT('child', function(self) {\n    window.com = self;\n});\n\ncom.EXEC('@refreshlist', 1);\n// logs: parent 1\n</script>\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nChiama un metodo di un plugin o una funzione globale, oppure scrive il primo argomento nel path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il metodo, la funzione o il path. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nLa forma `plugin/method` chiama un metodo del plugin e il nome di una funzione globale chiama quella funzione. Qualsiasi altro nome è un path che riceve `a`.\n\nExample: Scrivi in un path\n```js\ncom.SEEX('common.status', 'done');\nconsole.log(common.status);\n// logs: done\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nChiama un metodo dei componenti in tutta la pagina, nella forma `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La destinazione, ad esempio `grid/refresh`. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nExample: Chiama un metodo di un altro componente\n```html\n<ui-component name=\"grid\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.SETTER('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### find(selector)\n\nType: `method`\n\nTrova gli elementi all'interno del componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selettore, oppure un oggetto con i selettori. |\n\nReturns: `jQuery` Gli elementi trovati, oppure un oggetto che li contiene.\n\nCon un oggetto, il metodo cerca ogni selettore e restituisce un oggetto con le stesse chiavi.\n\nExample: Trova gli elementi\n```html\n<ui-component name=\"demo\"><input /><b></b></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\nconsole.log(com.find('input').length, com.find({ title: 'b' }).title.length);\n// logs: 1 1\n</script>\n```\n\n### closest(selector)\n\nType: `method`\n\nTrova il genitore più vicino che corrisponde a un selettore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selettore jQuery. |\n\nReturns: `jQuery` L'elemento trovato.\n\nExample: Trova un genitore\n```js\nconsole.log(com.closest('body')[0].tagName);\n// logs: BODY\n```\n\n### parent([selector])\n\nType: `method`\n\nTrova un elemento genitore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Il selettore. |\n\nReturns: `jQuery` L'elemento trovato.\n\nSenza argomento, il metodo restituisce il genitore diretto. Sono supportati anche questi valori:\n\n| Selettore | Risultato |\n| --- | --- |\n| `auto` | Il genitore più vicino con un'altezza impostata nel suo stile, oppure `window` |\n| `window` | L'oggetto `window` come jQuery |\n| `document` | Il `document` come jQuery |\n| `parent` seguito da un numero | Il genitore che si trova quel numero di livelli sopra il genitore diretto |\n| qualsiasi altro valore | Il genitore più vicino che corrisponde al selettore |\n\nExample: Leggi il genitore diretto\n```js\nconsole.log(com.parent()[0].tagName);\n// logs: BODY\n```\n\n### html([value])\n\nType: `method`\n\nLegge o sostituisce l'HTML dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | Il nuovo contenuto. |\n\nReturns: `jQuery` L'elemento, oppure l'HTML corrente senza argomento.\n\nUn array viene unito in un'unica stringa.\n\nExample: Imposta il contenuto\n```js\ncom.html(['<b>', 'Hello', '</b>']);\nconsole.log(com.html());\n// logs: <b>Hello</b>\n```\n\n### text([value])\n\nType: `method`\n\nLegge o sostituisce il testo dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | Il nuovo testo. |\n\nReturns: `jQuery` L'elemento, oppure il testo corrente senza argomento.\n\nUn array viene unito in un'unica stringa.\n\nExample: Imposta il testo\n```js\ncom.text('Hello');\nconsole.log(com.text());\n// logs: Hello\n```\n\n### append(value)\n\nType: `method`\n\nAggiunge HTML alla fine dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Il contenuto. |\n\nReturns: `jQuery` L'elemento.\n\nUn array viene unito in un'unica stringa.\n\nExample: Aggiungi contenuto\n```js\ncom.append('<i></i>');\ncom.append(['<b>', '</b>']);\nconsole.log(com.html());\n// logs: <i></i><b></b>\n```\n\n### empty()\n\nType: `method`\n\nRimuove il contenuto dell'elemento.\n\nReturns: `Component` L'istanza.\n\n### attr(name, [value])\n\nType: `method`\n\nLegge o imposta un attributo dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | L'attributo. |\n| `value` | `String` | no |  | Il nuovo valore. |\n\nReturns: `Object` Il valore in lettura, l'istanza in scrittura.\n\nExample: Attributi\n```js\ncom.attr('title', 'Hello');\ncom.attrd('id', 5);\nconsole.log(com.attr('title'), com.attrd('id'));\n// logs: Hello 5\n```\n\n### attrd(name, [value])\n\nType: `method`\n\nLegge o imposta un attributo `data-` dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome senza il prefisso `data-`. |\n| `value` | `String` | no |  | Il nuovo valore. |\n\nReturns: `String` Il valore in lettura.\n\n### css(name, [value])\n\nType: `method`\n\nLegge o imposta una proprietà CSS dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La proprietà. |\n| `value` | `String` | no |  | Il nuovo valore. |\n\nReturns: `Object` Il valore in lettura, l'istanza in scrittura.\n\nExample: Cambia uno stile\n```js\ncom.css('color', 'red');\nconsole.log(com.css('color'));\n// logs: rgb(255, 0, 0)\n```\n\n### aclass(name, [timeout])\n\nType: `method`\n\nAggiunge una classe CSS all'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La classe. |\n| `timeout` | `Number` | no |  | Un ritardo in millisecondi. |\n\nReturns: `Component` L'istanza.\n\nExample: Lavora con le classi\n```js\ncom.aclass('a b');\ncom.rclass('a');\ncom.tclass('c');\nconsole.log(com.element.attr('class'), com.hclass('c'));\n// logs: b c true\n```\n\n### rclass([name], [timeout])\n\nType: `method`\n\nRimuove una classe CSS dall'elemento, oppure tutte le classi senza argomento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | La classe. |\n| `timeout` | `Number` | no |  | Un ritardo in millisecondi. |\n\nReturns: `Component` L'istanza.\n\n### rclass2(search)\n\nType: `method`\n\nRimuove tutte le classi CSS che contengono un testo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String` | yes |  | Il testo da cercare. |\n\nReturns: `Component` L'istanza.\n\nExample: Rimuovi un gruppo di classi\n```js\ncom.aclass('size-1 size-2 box');\ncom.rclass2('size-');\nconsole.log(com.element.attr('class'));\n// logs: box\n```\n\n### tclass(name, [enable])\n\nType: `method`\n\nAttiva o disattiva una classe CSS sull'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La classe. |\n| `enable` | `Boolean` | no |  | Forza lo stato della classe. |\n\nReturns: `Component` L'istanza.\n\n### hclass(name)\n\nType: `method`\n\nIndica se l'elemento ha una classe CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La classe. |\n\nReturns: `Boolean` `true` quando la classe è presente.\n\n### width()\n\nType: `method`\n\nRestituisce la larghezza dell'elemento in pixel.\n\nReturns: `Number` La larghezza.\n\n### height()\n\nType: `method`\n\nRestituisce l'altezza dell'elemento in pixel.\n\nReturns: `Number` L'altezza.\n\n### event(name, [selector], callback)\n\nType: `method`\n\nRegistra un gestore di eventi DOM sull'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | L'evento DOM. |\n| `selector` | `String` | no |  | Limita l'evento ai figli corrispondenti. |\n| `callback` | `Function` | yes |  | Il gestore. |\n\nReturns: `Component` L'istanza.\n\nGli argomenti vengono passati al metodo `.on()` di jQuery.\n\nExample: Gestisci un clic\n```html\n<ui-component name=\"demo\"><button>Save</button></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.event('click', 'button', () => console.log('clicked'));\n    };\n});\n\n$('button').trigger('click');\n// logs: clicked\n</script>\n```\n\n### autofocus([selector])\n\nType: `method`\n\nSposta il focus sul primo controllo visibile all'interno dell'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Gli elementi a cui dare il focus. |\n\nReturns: `Component` L'istanza.\n\nIl selettore predefinito è `input,select,textarea`. Quando nessun controllo può ancora ricevere il focus, il metodo riprova ogni 200 millisecondi, al massimo 15 volte. Sui dispositivi mobili il focus non viene spostato.\n\nExample: Dai il focus al primo input\n```html\n<ui-component name=\"demo\"><input id=\"first\" /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.autofocus();\nconsole.log(document.activeElement.id);\n// logs: first\n</script>\n```\n\n### import(url, [callback], [prepare])\n\nType: `method`\n\nScarica i contenuti e li aggiunge all'elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'indirizzo. |\n| `callback` | `Function` | no |  | Viene eseguito quando il contenuto è nella pagina. |\n| `prepare` | `Function` | no |  | Una funzione `(html)` che restituisce il contenuto da inserire. |\n\nVedi `IMPORT()` in [Importare contenuti](../../guides/importing/).\n\nExample: Importa una parte\n```js\ncom.import('/parts/help.html', () => console.log(com.html()), html => html + '<hr>');\n// logs: <p>Help</p><hr>\n```\n\n### replace(target, [remove])\n\nType: `method`\n\nSposta il componente in un altro elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Element` | yes |  | Il nuovo elemento, come selettore, elemento DOM o jQuery. |\n| `remove` | `Boolean` | no | `false` | Rimuove l'elemento originale. |\n\nReturns: `Component` L'istanza.\n\nCon `remove`, l'elemento originale viene rimosso dalla pagina.\n\nExample: Sposta il componente\n```js\ncom.replace('#box', true);\nconsole.log(com.dom.id, $('ui-component').length);\n// logs: box 0\n```\n\n### remove()\n\nType: `method`\n\nChiama `destroy` e rimuove il componente e il suo elemento.\n\n### icon(value)\n\nType: `method`\n\nAggiunge a un nome di icona il prefisso delle icone indicato in `DEF.iconprefix`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Il nome dell'icona. |\n\nReturns: `String` Le classi CSS dell'icona.\n\nUn valore con uno spazio contiene già il suo prefisso e resta invariato.\n\nExample: Costruisci le classi delle icone\n```js\nconsole.log(com.icon('home'));\n// logs: ti ti-home\nconsole.log(com.icon('fa fa-home'));\n// logs: fa fa-home\n```\n\n### caniuse(name)\n\nType: `method`\n\nTrova il primo componente dichiarato in un elenco di nomi separati da una virgola o da `|`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | I nomi. |\n\nReturns: `String` Il nome trovato, oppure `false`.\n\nExample: Scegli un componente disponibile\n```js\nconsole.log(com.caniuse('missing,demo'));\n// logs: demo\nconsole.log(com.caniuse('missing|demo'));\n// logs: demo\nconsole.log(com.caniuse('missing'));\n// logs: false\n```\n\n### parseSource(value)\n\nType: `method`\n\nAnalizza un elenco nella forma `id|name|icon,id|name|icon`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | L'elenco. |\n\nReturns: `Array` Oggetti con `id`, `name` e `icon`.\n\nIl metodo è disponibile anche come `parsesource()`. Quando la chiave di configurazione `type` è `number`, gli identificatori vengono convertiti in numeri.\n\nExample: Analizza un elenco\n```js\nvar items = com.parseSource('1|One,2|Two|home');\nconsole.log(JSON.stringify(items[1]));\n// logs: {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n","entries":[{"type":"property","name":"id","signature":"id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"ID","since":"","deprecated":false},{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"def","signature":"def","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"delegate","name":"init()","signature":"init()","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"configure()","signature":"configure(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter()","signature":"setter(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"setter2()","signature":"setter2(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"getter()","signature":"getter(value, [realtime])","since":"","deprecated":false},{"type":"delegate","name":"validate()","signature":"validate(value)","since":"","deprecated":false},{"type":"delegate","name":"state()","signature":"state()","since":"","deprecated":false},{"type":"delegate","name":"state2()","signature":"state2(component)","since":"","deprecated":false},{"type":"delegate","name":"done()","signature":"done()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(value, [flags])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"rewrite(value, [flags])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"modify(value, [flags])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(value)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd([flags])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"refresh()","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"setPath(path)","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"touch()","signature":"touch()","since":"","deprecated":false},{"type":"method","name":"change()","signature":"change()","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"reset([noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"validate2([value])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"reconfigure(value)","since":"","deprecated":false},{"type":"method","name":"watchconfig()","signature":"watchconfig(key, path)","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"formatter(fn)","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"parser(fn)","since":"","deprecated":false},{"type":"method","name":"autobind20()","signature":"autobind20([delay], [realtimebinding])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"autofill([enabled])","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"readonly()","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"blind()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"singleton()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"empty()","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"css()","signature":"css(name, [value])","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"aclass(name, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"rclass([name], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"tclass(name, [enable])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"hclass(name)","since":"","deprecated":false},{"type":"method","name":"width()","signature":"width()","since":"","deprecated":false},{"type":"method","name":"height()","signature":"height()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"import(url, [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"replace(target, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"remove()","since":"","deprecated":false},{"type":"method","name":"icon()","signature":"icon(value)","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"caniuse(name)","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"parseSource(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcOG2ad61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/component/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Component","summary":"Vlastnosti, metódy a delegate inštancie komponentu.","markdown":"---\ntitle: Component\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/component/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Component\n\n> Vlastnosti, metódy a delegate inštancie komponentu.\n\nInštancia komponentu je prvým argumentom funkcie odovzdanej do `COMPONENT()`. Vytvára sa pre každý element [ui-component](../ui-component/). Ako jednotlivé časti spolupracujú, ukazuje príručka [Vytváranie komponentov](../../guides/creating-components/).\n\n## API\n\n### id\n\nType: `property`\n\nIdentifikátor inštancie.\n\nReturns: `String` Identifikátor inštancie.\n\nHodnota sa generuje a nahrádza ju konfiguračný kľúč `$id`.\n\n### ID\n\nType: `property`\n\nVygenerovaný identifikátor inštancie.\n\nReturns: `String` Vygenerovaný identifikátor inštancie.\n\nKonfiguračný kľúč `$id` ho nemení.\n\n### name\n\nType: `property`\n\nNázov komponentu.\n\nReturns: `String` Názov komponentu.\n\n### path\n\nType: `property`\n\nPath komponentu alebo `null`, keď ho element nemá.\n\nReturns: `Path` Path komponentu alebo `null`, keď ho element nemá.\n\nPozri [Path](../path/).\n\n### config\n\nType: `property`\n\nAktuálna konfigurácia.\n\nReturns: `Object` Aktuálna konfigurácia.\n\nMeň ju pomocou `reconfigure()`, aby sa zavolalo `configure`.\n\n### element\n\nType: `property`\n\nElement `<ui-component>` ako objekt jQuery.\n\nReturns: `jQuery` Element `<ui-component>` ako objekt jQuery.\n\n### dom\n\nType: `property`\n\nElement `<ui-component>`.\n\nReturns: `HTMLElement` Element `<ui-component>`.\n\n### plugin\n\nType: `property`\n\nNadradený plugin alebo `null`.\n\nReturns: `Plugin` Nadradený plugin alebo `null`.\n\nPozri [Plugin](../plugin/).\n\n### scope\n\nType: `property`\n\nObjekt, voči ktorému sa vyhodnocujú paths, teda `window`.\n\nReturns: `Object` Objekt, voči ktorému sa vyhodnocujú paths, teda `window`.\n\n### cls\n\nType: `property`\n\nNázov triedy CSS komponentu, napríklad `ui-grid`.\n\nReturns: `String` Názov triedy CSS komponentu, napríklad `ui-grid`.\n\nTrieda sa do elementu nepridáva automaticky.\n\n### def\n\nType: `property`\n\nFunkcia, ktorá vracia hodnotu atribútu `default`. Existuje iba vtedy, keď sa atribút používa.\n\nReturns: `Function` Funkcia, ktorá vracia hodnotu atribútu `default`. Existuje iba vtedy, keď sa atribút používa.\n\n### ready\n\nType: `property`\n\nJe `true`, len čo sa inštancia začne inicializovať.\n\nReturns: `Boolean` Je `true`, len čo sa inštancia začne inicializovať.\n\n### init()\n\nType: `delegate`\n\nSpustí sa raz za deklaráciu, pre prvú inštanciu komponentu.\n\nSpustí sa pred `make`. Použi ho na prácu spoločnú pre všetky inštancie.\n\nExample: Poradie delegate\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.init = () => console.log('init');\n    self.make = () => console.log('make');\n    self.configure = key => console.log('configure', key);\n    self.setter = () => console.log('setter');\n    self.done = () => console.log('done');\n});\n// logs: init\n// logs: make\n// logs: setter\n// logs: done\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nSpustí sa pri vytvorení inštancie.\n\nTu vytvor obsah elementu.\n\n### configure(key, value, init, prev)\n\nType: `delegate`\n\nSpustí sa pre každý konfiguračný kľúč, keď sa konfigurácia zmení.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Konfiguračný kľúč. |\n| `value` | `Object` | yes |  | Nová hodnota. |\n| `init` | `Boolean` | yes |  | `true` počas inicializácie. |\n| `prev` | `Object` | yes |  | Predchádzajúca hodnota alebo `null` počas inicializácie. |\n\nPri inicializácii komponentu sa spustí pre všetky kľúče.\n\nExample: Zareaguj na konfiguračný kľúč\n```html\n<ui-component name=\"demo\" config=\"title:Hello\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.configure = function(key, value, init, prev) {\n        key === 'title' && console.log(value, !!init, prev);\n    };\n    self.make = () => setTimeout(() => self.reconfigure({ title: 'Bye' }), 100);\n});\n// logs: Hello true null\n// logs: Bye false Hello\n</script>\n```\n\n### setter(value, path, flags)\n\nType: `delegate`\n\nDostane každú zmenu hodnoty na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Aktuálna hodnota. |\n| `path` | `String` | yes |  | Path, ktorý sa zmenil. |\n| `flags` | `Object` | yes |  | Flagy zmeny, napríklad `{ init: 1 }`. |\n\nPredvolená implementácia zapíše hodnotu do prvého prvku `input`, `textarea` alebo `select` vnútri elementu. Zaškrtávacie políčko sa zaškrtne, keď je hodnota ako text `true`, `1`, `on`, `yes` alebo `ok`. Na vykreslenie hodnoty priraď vlastnú funkciu.\n\nExample: Vykresli hodnotu\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.setter = function(value, path, flags) {\n        console.log(value, path, JSON.stringify(flags));\n    };\n});\n\nSET('common.value @touched', 5);\n// logs: 5 common.value {\"touched\":1}\n</script>\n```\n\n### setter2(value, path, flags)\n\nType: `delegate`\n\nDostane každú zmenu hodnoty vrátane zmien zapísaných pomocou `rewrite()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Aktuálna hodnota. |\n| `path` | `String` | yes |  | Path, ktorý sa zmenil. |\n| `flags` | `Object` | yes |  | Flagy zmeny. |\n\nExample: Pozri si hodnoty, ktoré obchádzajú setter\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = value => value && console.log('setter', value);\n    self.setter2 = value => value && console.log('setter2', value);\n});\n\ncom.rewrite(1);\n// logs: setter2 1\n</script>\n```\n\n### getter(value, [realtime])\n\nType: `delegate`\n\nSpracuje hodnotu zadanú používateľom a zapíše ju na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Zadaná hodnota. |\n| `realtime` | `Boolean` | no | `false` | Zapíše hodnotu bez volania `setter`. |\n\nHodnota prejde funkciou nastavenou pomocou `parser()` a prevedie sa podľa konfiguračného kľúča `type`. S `realtime` sa hodnota zapíše bez volania `setter`.\n\nExample: Zapíš hodnotu z kódu\n```js\ncom.getter('5');\nconsole.log(common.value);\n// logs: 5\n```\n\n### validate(value)\n\nType: `delegate`\n\nRozhodne, či je hodnota platná.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota na kontrolu. |\n\nReturns: `Boolean` Výsledok validácie. Prijíma sa aj reťazec.\n\nPre platnú hodnotu vráť `true` alebo prázdny reťazec. Vrátený reťazec sa uloží do `config.invalid` ako správa a každý iný výsledok nastaví `config.invalid` na `true`. Metóda sa spúšťa po každej zmene hodnoty.\n\nExample: Vyžaduj hodnotu\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.validate = value => value ? true : 'The value is required';\n});\n\nconsole.log(com.config.invalid);\n// logs: The value is required\nSET('common.value', 'x');\nconsole.log(com.config.invalid);\n// logs: false\n</script>\n```\n\n### state()\n\nType: `delegate`\n\nSpustí sa, keď sa zmení stav komponentu.\n\nStav prečítaj z `config.touched`, `config.modified`, `config.invalid` a `config.disabled`.\n\nExample: Sleduj stav\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self, config) {\n    window.com = self;\n    self.state = () => console.log(!!config.touched);\n});\n\ncom.touch();\n// logs: true\n</script>\n```\n\n### state2(component)\n\nType: `delegate`\n\nSpustí sa, keď iný komponent s rovnakým path oznámi svoj stav.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `component` | `Component` | yes |  | Komponent, ktorý oznamuje stav. |\n\nStav sa oznamuje pomocou `validate2()` alebo flagu `notify` metódy `bind()`.\n\nExample: Počúvaj susedný komponent\n```html\n<ui-component name=\"a\" path=\"common.value\"></ui-component>\n<ui-component name=\"b\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('a', function(self) {\n    window.com = self;\n});\n\nCOMPONENT('b', function(self) {\n    self.state2 = component => console.log(component.name);\n});\n\ncom.validate2();\n// logs: a\n</script>\n```\n\n### done()\n\nType: `delegate`\n\nSpustí sa na konci inicializácie, keď je hodnota nastavená.\n\n### destroy()\n\nType: `delegate`\n\nSpustí sa pri odstránení inštancie.\n\nVolá ho `remove()` a pravidelné čistenie pre elementy, ktoré opustili stránku. Tu uvoľni časovače a globálne obslužné funkcie.\n\nExample: Upratuj\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.destroy = () => console.log('destroyed');\n});\n\ncom.remove();\n// logs: destroyed\n</script>\n```\n\n### get()\n\nType: `method`\n\nPrečíta hodnotu na path komponentu.\n\nReturns: `Object` Hodnota, alebo `null`, ak path nie je.\n\nExample: Prečítaj hodnotu\n```js\nSET('common.value', 1);\nconsole.log(com.get());\n// logs: 1\n```\n\n### set(value, [flags])\n\nType: `method`\n\nZapíše hodnotu na path a upozorní všetko, čo je naň naviazané.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota na zápis. |\n| `flags` | `String` | no |  | Flagy ako `@touched @modified`. |\n\nExample: Zapíš hodnotu\n```js\ncom.set(5, '@touched');\nconsole.log(common.value);\n// logs: 5\n```\n\n### rewrite(value, [flags])\n\nType: `method`\n\nZapíše hodnotu na path bez volania `setter` tejto inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota na zápis. |\n| `flags` | `String` | no |  | Flagy ako `@touched @modified`. |\n\nOstatné komponenty a sledovače sa upozornia.\n\nExample: Zapíš bez vykresľovania\n```js\ncom.rewrite(7);\nconsole.log(com.get());\n// logs: 7\n```\n\n### modify(value, [flags])\n\nType: `method`\n\nZapíše hodnotu a označí komponent ako dotknutý a upravený.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota na zápis. |\n| `flags` | `String` | no |  | Flagy ako `@touched @modified`. |\n\nExample: Zapíš hodnotu zadanú používateľom\n```js\ncom.modify('x');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### push(value)\n\nType: `method`\n\nPridá hodnotu do poľa na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Hodnota na zápis. |\n\nPrázdny path sa inicializuje novým poľom a jednotlivá hodnota sa zabalí do poľa.\n\nExample: Pridaj položku\n```js\ncom.push('a');\ncom.push('b');\nconsole.log(common.value.join());\n// logs: a,b\n```\n\n### upd([flags])\n\nType: `method`\n\nUpozorní všetko naviazané na path bez zmeny hodnoty.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | no |  | Flagy ako `@touched @modified`. |\n\nMetóda je dostupná aj ako `update()`.\n\nExample: Oznám priamo vykonanú zmenu\n```js\ncommon.value = 5;\ncom.upd();\nconsole.log(com.get());\n// logs: 5\n```\n\n### refresh()\n\nType: `method`\n\nZavolá `setter` s aktuálnou hodnotou.\n\nExample: Vykresli znova\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.setter = (value, path, flags) => flags.refresh && console.log('refresh');\n});\n\ncom.refresh();\n// logs: refresh\n</script>\n```\n\n### setPath(path)\n\nType: `method`\n\nZmení path komponentu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Nový path. |\n\nZnak `?` sa nahradí path nadradeného pluginu. `setter` sa zavolá až pri ďalšej zmene, preto na vykreslenie novej hodnoty zavolaj `refresh()`.\n\nExample: Nasmeruj komponent na inú hodnotu\n```js\ncom.setPath('common.other');\nconsole.log(com.path.toString());\n// logs: common.other\n```\n\n### makepath(path)\n\nType: `method`\n\nNahradí znak `?` v path za path nadradeného pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nReturns: `String` Výsledný path.\n\nExample: Vyhodnoť relatívny path\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => console.log(self.makepath('?.items'));\n});\n// logs: orders.items\n</script>\n```\n\n### bind(flags, [value])\n\nType: `method`\n\nZmení stav komponentu a voliteľne zapíše hodnotu bez volania `setter`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `flags` | `String` | yes |  | Flagy. |\n| `value` | `Object` | no |  | Hodnota na zápis. |\n\nFlagy sa oddeľujú medzerou, čiarkou alebo znakom `|`, s `@` alebo bez neho:\n\n| Flag | Účinok |\n| --- | --- |\n| `touched`, `touch` | Označí komponent ako dotknutý. |\n| `modified`, `changed`, `modify`, `change` | Označí komponent ako upravený. |\n| `reset` | Vymaže stav dotknutia a úpravy. |\n| `validate` | Spustí validáciu. |\n| `notify` | Zavolá `state2` ostatných komponentov s rovnakým path. |\n| `setter` | Zavolá `setter`. |\n\nExample: Označ hodnotu ako zadanú používateľom\n```js\ncom.bind('@touched @modified', 'x');\nconsole.log(com.get(), com.element.attr('class'));\n// logs: x ui-touched ui-modified\n```\n\n### touch()\n\nType: `method`\n\nOznačí komponent ako dotknutý a spustí validáciu.\n\nExample: Označ ako dotknutý\n```js\ncom.touch();\nconsole.log(com.config.touched);\n// logs: 1\n```\n\n### change()\n\nType: `method`\n\nOznačí komponent ako dotknutý a upravený a spustí validáciu.\n\nExample: Označ ako zmenený\n```js\ncom.change();\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\n```\n\n### reset([noemit])\n\nType: `method`\n\nVymaže stav dotknutia a úpravy.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noemit` | `Boolean` | no | `false` | Preskočí validáciu. |\n\nValidácia sa spustí, pokiaľ `noemit` nie je `true`.\n\nExample: Vymaž stav\n```js\ncom.change();\ncom.reset();\nconsole.log(com.config.touched, com.config.modified);\n// logs: 0 0\n```\n\n### isInvalid()\n\nType: `method`\n\nZistí, či je komponent dotknutý a neplatný.\n\nReturns: `Boolean` Pravdivá hodnota, keď je komponent dotknutý a neplatný.\n\nExample: Zobraz chybu až potom, čo tu používateľ bol\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.validate = value => !!value;\n});\n\nconsole.log(!!com.isInvalid());\n// logs: false\ncom.touch();\nconsole.log(!!com.isInvalid());\n// logs: true\n</script>\n```\n\n### validate2([value])\n\nType: `method`\n\nSpustí validáciu a zavolá `state2` ostatných komponentov s rovnakým path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | no |  | Hodnota na validáciu. Predvolene aktuálna hodnota. |\n\n### reconfigure(value)\n\nType: `method`\n\nZmení konfiguráciu a zavolá `configure` pre každý kľúč.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `Object` | yes |  | Kľúče na zmenu. |\n\nHodnota je objekt alebo reťazec v tvare `key:value;key:value`. Prijíma špeciálne kľúče elementu [ui-component](../ui-component/), napríklad `$class` a `=key`.\n\nExample: Zmeň konfiguráciu\n```js\ncom.reconfigure('title:Orders;limit:5');\nconsole.log(com.config.title, com.config.limit);\n// logs: Orders 5\n```\n\n### watchconfig(key, path)\n\nType: `method`\n\nUdržiava konfiguračný kľúč rovný hodnote na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Konfiguračný kľúč alebo `null`. |\n| `path` | `String` | yes |  | Path, ktorá sa má sledovať. |\n\nS `null` ako kľúčom sa objekt na path použije ako konfigurácia.\n\nExample: Sleduj hodnotu\n```js\ncom.watchconfig('limit', 'common.limit');\nSET('common.limit', 10);\nconsole.log(com.config.limit);\n// logs: 10\n```\n\n### formatter(fn)\n\nType: `method`\n\nNastaví funkciu, ktorá prevádza hodnotu na zobrazenie, alebo ňou prevedie hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | Funkcia `(path, value, type, format)`, ktorá vracia hodnotu na zobrazenie, alebo hodnota na prevod. |\n\nReturns: `Object` Prevedená hodnota, ak je hodnota zadaná.\n\nS funkciou ako argumentom ju odvtedy používa predvolený `setter`. S akoukoľvek inou hodnotou metóda vráti prevedenú hodnotu.\n\nExample: Naformátuj cenu\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.formatter((path, value) => value ? '$' + value : '');\n});\n\nSET('common.value', 7);\nconsole.log($('input').val());\n// logs: $7\n</script>\n```\n\n### parser(fn)\n\nType: `method`\n\nNastaví funkciu, ktorá prevádza zadanú hodnotu pre model, alebo ňou prevedie hodnotu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `fn` | `Function` | yes |  | Funkcia `(path, value, type, format)`, ktorá vracia hodnotu na uloženie, alebo hodnota na prevod. |\n\nReturns: `Object` Prevedená hodnota, ak je hodnota zadaná.\n\nS funkciou ako argumentom ju odvtedy používa `getter()`. S akoukoľvek inou hodnotou metóda vráti prevedenú hodnotu.\n\nExample: Analyzuj cenu\n```html\n<ui-component name=\"demo\" path=\"common.value\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n    self.parser((path, value) => value.replace('$', ''));\n});\n\ncom.getter('$9');\nconsole.log(common.value);\n// logs: 9\n</script>\n```\n\n### autobind20([delay], [realtimebinding])\n\nType: `method`\n\nPrepojí prvky `input`, `select` a `textarea` vnútri elementu s path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `delay` | `Number` | no | `200` | Oneskorenie v milisekundách. |\n| `realtimebinding` | `Boolean` | no | `false` | Volá `setter` aj počas písania používateľa. |\n\nHodnota sa zapíše po oneskorení a stavy dotknutia a úpravy sa aktualizujú z udalostí používateľa.\n\nExample: Naviaž vstupné pole\n```html\n<ui-component name=\"demo\" path=\"common.value\"><input /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = () => self.autobind20(50);\n});\n\n$('input').val('typed').trigger('input');\nsetTimeout(() => console.log(common.value), 200);\n// logs: typed\n</script>\n```\n\n### autofill([enabled])\n\nType: `method`\n\nZapíše do modelu hodnoty, ktoré prehliadač vyplní sám.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `enabled` | `Boolean` | no | `true` | `false` túto funkciu vypne. |\n\nPrehliadač môže vyplniť formulár uloženými údajmi, napríklad menom alebo adresou, bez akejkoľvek udalosti vstupu. Sekundu po štarte knižnica prečíta prvý `input`, `textarea` alebo `select` každého komponentu, ktorý túto metódu volá, a hodnotu, ktorú tam nájde, zapíše do path s flagmi `@change` a `@init`. Parser komponentu hodnotu najprv prevedie.\n\nFunguje to s predvoleným `setter`. Komponenty s atribútom `default`, elementy `select` a posuvné vstupy (range) sa preskočia. `autofill(false)` to vypne.\n\nExample: Ponechaj hodnotu, ktorú vyplnil prehliadač\n```html\n<ui-component name=\"login\" path=\"form.email\"><input type=\"email\" /></ui-component>\n\n<script>\nCOMPONENT('login', function(self) {\n    self.autofill();\n});\n\n// the browser fills the input with a saved address\nsetTimeout(() => $('input').val('ann@example.com'), 100);\n\nsetTimeout(() => console.log(GET('form.email')), 1500);\n// logs: ann@example.com\n</script>\n```\n\n### readonly()\n\nType: `method`\n\nZmení komponent na zobrazenie bez `getter`, `setter` a validácie.\n\n### blind()\n\nType: `method`\n\nVylúči komponent z upozornení a z vyhľadávania podľa path.\n\n### singleton()\n\nType: `method`\n\nPovolí iba jednu inštanciu komponentu.\n\nOstatné elementy `<ui-component>` s rovnakým názvom sa odstránia.\n\nExample: Ponechaj jednu inštanciu\n```html\n<ui-component name=\"demo\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.singleton();\n});\n\nconsole.log($('ui-component').length);\n// logs: 1\n</script>\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nZavolá funkciu pri každej zmene na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, ktorá sa má sledovať. |\n| `callback` | `Function` | yes |  | Funkcia `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Zavolá funkciu hneď s aktuálnou hodnotou. |\n\nViacero paths spoj znakom `+`. S funkciou ako prvým argumentom sa sleduje path komponentu. Znak `?` sa nahradí path nadradeného pluginu.\n\nExample: Sleduj iný path\n```js\ncom.watch('common.user', (value, flags, path) => console.log(value, path));\nSET('common.user', 'Anna');\n// logs: Anna common.user\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nOdstráni sledovače zaregistrované cez `watch()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Sledovaný path. |\n| `callback` | `Function` | no |  | Sledovač, ktorý sa má odstrániť. |\n\nBez `callback` sa odstránia všetky sledovače daného path, ktoré zaregistroval tento komponent. S funkciou ako jediným argumentom sa odstráni sledovač path komponentu. Viac paths spoj znakom `+`. Znak `?` sa nahradí path nadradeného pluginu.\n\nExample: Prestaň sledovať path\n```js\nvar log = value => console.log('changed', value);\n\ncom.watch('common.count', log);\nSET('common.count', 1);\ncom.unwatch('common.count', log);\nSET('common.count', 2);\n// logs: changed 1\n```\n\n### datasource(path, callback, [init])\n\nType: `method`\n\nSleduje path s dátami pre komponent.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path, ktorá sa má sledovať. |\n| `callback` | `Function` | yes |  | Funkcia `(value, flags, path)`. |\n| `init` | `Boolean` | no | `true` | Nastav `false`, ak chceš preskočiť prvé volanie. |\n\nReturns: `Component` Inštancia.\n\nFunkcia sa zavolá s aktuálnou hodnotou pri inicializácii komponentu, pokiaľ `init` nie je `false`, a pri každej zmene. Nové volanie nahradí predtým zaregistrovaný zdroj dát a `datasource(null)` ho odstráni.\n\nExample: Vykresli položky z path\n```html\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nvar common = { items: ['a'] };\n\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.datasource('common.items', value => console.log(value.join()));\n    };\n});\n\nSET('common.items', ['a', 'b']);\n// logs: a\n// logs: a,b\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nZaregistruje obslužnú funkciu globálnej udalosti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | yes |  | Obslužná funkcia. |\n\nViacero názvov udalostí spoj znakom `+`. Pozri [Udalosti](../events/).\n\nExample: Obslúž udalosť\n```js\nvar handler = value => console.log(value);\ncom.on('refresh', handler);\nEMIT('refresh', 1);\ncom.off('refresh', handler);\nEMIT('refresh', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nOdstráni obslužnú funkciu globálnej udalosti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | no |  | Obslužná funkcia na odstránenie. |\n\nBez callbacku sa odstránia všetky obslužné funkcie udalosti zaregistrované na tejto inštancii.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nVyšle globálnu udalosť.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nExample: Vyšli udalosť\n```js\nON('saved', value => console.log(value));\ncom.emit('saved', 'ok');\n// logs: ok\n```\n\n### command(name, callback)\n\nType: `method`\n\nZaregistruje príkaz tejto inštancie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov príkazu. |\n| `callback` | `Function` | yes |  | Obslužná funkcia. |\n\nExample: Zaregistruj a spusti príkaz\n```js\ncom.command('clear', value => console.log('clear', value));\ncom.CMD('clear', 1);\n// logs: clear 1\n```\n\n### CMD(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nSpustí príkaz zaregistrovaný na tejto inštancii pomocou `command()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov príkazu. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n| `e` | `Object` | no |  | Piaty argument. |\n\n### GET(path)\n\nType: `method`\n\nPrečíta hodnotu z path. Znak `?` sa nahradí path nadradeného pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nReturns: `Object` Hodnota.\n\nExample: Pracuj s modelom pluginu\n```html\n<ui-plugin path=\"orders\"><ui-component name=\"demo\"></ui-component></ui-plugin>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.SET('?.count', 3);\n        console.log(self.GET('?.count'));\n    };\n});\n// logs: 3\n</script>\n```\n\n### SET(path, value)\n\nType: `method`\n\nZapíše hodnotu na path a upozorní všetko, čo je naň naviazané. Znak `?` sa nahradí path nadradeného pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n| `value` | `Object` | yes |  | Hodnota na zápis. |\n\n### EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá funkciu alebo metódu pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Napríklad `FUNC.save`, `?/save` alebo `@save`. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nZnak `?` sa nahradí path nadradeného pluginu. Názov, ktorý sa začína znakom `@`, zavolá metódu najbližšieho nadradeného komponentu.\n\nExample: Zavolaj metódu nadradeného komponentu\n```html\n<ui-component name=\"parent\">\n    <ui-component name=\"child\"></ui-component>\n</ui-component>\n\n<script>\nCOMPONENT('parent', function(self) {\n    self.refreshlist = value => console.log('parent', value);\n});\n\nCOMPONENT('child', function(self) {\n    window.com = self;\n});\n\ncom.EXEC('@refreshlist', 1);\n// logs: parent 1\n</script>\n```\n\n### SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá metódu pluginu alebo globálnu funkciu, prípadne zapíše prvý argument na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Metóda, funkcia alebo path. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nTvar `plugin/method` zavolá metódu pluginu a názov globálnej funkcie zavolá túto funkciu. Každý iný názov je path, ktorý dostane `a`.\n\nExample: Zapíš na path\n```js\ncom.SEEX('common.status', 'done');\nconsole.log(common.status);\n// logs: done\n```\n\n### SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá metódu komponentov na celej stránke v tvare `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Cieľ, napríklad `grid/refresh`. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nExample: Zavolaj metódu iného komponentu\n```html\n<ui-component name=\"grid\"></ui-component>\n<ui-component name=\"demo\"></ui-component>\n\n<script>\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.SETTER('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### find(selector)\n\nType: `method`\n\nNájde elementy vnútri komponentu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor alebo objekt so selektormi. |\n\nReturns: `jQuery` Nájdené elementy alebo objekt s nimi.\n\nS objektom metóda vyhľadá každý selektor a vráti objekt s rovnakými kľúčmi.\n\nExample: Nájdi elementy\n```html\n<ui-component name=\"demo\"><input /><b></b></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\nconsole.log(com.find('input').length, com.find({ title: 'b' }).title.length);\n// logs: 1 1\n</script>\n```\n\n### closest(selector)\n\nType: `method`\n\nNájde najbližší nadradený element zodpovedajúci selektoru.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor jQuery. |\n\nReturns: `jQuery` Nájdený element.\n\nExample: Nájdi nadradený element\n```js\nconsole.log(com.closest('body')[0].tagName);\n// logs: BODY\n```\n\n### parent([selector])\n\nType: `method`\n\nNájde nadradený element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Selektor. |\n\nReturns: `jQuery` Nájdený element.\n\nBez argumentu metóda vráti priamo nadradený element. Podporované sú aj tieto hodnoty:\n\n| Selektor | Výsledok |\n| --- | --- |\n| `auto` | Najbližší nadradený element s výškou nastavenou v štýle alebo `window` |\n| `window` | Objekt `window` ako jQuery |\n| `document` | Objekt `document` ako jQuery |\n| `parent` s číslom za ním | Nadradený element o daný počet úrovní nad priamo nadradeným elementom |\n| čokoľvek iné | Najbližší nadradený element zodpovedajúci selektoru |\n\nExample: Prečítaj priamo nadradený element\n```js\nconsole.log(com.parent()[0].tagName);\n// logs: BODY\n```\n\n### html([value])\n\nType: `method`\n\nPrečíta alebo nahradí HTML elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | Nový obsah. |\n\nReturns: `jQuery` Element alebo bez argumentu aktuálne HTML.\n\nPole sa spojí do jedného reťazca.\n\nExample: Nastav obsah\n```js\ncom.html(['<b>', 'Hello', '</b>']);\nconsole.log(com.html());\n// logs: <b>Hello</b>\n```\n\n### text([value])\n\nType: `method`\n\nPrečíta alebo nahradí text elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | no |  | Nový text. |\n\nReturns: `jQuery` Element alebo bez argumentu aktuálny text.\n\nPole sa spojí do jedného reťazca.\n\nExample: Nastav text\n```js\ncom.text('Hello');\nconsole.log(com.text());\n// logs: Hello\n```\n\n### append(value)\n\nType: `method`\n\nPridá HTML na koniec elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Obsah. |\n\nReturns: `jQuery` Element.\n\nPole sa spojí do jedného reťazca.\n\nExample: Pridaj obsah\n```js\ncom.append('<i></i>');\ncom.append(['<b>', '</b>']);\nconsole.log(com.html());\n// logs: <i></i><b></b>\n```\n\n### empty()\n\nType: `method`\n\nOdstráni obsah elementu.\n\nReturns: `Component` Inštancia.\n\n### attr(name, [value])\n\nType: `method`\n\nPrečíta alebo nastaví atribút elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Atribút. |\n| `value` | `String` | no |  | Nová hodnota. |\n\nReturns: `Object` Pri čítaní hodnota, pri nastavovaní inštancia.\n\nExample: Atribúty\n```js\ncom.attr('title', 'Hello');\ncom.attrd('id', 5);\nconsole.log(com.attr('title'), com.attrd('id'));\n// logs: Hello 5\n```\n\n### attrd(name, [value])\n\nType: `method`\n\nPrečíta alebo nastaví atribút `data-` elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov bez prefixu `data-`. |\n| `value` | `String` | no |  | Nová hodnota. |\n\nReturns: `String` Hodnota pri čítaní.\n\n### css(name, [value])\n\nType: `method`\n\nPrečíta alebo nastaví vlastnosť CSS elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Vlastnosť. |\n| `value` | `String` | no |  | Nová hodnota. |\n\nReturns: `Object` Pri čítaní hodnota, pri nastavovaní inštancia.\n\nExample: Zmeň štýl\n```js\ncom.css('color', 'red');\nconsole.log(com.css('color'));\n// logs: rgb(255, 0, 0)\n```\n\n### aclass(name, [timeout])\n\nType: `method`\n\nPridá elementu triedu CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Trieda. |\n| `timeout` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `Component` Inštancia.\n\nExample: Pracuj s triedami\n```js\ncom.aclass('a b');\ncom.rclass('a');\ncom.tclass('c');\nconsole.log(com.element.attr('class'), com.hclass('c'));\n// logs: b c true\n```\n\n### rclass([name], [timeout])\n\nType: `method`\n\nOdstráni z elementu triedu CSS alebo bez argumentu všetky triedy.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Trieda. |\n| `timeout` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `Component` Inštancia.\n\n### rclass2(search)\n\nType: `method`\n\nOdstráni všetky triedy CSS, ktoré obsahujú daný text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String` | yes |  | Hľadaný text. |\n\nReturns: `Component` Inštancia.\n\nExample: Odstráň skupinu tried\n```js\ncom.aclass('size-1 size-2 box');\ncom.rclass2('size-');\nconsole.log(com.element.attr('class'));\n// logs: box\n```\n\n### tclass(name, [enable])\n\nType: `method`\n\nPrepne triedu CSS na elemente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Trieda. |\n| `enable` | `Boolean` | no |  | Vynúti stav triedy. |\n\nReturns: `Component` Inštancia.\n\n### hclass(name)\n\nType: `method`\n\nZistí, či má element triedu CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Trieda. |\n\nReturns: `Boolean` `true`, keď je trieda prítomná.\n\n### width()\n\nType: `method`\n\nVráti šírku elementu v pixeloch.\n\nReturns: `Number` Šírka.\n\n### height()\n\nType: `method`\n\nVráti výšku elementu v pixeloch.\n\nReturns: `Number` Výška.\n\n### event(name, [selector], callback)\n\nType: `method`\n\nZaregistruje na elemente obslužnú funkciu udalosti DOM.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Udalosť DOM. |\n| `selector` | `String` | no |  | Obmedzí udalosť na zodpovedajúce podradené elementy. |\n| `callback` | `Function` | yes |  | Obslužná funkcia. |\n\nReturns: `Component` Inštancia.\n\nArgumenty sa odovzdajú metóde jQuery `.on()`.\n\nExample: Obslúž kliknutie\n```html\n<ui-component name=\"demo\"><button>Save</button></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    self.make = function() {\n        self.event('click', 'button', () => console.log('clicked'));\n    };\n});\n\n$('button').trigger('click');\n// logs: clicked\n</script>\n```\n\n### autofocus([selector])\n\nType: `method`\n\nPresunie focus na prvý viditeľný ovládací prvok vnútri elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no |  | Elementy, na ktoré sa má presunúť focus. |\n\nReturns: `Component` Inštancia.\n\nPredvolený selektor je `input,select,textarea`. Keď zatiaľ žiadny ovládací prvok nemôže dostať focus, metóda to skúša znova každých 200 milisekúnd, najviac 15-krát. Na mobilných zariadeniach sa focus nepresúva.\n\nExample: Presuň focus na prvé vstupné pole\n```html\n<ui-component name=\"demo\"><input id=\"first\" /></ui-component>\n\n<script>\nCOMPONENT('demo', function(self) {\n    window.com = self;\n});\n\ncom.autofocus();\nconsole.log(document.activeElement.id);\n// logs: first\n</script>\n```\n\n### import(url, [callback], [prepare])\n\nType: `method`\n\nStiahne obsah a pridá ho do elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Adresa. |\n| `callback` | `Function` | no |  | Spustí sa, keď je obsah na stránke. |\n| `prepare` | `Function` | no |  | Funkcia `(html)`, ktorá vracia obsah na vloženie. |\n\nPozri `IMPORT()` v časti [Import obsahu](../../guides/importing/).\n\nExample: Importuj časť\n```js\ncom.import('/parts/help.html', () => console.log(com.html()), html => html + '<hr>');\n// logs: <p>Help</p><hr>\n```\n\n### replace(target, [remove])\n\nType: `method`\n\nPresunie komponent do iného elementu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `target` | `Element` | yes |  | Nový element ako selektor, element DOM alebo jQuery. |\n| `remove` | `Boolean` | no | `false` | Odstráni pôvodný element. |\n\nReturns: `Component` Inštancia.\n\nS `remove` sa pôvodný element odstráni zo stránky.\n\nExample: Presuň komponent\n```js\ncom.replace('#box', true);\nconsole.log(com.dom.id, $('ui-component').length);\n// logs: box 0\n```\n\n### remove()\n\nType: `method`\n\nZavolá `destroy` a odstráni komponent aj jeho element.\n\n### icon(value)\n\nType: `method`\n\nPridá k názvu ikony prefix ikon z `DEF.iconprefix`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Názov ikony. |\n\nReturns: `String` Triedy CSS ikony.\n\nHodnota s medzerou už svoj prefix obsahuje a zostáva nezmenená.\n\nExample: Vytvor triedy ikony\n```js\nconsole.log(com.icon('home'));\n// logs: ti ti-home\nconsole.log(com.icon('fa fa-home'));\n// logs: fa fa-home\n```\n\n### caniuse(name)\n\nType: `method`\n\nNájde prvý deklarovaný komponent v zozname názvov oddelených čiarkou alebo znakom `|`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názvy. |\n\nReturns: `String` Nájdený názov alebo `false`.\n\nExample: Vyber dostupný komponent\n```js\nconsole.log(com.caniuse('missing,demo'));\n// logs: demo\nconsole.log(com.caniuse('missing|demo'));\n// logs: demo\nconsole.log(com.caniuse('missing'));\n// logs: false\n```\n\n### parseSource(value)\n\nType: `method`\n\nAnalyzuje zoznam v tvare `id|name|icon,id|name|icon`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Zoznam. |\n\nReturns: `Array` Objekty s `id`, `name` a `icon`.\n\nMetóda je dostupná aj ako `parsesource()`. Keď je konfiguračný kľúč `type` nastavený na `number`, identifikátory sa prevedú na čísla.\n\nExample: Analyzuj zoznam\n```js\nvar items = com.parseSource('1|One,2|Two|home');\nconsole.log(JSON.stringify(items[1]));\n// logs: {\"id\":\"2\",\"name\":\"Two\",\"icon\":\"home\"}\n```\n","entries":[{"type":"property","name":"id","signature":"id","since":"","deprecated":false},{"type":"property","name":"ID","signature":"ID","since":"","deprecated":false},{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"def","signature":"def","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"delegate","name":"init()","signature":"init()","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"configure()","signature":"configure(key, value, init, prev)","since":"","deprecated":false},{"type":"delegate","name":"setter()","signature":"setter(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"setter2()","signature":"setter2(value, path, flags)","since":"","deprecated":false},{"type":"delegate","name":"getter()","signature":"getter(value, [realtime])","since":"","deprecated":false},{"type":"delegate","name":"validate()","signature":"validate(value)","since":"","deprecated":false},{"type":"delegate","name":"state()","signature":"state()","since":"","deprecated":false},{"type":"delegate","name":"state2()","signature":"state2(component)","since":"","deprecated":false},{"type":"delegate","name":"done()","signature":"done()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get()","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set(value, [flags])","since":"","deprecated":false},{"type":"method","name":"rewrite()","signature":"rewrite(value, [flags])","since":"","deprecated":false},{"type":"method","name":"modify()","signature":"modify(value, [flags])","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(value)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd([flags])","since":"","deprecated":false},{"type":"method","name":"refresh()","signature":"refresh()","since":"","deprecated":false},{"type":"method","name":"setPath()","signature":"setPath(path)","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"bind()","signature":"bind(flags, [value])","since":"","deprecated":false},{"type":"method","name":"touch()","signature":"touch()","since":"","deprecated":false},{"type":"method","name":"change()","signature":"change()","since":"","deprecated":false},{"type":"method","name":"reset()","signature":"reset([noemit])","since":"","deprecated":false},{"type":"method","name":"isInvalid()","signature":"isInvalid()","since":"","deprecated":false},{"type":"method","name":"validate2()","signature":"validate2([value])","since":"","deprecated":false},{"type":"method","name":"reconfigure()","signature":"reconfigure(value)","since":"","deprecated":false},{"type":"method","name":"watchconfig()","signature":"watchconfig(key, path)","since":"","deprecated":false},{"type":"method","name":"formatter()","signature":"formatter(fn)","since":"","deprecated":false},{"type":"method","name":"parser()","signature":"parser(fn)","since":"","deprecated":false},{"type":"method","name":"autobind20()","signature":"autobind20([delay], [realtimebinding])","since":"","deprecated":false},{"type":"method","name":"autofill()","signature":"autofill([enabled])","since":"","deprecated":false},{"type":"method","name":"readonly()","signature":"readonly()","since":"","deprecated":false},{"type":"method","name":"blind()","signature":"blind()","since":"","deprecated":false},{"type":"method","name":"singleton()","signature":"singleton()","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"datasource()","signature":"datasource(path, callback, [init])","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"command()","signature":"command(name, callback)","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"CMD(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"GET()","signature":"GET(path)","since":"","deprecated":false},{"type":"method","name":"SET()","signature":"SET(path, value)","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"find()","signature":"find(selector)","since":"","deprecated":false},{"type":"method","name":"closest()","signature":"closest(selector)","since":"","deprecated":false},{"type":"method","name":"parent()","signature":"parent([selector])","since":"","deprecated":false},{"type":"method","name":"html()","signature":"html([value])","since":"","deprecated":false},{"type":"method","name":"text()","signature":"text([value])","since":"","deprecated":false},{"type":"method","name":"append()","signature":"append(value)","since":"","deprecated":false},{"type":"method","name":"empty()","signature":"empty()","since":"","deprecated":false},{"type":"method","name":"attr()","signature":"attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"css()","signature":"css(name, [value])","since":"","deprecated":false},{"type":"method","name":"aclass()","signature":"aclass(name, [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"rclass([name], [timeout])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"rclass2(search)","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"tclass(name, [enable])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"hclass(name)","since":"","deprecated":false},{"type":"method","name":"width()","signature":"width()","since":"","deprecated":false},{"type":"method","name":"height()","signature":"height()","since":"","deprecated":false},{"type":"method","name":"event()","signature":"event(name, [selector], callback)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"import()","signature":"import(url, [callback], [prepare])","since":"","deprecated":false},{"type":"method","name":"replace()","signature":"replace(target, [remove])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"remove()","since":"","deprecated":false},{"type":"method","name":"icon()","signature":"icon(value)","since":"","deprecated":false},{"type":"method","name":"caniuse()","signature":"caniuse(name)","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"parseSource(value)","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"Jamcb6Cko61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/ui-plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"ui-plugin","summary":"The attributes and the config keys of the ui-plugin element.","markdown":"---\ntitle: ui-plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/ui-plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-plugin\n\n> The attributes and the config keys of the ui-plugin element.\n\nThe `<ui-plugin>` element creates an instance of a plugin declared with `PLUGIN()` and gives the elements inside it a common path. The [Plugins](../../guides/plugins/) guide explains how to work with it, and the instance is described on the [Plugin](../plugin/) page.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nThe path of the plugin model, and the name of the declaration to use.\n\nThe attribute accepts these forms:\n\n| Value | Model path | Declaration |\n| --- | --- | --- |\n| `orders` | `orders` | `orders` |\n| `target name` | `target` | `name` |\n| `? name` | a generated path under `jComponent.data.` | `name` |\n| `*` | `common` | `PLUGIN('*', ...)` |\n| no attribute | the name of the next declaration waiting for an element | that declaration |\n\nWhen no declaration exists for the path, the element still works as a plugin without its own code.\n\nExample: One declaration, two models\n```html\n<ui-plugin path=\"left counter\"></ui-plugin>\n<ui-plugin path=\"right counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name);\n    };\n});\n// logs: left\n// logs: right\n</script>\n```\n\nExample: A generated model path\n```html\n<ui-plugin path=\"? counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name.substring(0, 16));\n    };\n});\n// logs: jComponent.data.\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nThe configuration of the plugin instance.\n\nThe format is the same as in [ui-component](../ui-component/). Besides the keys below, the plugin reads any key of its own from `exports.config`.\n\nExample: Read the configuration\n```html\n<ui-plugin path=\"report\" config=\"limit:20\"></ui-plugin>\n\n<script>\nPLUGIN('report', 'limit:5;sort:name', function(exports, config) {\n    console.log(config.limit, config.sort);\n});\n// logs: 20 name\n</script>\n```\n\n### init:path\n\nType: `config`\n\nCalls a function when the plugin is created, just ahead of `make`.\n\nThe function receives the jQuery element of the plugin. A `?` in the value is replaced with the path of the plugin, so `?/ready` calls the `ready` method of the same plugin.\n\nExample: Call a method of the plugin\n```html\n<ui-plugin path=\"report\" config=\"init:?/ready\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {\n    exports.ready = function(element) {\n        console.log(element[0].tagName);\n    };\n});\n// logs: UI-PLUGIN\n</script>\n```\n\n### class:name\n\nType: `config`\n\nToggles a CSS class on the element 500 milliseconds after the plugin is created.\n\nExample: Reveal the plugin\n```html\n<ui-plugin path=\"report\" config=\"class:visible\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nAdds the value of the `path` attribute to the element as a CSS class.\n\nExample: Style the plugin by its name\n```html\n<ui-plugin path=\"report\" config=\"aclass:true\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"Jamcb6Cko61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/ui-plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"ui-plugin","summary":"Die Attribute und Config-Keys des Elements ui-plugin.","markdown":"---\ntitle: ui-plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/ui-plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-plugin\n\n> Die Attribute und Config-Keys des Elements ui-plugin.\n\nDas Element `<ui-plugin>` erstellt eine Instanz eines mit `PLUGIN()` deklarierten Plugins und gibt den Elementen darin einen gemeinsamen Path. Wie du damit arbeitest, erklärt die Anleitung [Plugins](../../guides/plugins/), und die Instanz ist auf der Seite [Plugin](../plugin/) beschrieben.\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nDer Path des Plugin-Modells und der Name der zu verwendenden Deklaration.\n\nDas Attribut akzeptiert diese Formen:\n\n| Wert | Modell-Path | Deklaration |\n| --- | --- | --- |\n| `orders` | `orders` | `orders` |\n| `target name` | `target` | `name` |\n| `? name` | ein generierter Path unter `jComponent.data.` | `name` |\n| `*` | `common` | `PLUGIN('*', ...)` |\n| kein Attribut | der Name der nächsten Deklaration, die auf ein Element wartet | diese Deklaration |\n\nGibt es für den Path keine Deklaration, funktioniert das Element trotzdem als Plugin ohne eigenen Code.\n\nExample: Eine Deklaration, zwei Modelle\n```html\n<ui-plugin path=\"left counter\"></ui-plugin>\n<ui-plugin path=\"right counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name);\n    };\n});\n// logs: left\n// logs: right\n</script>\n```\n\nExample: Ein generierter Modell-Path\n```html\n<ui-plugin path=\"? counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name.substring(0, 16));\n    };\n});\n// logs: jComponent.data.\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nDie Konfiguration der Plugin-Instanz.\n\nDas Format ist dasselbe wie bei [ui-component](../ui-component/). Neben den Schlüsseln unten liest das Plugin jeden eigenen Schlüssel aus `exports.config`.\n\nExample: Konfiguration lesen\n```html\n<ui-plugin path=\"report\" config=\"limit:20\"></ui-plugin>\n\n<script>\nPLUGIN('report', 'limit:5;sort:name', function(exports, config) {\n    console.log(config.limit, config.sort);\n});\n// logs: 20 name\n</script>\n```\n\n### init:path\n\nType: `config`\n\nRuft eine Funktion auf, wenn das Plugin erstellt wird, unmittelbar vor `make`.\n\nDie Funktion erhält das jQuery-Element des Plugins. Ein `?` im Wert wird durch den Path des Plugins ersetzt, `?/ready` ruft also die Methode `ready` desselben Plugins auf.\n\nExample: Methode des Plugins aufrufen\n```html\n<ui-plugin path=\"report\" config=\"init:?/ready\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {\n    exports.ready = function(element) {\n        console.log(element[0].tagName);\n    };\n});\n// logs: UI-PLUGIN\n</script>\n```\n\n### class:name\n\nType: `config`\n\nSchaltet 500 Millisekunden nach dem Erstellen des Plugins eine CSS-Klasse am Element um.\n\nExample: Plugin einblenden\n```html\n<ui-plugin path=\"report\" config=\"class:visible\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nFügt dem Element den Wert des Attributs `path` als CSS-Klasse hinzu.\n\nExample: Plugin über seinen Namen stylen\n```html\n<ui-plugin path=\"report\" config=\"aclass:true\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"Jamcb6Cko61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/ui-plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"ui-plugin","summary":"Los atributos y las claves de configuración del elemento ui-plugin.","markdown":"---\ntitle: ui-plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/ui-plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-plugin\n\n> Los atributos y las claves de configuración del elemento ui-plugin.\n\nEl elemento `<ui-plugin>` crea una instancia de un plugin declarado con `PLUGIN()` y da un path común a los elementos que contiene. La guía [Plugins](../../guides/plugins/) explica cómo trabajar con él, y la instancia se describe en la página [Plugin](../plugin/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nEl path del modelo del plugin y el nombre de la declaración que se usa.\n\nEl atributo acepta estas formas:\n\n| Valor | Path del modelo | Declaración |\n| --- | --- | --- |\n| `orders` | `orders` | `orders` |\n| `target name` | `target` | `name` |\n| `? name` | un path generado bajo `jComponent.data.` | `name` |\n| `*` | `common` | `PLUGIN('*', ...)` |\n| sin atributo | el nombre de la siguiente declaración que espera un elemento | esa declaración |\n\nCuando no existe ninguna declaración para el path, el elemento sigue funcionando como un plugin sin código propio.\n\nExample: Una declaración, dos modelos\n```html\n<ui-plugin path=\"left counter\"></ui-plugin>\n<ui-plugin path=\"right counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name);\n    };\n});\n// logs: left\n// logs: right\n</script>\n```\n\nExample: Un path de modelo generado\n```html\n<ui-plugin path=\"? counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name.substring(0, 16));\n    };\n});\n// logs: jComponent.data.\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nLa configuración de la instancia del plugin.\n\nEl formato es el mismo que en [ui-component](../ui-component/). Además de las claves siguientes, el plugin lee cualquier clave propia de `exports.config`.\n\nExample: Leer la configuración\n```html\n<ui-plugin path=\"report\" config=\"limit:20\"></ui-plugin>\n\n<script>\nPLUGIN('report', 'limit:5;sort:name', function(exports, config) {\n    console.log(config.limit, config.sort);\n});\n// logs: 20 name\n</script>\n```\n\n### init:path\n\nType: `config`\n\nLlama a una función cuando se crea el plugin, justo antes de `make`.\n\nLa función recibe el elemento jQuery del plugin. Un `?` en el valor se sustituye por el path del plugin, así que `?/ready` llama al método `ready` del mismo plugin.\n\nExample: Llamar a un método del plugin\n```html\n<ui-plugin path=\"report\" config=\"init:?/ready\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {\n    exports.ready = function(element) {\n        console.log(element[0].tagName);\n    };\n});\n// logs: UI-PLUGIN\n</script>\n```\n\n### class:name\n\nType: `config`\n\nAlterna una clase CSS en el elemento 500 milisegundos después de crear el plugin.\n\nExample: Mostrar el plugin\n```html\n<ui-plugin path=\"report\" config=\"class:visible\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nAñade al elemento el valor del atributo `path` como clase CSS.\n\nExample: Dar estilo al plugin por su nombre\n```html\n<ui-plugin path=\"report\" config=\"aclass:true\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"Jamcb6Cko61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/ui-plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"ui-plugin","summary":"Les attributs et les clés de configuration de l'élément ui-plugin.","markdown":"---\ntitle: ui-plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/ui-plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-plugin\n\n> Les attributs et les clés de configuration de l'élément ui-plugin.\n\nL'élément `<ui-plugin>` crée une instance d'un plugin déclaré avec `PLUGIN()` et donne un path commun aux éléments qu'il contient. Le guide [Plugins](../../guides/plugins/) explique comment travailler avec lui, et l'instance est décrite sur la page [Plugin](../plugin/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nLe path du modèle de données du plugin et le nom de la déclaration à utiliser.\n\nL'attribut accepte ces formes :\n\n| Valeur | Path du modèle de données | Déclaration |\n| --- | --- | --- |\n| `orders` | `orders` | `orders` |\n| `target name` | `target` | `name` |\n| `? name` | un path généré sous `jComponent.data.` | `name` |\n| `*` | `common` | `PLUGIN('*', ...)` |\n| pas d'attribut | le nom de la prochaine déclaration en attente d'un élément | cette déclaration |\n\nQuand aucune déclaration n'existe pour le path, l'élément fonctionne quand même comme un plugin sans code propre.\n\nExample: Une déclaration, deux modèles de données\n```html\n<ui-plugin path=\"left counter\"></ui-plugin>\n<ui-plugin path=\"right counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name);\n    };\n});\n// logs: left\n// logs: right\n</script>\n```\n\nExample: Un path de modèle de données généré\n```html\n<ui-plugin path=\"? counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name.substring(0, 16));\n    };\n});\n// logs: jComponent.data.\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nLa configuration de l'instance du plugin.\n\nLe format est le même que dans [ui-component](../ui-component/). En plus des clés ci-dessous, le plugin lit toutes ses propres clés depuis `exports.config`.\n\nExample: Lire la configuration\n```html\n<ui-plugin path=\"report\" config=\"limit:20\"></ui-plugin>\n\n<script>\nPLUGIN('report', 'limit:5;sort:name', function(exports, config) {\n    console.log(config.limit, config.sort);\n});\n// logs: 20 name\n</script>\n```\n\n### init:path\n\nType: `config`\n\nAppelle une fonction quand le plugin est créé, juste avant `make`.\n\nLa fonction reçoit l'élément jQuery du plugin. Un `?` dans la valeur est remplacé par le path du plugin : `?/ready` appelle donc la méthode `ready` de ce même plugin.\n\nExample: Appeler une méthode du plugin\n```html\n<ui-plugin path=\"report\" config=\"init:?/ready\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {\n    exports.ready = function(element) {\n        console.log(element[0].tagName);\n    };\n});\n// logs: UI-PLUGIN\n</script>\n```\n\n### class:name\n\nType: `config`\n\nBascule une classe CSS sur l'élément 500 millisecondes après la création du plugin.\n\nExample: Révéler le plugin\n```html\n<ui-plugin path=\"report\" config=\"class:visible\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nAjoute la valeur de l'attribut `path` à l'élément en tant que classe CSS.\n\nExample: Styler le plugin d'après son nom\n```html\n<ui-plugin path=\"report\" config=\"aclass:true\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"Jamcb6Cko61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/ui-plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"ui-plugin","summary":"Gli attributi e le chiavi di configurazione dell'elemento ui-plugin.","markdown":"---\ntitle: ui-plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/ui-plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-plugin\n\n> Gli attributi e le chiavi di configurazione dell'elemento ui-plugin.\n\nL'elemento `<ui-plugin>` crea un'istanza di un plugin dichiarato con `PLUGIN()` e assegna agli elementi al suo interno un path comune. La guida [Plugin](../../guides/plugins/) spiega come lavorarci, e l'istanza è descritta nella pagina [Plugin](../plugin/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nIl path del modello del plugin e il nome della dichiarazione da usare.\n\nL'attributo accetta queste forme:\n\n| Valore | Path del modello | Dichiarazione |\n| --- | --- | --- |\n| `orders` | `orders` | `orders` |\n| `target name` | `target` | `name` |\n| `? name` | un path generato sotto `jComponent.data.` | `name` |\n| `*` | `common` | `PLUGIN('*', ...)` |\n| nessun attributo | il nome della prossima dichiarazione in attesa di un elemento | quella dichiarazione |\n\nQuando non esiste una dichiarazione per il path, l'elemento funziona comunque come plugin senza codice proprio.\n\nExample: Una dichiarazione, due modelli\n```html\n<ui-plugin path=\"left counter\"></ui-plugin>\n<ui-plugin path=\"right counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name);\n    };\n});\n// logs: left\n// logs: right\n</script>\n```\n\nExample: Un path del modello generato\n```html\n<ui-plugin path=\"? counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name.substring(0, 16));\n    };\n});\n// logs: jComponent.data.\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nLa configurazione dell'istanza del plugin.\n\nIl formato è lo stesso di [ui-component](../ui-component/). Oltre alle chiavi qui sotto, il plugin legge da `exports.config` qualsiasi chiave propria.\n\nExample: Leggi la configurazione\n```html\n<ui-plugin path=\"report\" config=\"limit:20\"></ui-plugin>\n\n<script>\nPLUGIN('report', 'limit:5;sort:name', function(exports, config) {\n    console.log(config.limit, config.sort);\n});\n// logs: 20 name\n</script>\n```\n\n### init:path\n\nType: `config`\n\nChiama una funzione quando il plugin viene creato, subito prima di `make`.\n\nLa funzione riceve l'elemento jQuery del plugin. Un `?` nel valore viene sostituito con il path del plugin, quindi `?/ready` chiama il metodo `ready` dello stesso plugin.\n\nExample: Chiama un metodo del plugin\n```html\n<ui-plugin path=\"report\" config=\"init:?/ready\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {\n    exports.ready = function(element) {\n        console.log(element[0].tagName);\n    };\n});\n// logs: UI-PLUGIN\n</script>\n```\n\n### class:name\n\nType: `config`\n\nAttiva o disattiva una classe CSS sull'elemento 500 millisecondi dopo la creazione del plugin.\n\nExample: Rivela il plugin\n```html\n<ui-plugin path=\"report\" config=\"class:visible\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nAggiunge all'elemento il valore dell'attributo `path` come classe CSS.\n\nExample: Applica uno stile al plugin in base al nome\n```html\n<ui-plugin path=\"report\" config=\"aclass:true\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"Jamcb6Cko61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/ui-plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"ui-plugin","summary":"Atribúty a konfiguračné kľúče elementu ui-plugin.","markdown":"---\ntitle: ui-plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/ui-plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-plugin\n\n> Atribúty a konfiguračné kľúče elementu ui-plugin.\n\nElement `<ui-plugin>` vytvorí inštanciu pluginu deklarovaného pomocou `PLUGIN()` a elementom vnútri seba dá spoločný path. Ako s ním pracovať, vysvetľuje príručka [Pluginy](../../guides/plugins/) a inštanciu opisuje stránka [Plugin](../plugin/).\n\n## API\n\n### path=\"path\"\n\nType: `property`\n\nPath modelu pluginu a názov deklarácie, ktorá sa má použiť.\n\nAtribút prijíma tieto tvary:\n\n| Hodnota | Path modelu | Deklarácia |\n| --- | --- | --- |\n| `orders` | `orders` | `orders` |\n| `target name` | `target` | `name` |\n| `? name` | vygenerovaný path pod `jComponent.data.` | `name` |\n| `*` | `common` | `PLUGIN('*', ...)` |\n| bez atribútu | názov ďalšej deklarácie čakajúcej na element | táto deklarácia |\n\nKeď pre path neexistuje žiadna deklarácia, element aj tak funguje ako plugin bez vlastného kódu.\n\nExample: Jedna deklarácia, dva modely\n```html\n<ui-plugin path=\"left counter\"></ui-plugin>\n<ui-plugin path=\"right counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name);\n    };\n});\n// logs: left\n// logs: right\n</script>\n```\n\nExample: Vygenerovaný path modelu\n```html\n<ui-plugin path=\"? counter\"></ui-plugin>\n\n<script>\nPLUGIN('counter', function(exports) {\n    exports.make = function() {\n        console.log(exports.name.substring(0, 16));\n    };\n});\n// logs: jComponent.data.\n</script>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nKonfigurácia inštancie pluginu.\n\nFormát je rovnaký ako pri [ui-component](../ui-component/). Okrem kľúčov uvedených nižšie plugin číta z `exports.config` aj akýkoľvek vlastný kľúč.\n\nExample: Prečítaj konfiguráciu\n```html\n<ui-plugin path=\"report\" config=\"limit:20\"></ui-plugin>\n\n<script>\nPLUGIN('report', 'limit:5;sort:name', function(exports, config) {\n    console.log(config.limit, config.sort);\n});\n// logs: 20 name\n</script>\n```\n\n### init:path\n\nType: `config`\n\nZavolá funkciu pri vytvorení pluginu, tesne pred `make`.\n\nFunkcia dostane element jQuery pluginu. Znak `?` v hodnote sa nahradí path pluginu, takže `?/ready` zavolá metódu `ready` toho istého pluginu.\n\nExample: Zavolaj metódu pluginu\n```html\n<ui-plugin path=\"report\" config=\"init:?/ready\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {\n    exports.ready = function(element) {\n        console.log(element[0].tagName);\n    };\n});\n// logs: UI-PLUGIN\n</script>\n```\n\n### class:name\n\nType: `config`\n\nPrepne triedu CSS na elemente 500 milisekúnd po vytvorení pluginu.\n\nExample: Odhaľ plugin\n```html\n<ui-plugin path=\"report\" config=\"class:visible\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n\n### aclass:true\n\nType: `config`\n\nPridá hodnotu atribútu `path` do elementu ako triedu CSS.\n\nExample: Štýluj plugin podľa jeho názvu\n```html\n<ui-plugin path=\"report\" config=\"aclass:true\"></ui-plugin>\n\n<script>\nPLUGIN('report', function(exports) {});\n</script>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"path\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false},{"type":"config","name":"aclass","signature":"aclass:true","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcX882o61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"Plugin","summary":"The properties, the methods and the delegates of a plugin instance.","markdown":"---\ntitle: Plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Plugin\n\n> The properties, the methods and the delegates of a plugin instance.\n\nA plugin instance is the first argument of the function given to `PLUGIN()`, usually named `exports`. It is created for each [ui-plugin](../ui-plugin/) element. The methods work with paths relative to the plugin, as explained in the [Plugins](../../guides/plugins/) guide. The examples below use a plugin with the path `orders`.\n\n## API\n\n### name\n\nType: `property`\n\nThe path of the plugin.\n\nReturns: `String` The path of the plugin.\n\n### path\n\nType: `property`\n\nThe path of the plugin model.\n\nReturns: `Path` The path of the plugin model.\n\nSee [Path](../path/).\n\n### config\n\nType: `property`\n\nThe configuration of the plugin.\n\nReturns: `Object` The configuration of the plugin.\n\n### element\n\nType: `property`\n\nThe element of the plugin as a jQuery object.\n\nReturns: `jQuery` The element of the plugin as a jQuery object.\n\n### dom\n\nType: `property`\n\nThe element of the plugin.\n\nReturns: `HTMLElement` The element of the plugin.\n\n### scope\n\nType: `property`\n\nThe object that paths are resolved against, which is `window`.\n\nReturns: `Object` The object that paths are resolved against, which is `window`.\n\n### cls\n\nType: `property`\n\nThe value of the `path` attribute of the element.\n\nReturns: `String` The value of the `path` attribute of the element.\n\n### ready\n\nType: `property`\n\nIs `true` when the plugin is initialized.\n\nReturns: `Boolean` Is `true` when the plugin is initialized.\n\n### plugin\n\nType: `property`\n\nThe parent plugin of a plugin nested with a `?` in its path, otherwise `null`.\n\nReturns: `Plugin` The parent plugin of a plugin nested with a `?` in its path, otherwise `null`.\n\n### parent\n\nType: `property`\n\nThe same value as the `plugin` property.\n\nReturns: `Plugin` The same value as the `plugin` property.\n\nExample: A nested plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-plugin path=\"?.detail\"></ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nPLUGIN('orders.detail', function(exports) {\n    exports.make = () => console.log(exports.name, exports.parent.name);\n});\n// logs: orders.detail orders\n</script>\n```\n\n### caller\n\nType: `property`\n\nThe plugin that called a method of this plugin through `EXEC()`.\n\nReturns: `Plugin` The plugin that called a method of this plugin through `EXEC()`.\n\nSee `talker()`.\n\n### model\n\nType: `property`\n\nReads or replaces the model of the plugin.\n\nReturns: `Object` Reads or replaces the model of the plugin.\n\nAssigning a value does not notify anything bound to the path. Use `set()` or `upd()` for that.\n\nExample: Read the model\n```js\nplugin.set('count', 2);\nconsole.log(JSON.stringify(plugin.model));\n// logs: {\"count\":2}\nplugin.model = { count: 3 };\nconsole.log(orders.count);\n// logs: 3\n```\n\n### modified\n\nType: `property`\n\nReturns the model and clears the state of its components.\n\nReturns: `Object` The model of the plugin.\n\nReading the property returns the whole model, like `get()`, and clears the touched and modified state of the components in the plugin, like the flag `@reset`. Read it after saving a form.\n\nExample: Save a form\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nPLUGIN('orders', function(exports) {\n    exports.save = function() {\n        console.log(JSON.stringify(exports.modified));\n        console.log(FIND('field').config.modified);\n    };\n});\n\nON('ready', function() {\n    SET('orders.city @change', 'Prague');\n    EXEC('orders/save');\n});\n// logs: {\"city\":\"Prague\"}\n// logs: 0\n</script>\n```\n\n### data\n\nType: `property`\n\nThe same value as the `model` property.\n\nReturns: `Object` The same value as the `model` property.\n\n### form\n\nType: `property`\n\nReturns the model and clears the touched and modified state of the components in the path of the plugin.\n\nReturns: `Object` Returns the model and clears the touched and modified state of the components in the path of the plugin.\n\nExample: Read a form and reset its state\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.name\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('field', function(self) {\n    window.com = self;\n});\n\ncom.modify('Anna');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\nconsole.log(plugin.form.name, com.element.hclass('ui-touched'));\n// logs: Anna false\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nRuns when the plugin is created.\n\nExample: Initialize the plugin\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = () => console.log(exports.path.toString());\n});\n// logs: orders\n</script>\n```\n\n### destroy()\n\nType: `delegate`\n\nRuns when the plugin is removed.\n\nThe regular cleanup removes the plugins whose element left the page.\n\nExample: Release resources\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.destroy = () => console.log('destroyed');\n});\n\n$('ui-plugin').remove();\njComponent.free();\n// logs: destroyed\n</script>\n```\n\n### get([path])\n\nType: `method`\n\nReads a value from the model.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | A path relative to the plugin. |\n\nReturns: `Object` The value.\n\nWithout a path, the method returns the whole model. A path with the `@reset` flag also clears the state of the components in the path.\n\nExample: Read a value\n```js\nplugin.set('user.name', 'Anna');\nconsole.log(plugin.get('user.name'));\n// logs: Anna\n```\n\n### set([path], value)\n\nType: `method`\n\nWrites a value to the model and notifies everything bound to the path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | A path relative to the plugin. |\n| `value` | `Object` | yes |  | The value to write. |\n\nWith an object as the only argument, the method replaces the whole model.\n\nExample: Write a value\n```js\nplugin.set('status', 'open');\nconsole.log(orders.status);\n// logs: open\n```\n\nExample: Replace the model\n```js\nplugin.set({ status: 'new', items: [] });\nconsole.log(JSON.stringify(orders));\n// logs: {\"status\":\"new\",\"items\":[]}\n```\n\n### push(path, value)\n\nType: `method`\n\nAdds a value to an array in the model.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | A path relative to the plugin. |\n| `value` | `Object` | yes |  | The value to write. |\n\nEach item of an array value is added separately.\n\nExample: Add items\n```js\nplugin.push('items', 1);\nplugin.push('items', [2, 3]);\nconsole.log(orders.items.join());\n// logs: 1,2,3\n```\n\n### inc(path, [value])\n\nType: `method`\n\nIncreases a number in the model.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | A path relative to the plugin. |\n| `value` | `Number` | no | `1` | The increment. |\n\nExample: Count\n```js\nplugin.inc('count');\nplugin.inc('count', 4);\nconsole.log(orders.count);\n// logs: 5\n```\n\n### toggle(path)\n\nType: `method`\n\nNegates a value in the model.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | A path relative to the plugin. |\n\nExample: Switch a value\n```js\nplugin.toggle('open');\nconsole.log(orders.open);\n// logs: true\n```\n\n### nul(path)\n\nType: `method`\n\nWrites `null` to the model.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | A path relative to the plugin. |\n\nExample: Clear a value\n```js\nplugin.set('user', 'Anna');\nplugin.nul('user');\nconsole.log(orders.user);\n// logs: null\n```\n\n### upd(path)\n\nType: `method`\n\nNotifies everything bound to a path, without changing the value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | A path relative to the plugin. |\n\nThe method is also available as `update()`.\n\nExample: Announce a direct change\n```js\nplugin.watch('count', value => console.log(value));\norders.count = 5;\nplugin.upd('count');\n// logs: 5\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nCalls a function on each change at a path of the model.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | A path relative to the plugin. |\n| `callback` | `Function` | yes |  | A function `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Calls the function right away with the current value. |\n\nWith a function as the first argument, the whole model is observed. Join several paths with `+`.\n\nExample: Observe a value\n```js\nplugin.watch('status', (value, flags, path) => console.log(value, path));\nplugin.set('status', 'open');\n// logs: open orders.status\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nRemoves watchers registered with `watch()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | A path relative to the plugin. |\n| `callback` | `Function` | no |  | The watcher to remove. |\n\nWithout `callback`, all the watchers of the path are removed. With a function as the only argument, the watcher of the whole model is removed. Join several paths with `+`.\n\nExample: Stop observing a value\n```js\nvar log = value => console.log('status', value);\n\nplugin.watch('status', log);\nplugin.set('status', 'open');\nplugin.unwatch('status', log);\nplugin.set('status', 'closed');\n// logs: status open\n```\n\n### makepath(path)\n\nType: `method`\n\nReplaces the `?` in a path with the path of the plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | The path. |\n\nReturns: `String` The resulting path.\n\nExample: Build a path\n```js\nconsole.log(plugin.makepath('?.items'));\n// logs: orders.items\n```\n\n### cachepath(path, expire, [def])\n\nType: `method`\n\nKeeps a value of the model in the cache between visits.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | A path relative to the plugin. |\n| `expire` | `String` | yes |  | The lifetime of the saved value, for example `1 day`. |\n| `def` | `Object|Function` | no |  | The value used when nothing is saved. |\n\nThe same as the global [CACHEPATH()](../globals/), with a path relative to the plugin.\n\nExample: Remember a filter\n```js\nplugin.cachepath('filter', '1 day', 'all');\nconsole.log(orders.filter);\n// logs: all\n```\n\n### format(value)\n\nType: `method`\n\nInserts the path of the plugin into a text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | The text. |\n\nReturns: `String` The resulting text.\n\nThe text `{0}` is replaced with the path. Without `{0}`, the path is added to the end of the text.\n\nExample: Insert the path\n```js\nconsole.log(plugin.format('{0}.items'));\n// logs: orders.items\n```\n\n### exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nCalls a method of this plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The method name. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n| `e` | `Object` | no |  | The fifth argument. |\n\nThe name can carry flags. The method runs without `this`, so refer to the plugin with `exports`.\n\nExample: Call a method\n```js\nplugin.exec('save', 1);\n// logs: save 1\n```\n\n### cmd(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuns a command on the components inside the plugin element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The command, optionally followed by flags. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nComponents register commands with [command()](../component/). `CMD()` is the same method. To reach the components of the whole page, use the global [CMD()](../globals/).\n\nExample: Clear the lists of a plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"list\"></ui-component>\n</ui-plugin>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.command('clear', () => console.log('clear'));\n});\n\nPLUGIN('orders', function(exports) {});\n\nON('ready', () => PLUGINS.orders.cmd('clear'));\n// logs: clear\n</script>\n```\n\n### setter(name, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a method of the components inside the plugin, in the form `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The target, for example `grid/refresh`. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nThe method is also available as `SETTER()`.\n\nExample: Call components inside the plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"grid\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nplugin.setter('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### alias(name)\n\nType: `method`\n\nRegisters the plugin under another name in `PLUGINS`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The other name. |\n\nExample: Use a short name\n```js\nplugin.alias('o');\nconsole.log(PLUGINS.o === plugin);\n// logs: true\n```\n\n### talker()\n\nType: `method`\n\nMarks this plugin as the caller of the next `EXEC()` call.\n\nThe called plugin finds it in its `caller` property.\n\nExample: Find out who called\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nPLUGIN('users', function(exports) {\n    exports.load = () => console.log(exports.caller.name);\n});\n\nplugin.talker();\nEXEC('users/load');\n// logs: orders\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nRegisters a handler of a global event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The event name. |\n| `callback` | `Function` | yes |  | The handler. |\n\nJoin several event names with `+`. See [Events](../events/).\n\nExample: Handle an event\n```js\nvar handler = value => console.log(value);\nplugin.on('saved', handler);\nplugin.emit('saved', 1);\nplugin.off('saved', handler);\nplugin.emit('saved', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nRemoves a handler of a global event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The event name. |\n| `callback` | `Function` | no |  | The handler to remove. |\n\nWithout a callback, all handlers of the event registered on this plugin are removed.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nEmits a global event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The event name. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\n### ajax(url, [data], [callback])\n\nType: `method`\n\nSends a request.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The method and the address. |\n| `data` | `Object` | no |  | The data to send. |\n| `callback` | `Function` | no |  | A function `(response)`, or a path. |\n\nThe address has the form `METHOD /url`. A string as the callback is a path relative to the plugin that receives the response.\n\nExample: Store the response in the model\n```js\nplugin.ajax('GET /api/orders/', 'items');\nconsole.log(orders.items.length);\n// logs: 2\n```\n\n### tapi(name, [data], [callback])\n\nType: `method`\n\nCalls an operation of the API at the address in `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the operation. |\n| `data` | `Object` | no |  | The data to send. |\n| `callback` | `Function` | no |  | A function `(response)`, or a path. |\n\nA string as the callback is a path relative to the plugin that receives the response.\n\nExample: Call an API operation\n```js\nDEF.api = '/api/';\nplugin.tapi('orders_list', 'items');\n// sends: POST /api/ {\"schema\":\"orders_list\"}\n```\n\n### pipe(name, [data], [callback])\n\nType: `method`\n\nCalls an operation of the API at the address in `DEF.pipe`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the operation. |\n| `data` | `Object` | no |  | The data to send. |\n| `callback` | `Function` | no |  | A function `(response)`, or a path. |\n\nIt works in the same way as `tapi()`.\n\nExample: Call a pipe operation\n```js\nDEF.pipe = '/pipe/';\nplugin.pipe('orders_save', { id: 1 }, response => console.log(response.ok));\n// logs: true\n```\n","entries":[{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"caller","since":"","deprecated":false},{"type":"property","name":"model","signature":"model","since":"","deprecated":false},{"type":"property","name":"modified","signature":"modified","since":"","deprecated":false},{"type":"property","name":"data","signature":"data","since":"","deprecated":false},{"type":"property","name":"form","signature":"form","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set([path], value)","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(path, value)","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"inc(path, [value])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"toggle(path)","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"nul(path)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd(path)","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"cachepath()","signature":"cachepath(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"format(value)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"cmd()","signature":"cmd(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setter()","signature":"setter(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"alias()","signature":"alias(name)","since":"","deprecated":false},{"type":"method","name":"talker()","signature":"talker()","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"pipe()","signature":"pipe(name, [data], [callback])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcX882o61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"Plugin","summary":"Die Eigenschaften, Methoden und Delegates einer Plugin-Instanz.","markdown":"---\ntitle: Plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Plugin\n\n> Die Eigenschaften, Methoden und Delegates einer Plugin-Instanz.\n\nEine Plugin-Instanz ist das erste Argument der Funktion, die an `PLUGIN()` übergeben wird, und heißt meist `exports`. Für jedes Element [ui-plugin](../ui-plugin/) wird eine Instanz erstellt. Die Methoden arbeiten mit Paths relativ zum Plugin, wie in der Anleitung [Plugins](../../guides/plugins/) erklärt. Die Beispiele unten verwenden ein Plugin mit dem Path `orders`.\n\n## API\n\n### name\n\nType: `property`\n\nDer Path des Plugins.\n\nReturns: `String` Der Path des Plugins.\n\n### path\n\nType: `property`\n\nDer Path des Plugin-Modells.\n\nReturns: `Path` Der Path des Plugin-Modells.\n\nSiehe [Path](../path/).\n\n### config\n\nType: `property`\n\nDie Konfiguration des Plugins.\n\nReturns: `Object` Die Konfiguration des Plugins.\n\n### element\n\nType: `property`\n\nDas Element des Plugins als jQuery-Objekt.\n\nReturns: `jQuery` Das Element des Plugins als jQuery-Objekt.\n\n### dom\n\nType: `property`\n\nDas Element des Plugins.\n\nReturns: `HTMLElement` Das Element des Plugins.\n\n### scope\n\nType: `property`\n\nDas Objekt, gegen das Paths aufgelöst werden, also `window`.\n\nReturns: `Object` Das Objekt, gegen das Paths aufgelöst werden, also `window`.\n\n### cls\n\nType: `property`\n\nDer Wert des Attributs `path` des Elements.\n\nReturns: `String` Der Wert des Attributs `path` des Elements.\n\n### ready\n\nType: `property`\n\nIst `true`, wenn das Plugin initialisiert ist.\n\nReturns: `Boolean` Ist `true`, wenn das Plugin initialisiert ist.\n\n### plugin\n\nType: `property`\n\nDas übergeordnete Plugin eines Plugins, das mit einem `?` im Path verschachtelt ist, sonst `null`.\n\nReturns: `Plugin` Das übergeordnete Plugin eines Plugins, das mit einem `?` im Path verschachtelt ist, sonst `null`.\n\n### parent\n\nType: `property`\n\nDerselbe Wert wie die Eigenschaft `plugin`.\n\nReturns: `Plugin` Derselbe Wert wie die Eigenschaft `plugin`.\n\nExample: Ein verschachteltes Plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-plugin path=\"?.detail\"></ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nPLUGIN('orders.detail', function(exports) {\n    exports.make = () => console.log(exports.name, exports.parent.name);\n});\n// logs: orders.detail orders\n</script>\n```\n\n### caller\n\nType: `property`\n\nDas Plugin, das über `EXEC()` eine Methode dieses Plugins aufgerufen hat.\n\nReturns: `Plugin` Das Plugin, das über `EXEC()` eine Methode dieses Plugins aufgerufen hat.\n\nSiehe `talker()`.\n\n### model\n\nType: `property`\n\nLiest oder ersetzt das Modell des Plugins.\n\nReturns: `Object` Liest oder ersetzt das Modell des Plugins.\n\nEine Zuweisung benachrichtigt nichts, was an den Path gebunden ist. Verwende dafür `set()` oder `upd()`.\n\nExample: Modell lesen\n```js\nplugin.set('count', 2);\nconsole.log(JSON.stringify(plugin.model));\n// logs: {\"count\":2}\nplugin.model = { count: 3 };\nconsole.log(orders.count);\n// logs: 3\n```\n\n### modified\n\nType: `property`\n\nGibt das Modell zurück und löscht den Zustand seiner Komponenten.\n\nReturns: `Object` Das Modell des Plugins.\n\nWenn du die Eigenschaft liest, erhältst du das gesamte Modell, wie bei `get()`, und der Zustand „berührt“ und „geändert“ der Komponenten im Plugin wird gelöscht, wie mit dem Flag `@reset`. Lies sie, nachdem du ein Formular gespeichert hast.\n\nExample: Ein Formular speichern\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nPLUGIN('orders', function(exports) {\n    exports.save = function() {\n        console.log(JSON.stringify(exports.modified));\n        console.log(FIND('field').config.modified);\n    };\n});\n\nON('ready', function() {\n    SET('orders.city @change', 'Prague');\n    EXEC('orders/save');\n});\n// logs: {\"city\":\"Prague\"}\n// logs: 0\n</script>\n```\n\n### data\n\nType: `property`\n\nDerselbe Wert wie die Eigenschaft `model`.\n\nReturns: `Object` Derselbe Wert wie die Eigenschaft `model`.\n\n### form\n\nType: `property`\n\nGibt das Modell zurück und löscht den Zustand berührt und geändert der Komponenten im Path des Plugins.\n\nReturns: `Object` Gibt das Modell zurück und löscht den Zustand berührt und geändert der Komponenten im Path des Plugins.\n\nExample: Formular lesen und seinen Zustand zurücksetzen\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.name\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('field', function(self) {\n    window.com = self;\n});\n\ncom.modify('Anna');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\nconsole.log(plugin.form.name, com.element.hclass('ui-touched'));\n// logs: Anna false\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nWird ausgeführt, wenn das Plugin erstellt wird.\n\nExample: Plugin initialisieren\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = () => console.log(exports.path.toString());\n});\n// logs: orders\n</script>\n```\n\n### destroy()\n\nType: `delegate`\n\nWird ausgeführt, wenn das Plugin entfernt wird.\n\nDie regelmäßige Bereinigung entfernt die Plugins, deren Element die Seite verlassen hat.\n\nExample: Ressourcen freigeben\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.destroy = () => console.log('destroyed');\n});\n\n$('ui-plugin').remove();\njComponent.free();\n// logs: destroyed\n</script>\n```\n\n### get([path])\n\nType: `method`\n\nLiest einen Wert aus dem Modell.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Ein Path relativ zum Plugin. |\n\nReturns: `Object` Der Wert.\n\nOhne Path gibt die Methode das gesamte Modell zurück. Ein Path mit dem Flag `@reset` löscht zusätzlich den Zustand der Komponenten im Path.\n\nExample: Wert lesen\n```js\nplugin.set('user.name', 'Anna');\nconsole.log(plugin.get('user.name'));\n// logs: Anna\n```\n\n### set([path], value)\n\nType: `method`\n\nSchreibt einen Wert in das Modell und benachrichtigt alles, was an den Path gebunden ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Ein Path relativ zum Plugin. |\n| `value` | `Object` | yes |  | Der zu schreibende Wert. |\n\nMit einem Objekt als einzigem Argument ersetzt die Methode das gesamte Modell.\n\nExample: Wert schreiben\n```js\nplugin.set('status', 'open');\nconsole.log(orders.status);\n// logs: open\n```\n\nExample: Das Modell ersetzen\n```js\nplugin.set({ status: 'new', items: [] });\nconsole.log(JSON.stringify(orders));\n// logs: {\"status\":\"new\",\"items\":[]}\n```\n\n### push(path, value)\n\nType: `method`\n\nFügt einem Array im Modell einen Wert hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Ein Path relativ zum Plugin. |\n| `value` | `Object` | yes |  | Der zu schreibende Wert. |\n\nJeder Eintrag eines Array-Werts wird einzeln hinzugefügt.\n\nExample: Elemente hinzufügen\n```js\nplugin.push('items', 1);\nplugin.push('items', [2, 3]);\nconsole.log(orders.items.join());\n// logs: 1,2,3\n```\n\n### inc(path, [value])\n\nType: `method`\n\nErhöht eine Zahl im Modell.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Ein Path relativ zum Plugin. |\n| `value` | `Number` | no | `1` | Die Schrittweite. |\n\nExample: Zählen\n```js\nplugin.inc('count');\nplugin.inc('count', 4);\nconsole.log(orders.count);\n// logs: 5\n```\n\n### toggle(path)\n\nType: `method`\n\nNegiert einen Wert im Modell.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Ein Path relativ zum Plugin. |\n\nExample: Wert umschalten\n```js\nplugin.toggle('open');\nconsole.log(orders.open);\n// logs: true\n```\n\n### nul(path)\n\nType: `method`\n\nSchreibt `null` in das Modell.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Ein Path relativ zum Plugin. |\n\nExample: Einen Wert leeren\n```js\nplugin.set('user', 'Anna');\nplugin.nul('user');\nconsole.log(orders.user);\n// logs: null\n```\n\n### upd(path)\n\nType: `method`\n\nBenachrichtigt alles, was an einen Path gebunden ist, ohne den Wert zu ändern.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Ein Path relativ zum Plugin. |\n\nDie Methode steht auch als `update()` zur Verfügung.\n\nExample: Direkte Änderung melden\n```js\nplugin.watch('count', value => console.log(value));\norders.count = 5;\nplugin.upd('count');\n// logs: 5\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nRuft bei jeder Änderung an einem Path des Modells eine Funktion auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Ein Path relativ zum Plugin. |\n| `callback` | `Function` | yes |  | Eine Funktion `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Ruft die Funktion sofort mit dem aktuellen Wert auf. |\n\nMit einer Funktion als erstem Argument wird das gesamte Modell beobachtet. Verbinde mehrere Paths mit `+`.\n\nExample: Wert beobachten\n```js\nplugin.watch('status', (value, flags, path) => console.log(value, path));\nplugin.set('status', 'open');\n// logs: open orders.status\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nEntfernt Watcher, die mit `watch()` registriert wurden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Ein Path relativ zum Plugin. |\n| `callback` | `Function` | no |  | Der Watcher, der entfernt werden soll. |\n\nOhne `callback` werden alle Watcher des Paths entfernt. Mit einer Funktion als einzigem Argument wird der Watcher des gesamten Modells entfernt. Verbinde mehrere Paths mit `+`.\n\nExample: Einen Wert nicht mehr beobachten\n```js\nvar log = value => console.log('status', value);\n\nplugin.watch('status', log);\nplugin.set('status', 'open');\nplugin.unwatch('status', log);\nplugin.set('status', 'closed');\n// logs: status open\n```\n\n### makepath(path)\n\nType: `method`\n\nErsetzt das `?` in einem Path durch den Path des Plugins.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Der Path. |\n\nReturns: `String` Der resultierende Path.\n\nExample: Path bilden\n```js\nconsole.log(plugin.makepath('?.items'));\n// logs: orders.items\n```\n\n### cachepath(path, expire, [def])\n\nType: `method`\n\nBewahrt einen Wert des Modells zwischen Besuchen im Cache auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Ein Path relativ zum Plugin. |\n| `expire` | `String` | yes |  | Die Lebensdauer des gespeicherten Werts, zum Beispiel `1 day`. |\n| `def` | `Object|Function` | no |  | Der Wert, der verwendet wird, wenn nichts gespeichert ist. |\n\nWie das globale [CACHEPATH()](../globals/), mit einem Path relativ zum Plugin.\n\nExample: Einen Filter merken\n```js\nplugin.cachepath('filter', '1 day', 'all');\nconsole.log(orders.filter);\n// logs: all\n```\n\n### format(value)\n\nType: `method`\n\nFügt den Path des Plugins in einen Text ein.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Der Text. |\n\nReturns: `String` Der resultierende Text.\n\nDer Text `{0}` wird durch den Path ersetzt. Ohne `{0}` wird der Path am Ende des Textes angefügt.\n\nExample: Path einfügen\n```js\nconsole.log(plugin.format('{0}.items'));\n// logs: orders.items\n```\n\n### exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nRuft eine Methode dieses Plugins auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Methodenname. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n| `e` | `Object` | no |  | Das fünfte Argument. |\n\nDer Name kann Flags enthalten. Die Methode läuft ohne `this`, verweise also mit `exports` auf das Plugin.\n\nExample: Methode aufrufen\n```js\nplugin.exec('save', 1);\n// logs: save 1\n```\n\n### cmd(name, [a], [b], [c], [d])\n\nType: `method`\n\nFührt einen Befehl auf den Komponenten innerhalb des Plugin-Elements aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Befehl, optional gefolgt von Flags. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nKomponenten registrieren Befehle mit [command()](../component/). `CMD()` ist dieselbe Methode. Um die Komponenten der ganzen Seite zu erreichen, verwende das globale [CMD()](../globals/).\n\nExample: Die Listen eines Plugins leeren\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"list\"></ui-component>\n</ui-plugin>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.command('clear', () => console.log('clear'));\n});\n\nPLUGIN('orders', function(exports) {});\n\nON('ready', () => PLUGINS.orders.cmd('clear'));\n// logs: clear\n</script>\n```\n\n### setter(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuft eine Methode der Komponenten innerhalb des Plugins auf, in der Form `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Das Ziel, zum Beispiel `grid/refresh`. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nDie Methode steht auch als `SETTER()` zur Verfügung.\n\nExample: Komponenten innerhalb des Plugins aufrufen\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"grid\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nplugin.setter('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### alias(name)\n\nType: `method`\n\nRegistriert das Plugin unter einem anderen Namen in `PLUGINS`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der andere Name. |\n\nExample: Kurzen Namen verwenden\n```js\nplugin.alias('o');\nconsole.log(PLUGINS.o === plugin);\n// logs: true\n```\n\n### talker()\n\nType: `method`\n\nMarkiert dieses Plugin als Aufrufer des nächsten `EXEC()`-Aufrufs.\n\nDas aufgerufene Plugin findet es in seiner Eigenschaft `caller`.\n\nExample: Herausfinden, wer aufgerufen hat\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nPLUGIN('users', function(exports) {\n    exports.load = () => console.log(exports.caller.name);\n});\n\nplugin.talker();\nEXEC('users/load');\n// logs: orders\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nRegistriert einen Handler für ein globales Event.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Event-Name. |\n| `callback` | `Function` | yes |  | Der Handler. |\n\nVerbinde mehrere Event-Namen mit `+`. Siehe [Events](../events/).\n\nExample: Event behandeln\n```js\nvar handler = value => console.log(value);\nplugin.on('saved', handler);\nplugin.emit('saved', 1);\nplugin.off('saved', handler);\nplugin.emit('saved', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nEntfernt einen Handler eines globalen Events.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Event-Name. |\n| `callback` | `Function` | no |  | Der zu entfernende Handler. |\n\nOhne Callback werden alle Handler des Events entfernt, die auf diesem Plugin registriert sind.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nLöst ein globales Event aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Event-Name. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\n### ajax(url, [data], [callback])\n\nType: `method`\n\nSendet eine Anfrage.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die Methode und die Adresse. |\n| `data` | `Object` | no |  | Die zu sendenden Daten. |\n| `callback` | `Function` | no |  | Eine Funktion `(response)` oder ein Path. |\n\nDie Adresse hat die Form `METHOD /url`. Ein String als Callback ist ein Path relativ zum Plugin, der die Antwort erhält.\n\nExample: Antwort im Modell speichern\n```js\nplugin.ajax('GET /api/orders/', 'items');\nconsole.log(orders.items.length);\n// logs: 2\n```\n\n### tapi(name, [data], [callback])\n\nType: `method`\n\nRuft eine Operation der API an der Adresse in `DEF.api` auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Operation. |\n| `data` | `Object` | no |  | Die zu sendenden Daten. |\n| `callback` | `Function` | no |  | Eine Funktion `(response)` oder ein Path. |\n\nEin String als Callback ist ein Path relativ zum Plugin, der die Antwort erhält.\n\nExample: API-Operation aufrufen\n```js\nDEF.api = '/api/';\nplugin.tapi('orders_list', 'items');\n// sends: POST /api/ {\"schema\":\"orders_list\"}\n```\n\n### pipe(name, [data], [callback])\n\nType: `method`\n\nRuft eine Operation der API an der Adresse in `DEF.pipe` auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Operation. |\n| `data` | `Object` | no |  | Die zu sendenden Daten. |\n| `callback` | `Function` | no |  | Eine Funktion `(response)` oder ein Path. |\n\nFunktioniert genauso wie `tapi()`.\n\nExample: Pipe-Operation aufrufen\n```js\nDEF.pipe = '/pipe/';\nplugin.pipe('orders_save', { id: 1 }, response => console.log(response.ok));\n// logs: true\n```\n","entries":[{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"caller","since":"","deprecated":false},{"type":"property","name":"model","signature":"model","since":"","deprecated":false},{"type":"property","name":"modified","signature":"modified","since":"","deprecated":false},{"type":"property","name":"data","signature":"data","since":"","deprecated":false},{"type":"property","name":"form","signature":"form","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set([path], value)","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(path, value)","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"inc(path, [value])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"toggle(path)","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"nul(path)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd(path)","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"cachepath()","signature":"cachepath(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"format(value)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"cmd()","signature":"cmd(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setter()","signature":"setter(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"alias()","signature":"alias(name)","since":"","deprecated":false},{"type":"method","name":"talker()","signature":"talker()","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"pipe()","signature":"pipe(name, [data], [callback])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcX882o61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Plugin","summary":"Las propiedades, los métodos y los delegates de una instancia de plugin.","markdown":"---\ntitle: Plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Plugin\n\n> Las propiedades, los métodos y los delegates de una instancia de plugin.\n\nUna instancia de plugin es el primer argumento de la función que se pasa a `PLUGIN()`, normalmente llamado `exports`. Se crea una por cada elemento [ui-plugin](../ui-plugin/). Los métodos trabajan con paths relativos al plugin, como se explica en la guía [Plugins](../../guides/plugins/). Los ejemplos siguientes usan un plugin con el path `orders`.\n\n## API\n\n### name\n\nType: `property`\n\nEl path del plugin.\n\nReturns: `String` El path del plugin.\n\n### path\n\nType: `property`\n\nEl path del modelo del plugin.\n\nReturns: `Path` El path del modelo del plugin.\n\nConsulta [Path](../path/).\n\n### config\n\nType: `property`\n\nLa configuración del plugin.\n\nReturns: `Object` La configuración del plugin.\n\n### element\n\nType: `property`\n\nEl elemento del plugin como objeto jQuery.\n\nReturns: `jQuery` El elemento del plugin como objeto jQuery.\n\n### dom\n\nType: `property`\n\nEl elemento del plugin.\n\nReturns: `HTMLElement` El elemento del plugin.\n\n### scope\n\nType: `property`\n\nEl objeto sobre el que se resuelven los paths, que es `window`.\n\nReturns: `Object` El objeto sobre el que se resuelven los paths, que es `window`.\n\n### cls\n\nType: `property`\n\nEl valor del atributo `path` del elemento.\n\nReturns: `String` El valor del atributo `path` del elemento.\n\n### ready\n\nType: `property`\n\nEs `true` cuando el plugin está inicializado.\n\nReturns: `Boolean` Es `true` cuando el plugin está inicializado.\n\n### plugin\n\nType: `property`\n\nEl plugin padre de un plugin anidado con un `?` en su path; en caso contrario, `null`.\n\nReturns: `Plugin` El plugin padre de un plugin anidado con un `?` en su path; en caso contrario, `null`.\n\n### parent\n\nType: `property`\n\nEl mismo valor que la propiedad `plugin`.\n\nReturns: `Plugin` El mismo valor que la propiedad `plugin`.\n\nExample: Un plugin anidado\n```html\n<ui-plugin path=\"orders\">\n    <ui-plugin path=\"?.detail\"></ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nPLUGIN('orders.detail', function(exports) {\n    exports.make = () => console.log(exports.name, exports.parent.name);\n});\n// logs: orders.detail orders\n</script>\n```\n\n### caller\n\nType: `property`\n\nEl plugin que llamó a un método de este plugin mediante `EXEC()`.\n\nReturns: `Plugin` El plugin que llamó a un método de este plugin mediante `EXEC()`.\n\nConsulta `talker()`.\n\n### model\n\nType: `property`\n\nLee o sustituye el modelo del plugin.\n\nReturns: `Object` Lee o sustituye el modelo del plugin.\n\nAsignar un valor no notifica a nada de lo que está enlazado al path. Para eso, usa `set()` o `upd()`.\n\nExample: Leer el modelo\n```js\nplugin.set('count', 2);\nconsole.log(JSON.stringify(plugin.model));\n// logs: {\"count\":2}\nplugin.model = { count: 3 };\nconsole.log(orders.count);\n// logs: 3\n```\n\n### modified\n\nType: `property`\n\nDevuelve el modelo y borra el estado de sus componentes.\n\nReturns: `Object` El modelo del plugin.\n\nAl leer la propiedad obtienes el modelo completo, como con `get()`, y se borra el estado de tocado y modificado de los componentes del plugin, como con el flag `@reset`. Léela después de guardar un formulario.\n\nExample: Guardar un formulario\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nPLUGIN('orders', function(exports) {\n    exports.save = function() {\n        console.log(JSON.stringify(exports.modified));\n        console.log(FIND('field').config.modified);\n    };\n});\n\nON('ready', function() {\n    SET('orders.city @change', 'Prague');\n    EXEC('orders/save');\n});\n// logs: {\"city\":\"Prague\"}\n// logs: 0\n</script>\n```\n\n### data\n\nType: `property`\n\nEl mismo valor que la propiedad `model`.\n\nReturns: `Object` El mismo valor que la propiedad `model`.\n\n### form\n\nType: `property`\n\nDevuelve el modelo y borra el estado de tocado y modificado de los componentes del path del plugin.\n\nReturns: `Object` Devuelve el modelo y borra el estado de tocado y modificado de los componentes del path del plugin.\n\nExample: Leer un formulario y restablecer su estado\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.name\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('field', function(self) {\n    window.com = self;\n});\n\ncom.modify('Anna');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\nconsole.log(plugin.form.name, com.element.hclass('ui-touched'));\n// logs: Anna false\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nSe ejecuta cuando se crea el plugin.\n\nExample: Inicializar el plugin\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = () => console.log(exports.path.toString());\n});\n// logs: orders\n</script>\n```\n\n### destroy()\n\nType: `delegate`\n\nSe ejecuta cuando se elimina el plugin.\n\nLa limpieza periódica elimina los plugins cuyo elemento ha salido de la página.\n\nExample: Liberar recursos\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.destroy = () => console.log('destroyed');\n});\n\n$('ui-plugin').remove();\njComponent.free();\n// logs: destroyed\n</script>\n```\n\n### get([path])\n\nType: `method`\n\nLee un valor del modelo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Un path relativo al plugin. |\n\nReturns: `Object` El valor.\n\nSin path, el método devuelve el modelo completo. Un path con el flag `@reset` también borra el estado de los componentes del path.\n\nExample: Leer un valor\n```js\nplugin.set('user.name', 'Anna');\nconsole.log(plugin.get('user.name'));\n// logs: Anna\n```\n\n### set([path], value)\n\nType: `method`\n\nEscribe un valor en el modelo y notifica a todo lo que está enlazado al path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `value` | `Object` | yes |  | El valor que se va a escribir. |\n\nCon un objeto como único argumento, el método sustituye el modelo completo.\n\nExample: Escribir un valor\n```js\nplugin.set('status', 'open');\nconsole.log(orders.status);\n// logs: open\n```\n\nExample: Sustituir el modelo\n```js\nplugin.set({ status: 'new', items: [] });\nconsole.log(JSON.stringify(orders));\n// logs: {\"status\":\"new\",\"items\":[]}\n```\n\n### push(path, value)\n\nType: `method`\n\nAñade un valor a un array del modelo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `value` | `Object` | yes |  | El valor que se va a escribir. |\n\nCada elemento de un valor de tipo array se añade por separado.\n\nExample: Añadir elementos\n```js\nplugin.push('items', 1);\nplugin.push('items', [2, 3]);\nconsole.log(orders.items.join());\n// logs: 1,2,3\n```\n\n### inc(path, [value])\n\nType: `method`\n\nIncrementa un número del modelo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `value` | `Number` | no | `1` | El incremento. |\n\nExample: Contar\n```js\nplugin.inc('count');\nplugin.inc('count', 4);\nconsole.log(orders.count);\n// logs: 5\n```\n\n### toggle(path)\n\nType: `method`\n\nNiega un valor del modelo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n\nExample: Alternar un valor\n```js\nplugin.toggle('open');\nconsole.log(orders.open);\n// logs: true\n```\n\n### nul(path)\n\nType: `method`\n\nEscribe `null` en el modelo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n\nExample: Borrar un valor\n```js\nplugin.set('user', 'Anna');\nplugin.nul('user');\nconsole.log(orders.user);\n// logs: null\n```\n\n### upd(path)\n\nType: `method`\n\nNotifica a todo lo que está enlazado a un path, sin cambiar el valor.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n\nEl método también está disponible como `update()`.\n\nExample: Anunciar un cambio directo\n```js\nplugin.watch('count', value => console.log(value));\norders.count = 5;\nplugin.upd('count');\n// logs: 5\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nLlama a una función en cada cambio de un path del modelo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `callback` | `Function` | yes |  | Una función `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Llama a la función de inmediato con el valor actual. |\n\nCon una función como primer argumento, se observa el modelo completo. Une varios paths con `+`.\n\nExample: Observar un valor\n```js\nplugin.watch('status', (value, flags, path) => console.log(value, path));\nplugin.set('status', 'open');\n// logs: open orders.status\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nElimina observadores registrados con `watch()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `callback` | `Function` | no |  | El observador que se va a eliminar. |\n\nSin `callback`, se eliminan todos los observadores del path. Con una función como único argumento, se elimina el observador del modelo completo. Une varios paths con `+`.\n\nExample: Dejar de observar un valor\n```js\nvar log = value => console.log('status', value);\n\nplugin.watch('status', log);\nplugin.set('status', 'open');\nplugin.unwatch('status', log);\nplugin.set('status', 'closed');\n// logs: status open\n```\n\n### makepath(path)\n\nType: `method`\n\nSustituye el `?` de un path por el path del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | El path. |\n\nReturns: `String` El path resultante.\n\nExample: Construir un path\n```js\nconsole.log(plugin.makepath('?.items'));\n// logs: orders.items\n```\n\n### cachepath(path, expire, [def])\n\nType: `method`\n\nConserva un valor del modelo en la caché entre visitas.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `expire` | `String` | yes |  | La duración del valor guardado, por ejemplo `1 day`. |\n| `def` | `Object|Function` | no |  | El valor que se usa cuando no hay nada guardado. |\n\nIgual que la función global [CACHEPATH()](../globals/), con un path relativo al plugin.\n\nExample: Recordar un filtro\n```js\nplugin.cachepath('filter', '1 day', 'all');\nconsole.log(orders.filter);\n// logs: all\n```\n\n### format(value)\n\nType: `method`\n\nInserta el path del plugin en un texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | El texto. |\n\nReturns: `String` El texto resultante.\n\nEl texto `{0}` se sustituye por el path. Sin `{0}`, el path se añade al final del texto.\n\nExample: Insertar el path\n```js\nconsole.log(plugin.format('{0}.items'));\n// logs: orders.items\n```\n\n### exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nLlama a un método de este plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del método. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n| `e` | `Object` | no |  | El quinto argumento. |\n\nEl nombre puede llevar flags. El método se ejecuta sin `this`, así que haz referencia al plugin con `exports`.\n\nExample: Llamar a un método\n```js\nplugin.exec('save', 1);\n// logs: save 1\n```\n\n### cmd(name, [a], [b], [c], [d])\n\nType: `method`\n\nEjecuta un comando en los componentes que hay dentro del elemento del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El comando, opcionalmente seguido de flags. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nLos componentes registran comandos con [command()](../component/). `CMD()` es el mismo método. Para llegar a los componentes de toda la página, usa la función global [CMD()](../globals/).\n\nExample: Vaciar las listas de un plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"list\"></ui-component>\n</ui-plugin>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.command('clear', () => console.log('clear'));\n});\n\nPLUGIN('orders', function(exports) {});\n\nON('ready', () => PLUGINS.orders.cmd('clear'));\n// logs: clear\n</script>\n```\n\n### setter(name, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a un método de los componentes que hay dentro del plugin, con la forma `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El destino, por ejemplo `grid/refresh`. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nEl método también está disponible como `SETTER()`.\n\nExample: Llamar a los componentes que hay dentro del plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"grid\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nplugin.setter('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### alias(name)\n\nType: `method`\n\nRegistra el plugin con otro nombre en `PLUGINS`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El otro nombre. |\n\nExample: Usar un nombre corto\n```js\nplugin.alias('o');\nconsole.log(PLUGINS.o === plugin);\n// logs: true\n```\n\n### talker()\n\nType: `method`\n\nMarca este plugin como el que hace la siguiente llamada a `EXEC()`.\n\nEl plugin llamado lo encuentra en su propiedad `caller`.\n\nExample: Averiguar quién hizo la llamada\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nPLUGIN('users', function(exports) {\n    exports.load = () => console.log(exports.caller.name);\n});\n\nplugin.talker();\nEXEC('users/load');\n// logs: orders\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nRegistra un manejador de un evento global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `callback` | `Function` | yes |  | El manejador. |\n\nUne varios nombres de evento con `+`. Consulta [Eventos](../events/).\n\nExample: Gestionar un evento\n```js\nvar handler = value => console.log(value);\nplugin.on('saved', handler);\nplugin.emit('saved', 1);\nplugin.off('saved', handler);\nplugin.emit('saved', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nElimina un manejador de un evento global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `callback` | `Function` | no |  | El manejador que se va a eliminar. |\n\nSin callback, se eliminan todos los manejadores del evento registrados en este plugin.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nEmite un evento global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del evento. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\n### ajax(url, [data], [callback])\n\nType: `method`\n\nEnvía una petición.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | El método y la dirección. |\n| `data` | `Object` | no |  | Los datos que se envían. |\n| `callback` | `Function` | no |  | Una función `(response)` o un path. |\n\nLa dirección tiene la forma `METHOD /url`. Una cadena como callback es un path relativo al plugin que recibe la respuesta.\n\nExample: Guardar la respuesta en el modelo\n```js\nplugin.ajax('GET /api/orders/', 'items');\nconsole.log(orders.items.length);\n// logs: 2\n```\n\n### tapi(name, [data], [callback])\n\nType: `method`\n\nLlama a una operación de la API en la dirección de `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la operación. |\n| `data` | `Object` | no |  | Los datos que se envían. |\n| `callback` | `Function` | no |  | Una función `(response)` o un path. |\n\nUna cadena como callback es un path relativo al plugin que recibe la respuesta.\n\nExample: Llamar a una operación de la API\n```js\nDEF.api = '/api/';\nplugin.tapi('orders_list', 'items');\n// sends: POST /api/ {\"schema\":\"orders_list\"}\n```\n\n### pipe(name, [data], [callback])\n\nType: `method`\n\nLlama a una operación de la API en la dirección de `DEF.pipe`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la operación. |\n| `data` | `Object` | no |  | Los datos que se envían. |\n| `callback` | `Function` | no |  | Una función `(response)` o un path. |\n\nFunciona igual que `tapi()`.\n\nExample: Llamar a una operación de pipe\n```js\nDEF.pipe = '/pipe/';\nplugin.pipe('orders_save', { id: 1 }, response => console.log(response.ok));\n// logs: true\n```\n","entries":[{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"caller","since":"","deprecated":false},{"type":"property","name":"model","signature":"model","since":"","deprecated":false},{"type":"property","name":"modified","signature":"modified","since":"","deprecated":false},{"type":"property","name":"data","signature":"data","since":"","deprecated":false},{"type":"property","name":"form","signature":"form","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set([path], value)","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(path, value)","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"inc(path, [value])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"toggle(path)","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"nul(path)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd(path)","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"cachepath()","signature":"cachepath(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"format(value)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"cmd()","signature":"cmd(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setter()","signature":"setter(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"alias()","signature":"alias(name)","since":"","deprecated":false},{"type":"method","name":"talker()","signature":"talker()","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"pipe()","signature":"pipe(name, [data], [callback])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcX882o61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Plugin","summary":"Les propriétés, les méthodes et les delegates d'une instance de plugin.","markdown":"---\ntitle: Plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Plugin\n\n> Les propriétés, les méthodes et les delegates d'une instance de plugin.\n\nUne instance de plugin est le premier argument de la fonction fournie à `PLUGIN()`, généralement nommé `exports`. Elle est créée pour chaque élément [ui-plugin](../ui-plugin/). Les méthodes travaillent avec des paths relatifs au plugin, comme l'explique le guide [Plugins](../../guides/plugins/). Les exemples ci-dessous utilisent un plugin dont le path est `orders`.\n\n## API\n\n### name\n\nType: `property`\n\nLe path du plugin.\n\nReturns: `String` Le path du plugin.\n\n### path\n\nType: `property`\n\nLe path du modèle de données du plugin.\n\nReturns: `Path` Le path du modèle de données du plugin.\n\nVoir [Path](../path/).\n\n### config\n\nType: `property`\n\nLa configuration du plugin.\n\nReturns: `Object` La configuration du plugin.\n\n### element\n\nType: `property`\n\nL'élément du plugin sous forme d'objet jQuery.\n\nReturns: `jQuery` L'élément du plugin sous forme d'objet jQuery.\n\n### dom\n\nType: `property`\n\nL'élément du plugin.\n\nReturns: `HTMLElement` L'élément du plugin.\n\n### scope\n\nType: `property`\n\nL'objet par rapport auquel les paths sont résolus, c'est-à-dire `window`.\n\nReturns: `Object` L'objet par rapport auquel les paths sont résolus, c'est-à-dire `window`.\n\n### cls\n\nType: `property`\n\nLa valeur de l'attribut `path` de l'élément.\n\nReturns: `String` La valeur de l'attribut `path` de l'élément.\n\n### ready\n\nType: `property`\n\nVaut `true` quand le plugin est initialisé.\n\nReturns: `Boolean` Vaut `true` quand le plugin est initialisé.\n\n### plugin\n\nType: `property`\n\nLe plugin parent d'un plugin imbriqué avec un `?` dans son path, sinon `null`.\n\nReturns: `Plugin` Le plugin parent d'un plugin imbriqué avec un `?` dans son path, sinon `null`.\n\n### parent\n\nType: `property`\n\nLa même valeur que la propriété `plugin`.\n\nReturns: `Plugin` La même valeur que la propriété `plugin`.\n\nExample: Un plugin imbriqué\n```html\n<ui-plugin path=\"orders\">\n    <ui-plugin path=\"?.detail\"></ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nPLUGIN('orders.detail', function(exports) {\n    exports.make = () => console.log(exports.name, exports.parent.name);\n});\n// logs: orders.detail orders\n</script>\n```\n\n### caller\n\nType: `property`\n\nLe plugin qui a appelé une méthode de ce plugin via `EXEC()`.\n\nReturns: `Plugin` Le plugin qui a appelé une méthode de ce plugin via `EXEC()`.\n\nVoir `talker()`.\n\n### model\n\nType: `property`\n\nLit ou remplace le modèle de données du plugin.\n\nReturns: `Object` Lit ou remplace le modèle de données du plugin.\n\nAssigner une valeur ne notifie rien de ce qui est lié au path. Utilise `set()` ou `upd()` pour cela.\n\nExample: Lire le modèle de données\n```js\nplugin.set('count', 2);\nconsole.log(JSON.stringify(plugin.model));\n// logs: {\"count\":2}\nplugin.model = { count: 3 };\nconsole.log(orders.count);\n// logs: 3\n```\n\n### modified\n\nType: `property`\n\nRenvoie le modèle de données et réinitialise l'état de ses composants.\n\nReturns: `Object` Le modèle de données du plugin.\n\nLire la propriété renvoie tout le modèle de données, comme `get()`, et efface l'état touché et modifié des composants du plugin, comme le flag `@reset`. Lis-la après avoir enregistré un formulaire.\n\nExample: Enregistrer un formulaire\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nPLUGIN('orders', function(exports) {\n    exports.save = function() {\n        console.log(JSON.stringify(exports.modified));\n        console.log(FIND('field').config.modified);\n    };\n});\n\nON('ready', function() {\n    SET('orders.city @change', 'Prague');\n    EXEC('orders/save');\n});\n// logs: {\"city\":\"Prague\"}\n// logs: 0\n</script>\n```\n\n### data\n\nType: `property`\n\nLa même valeur que la propriété `model`.\n\nReturns: `Object` La même valeur que la propriété `model`.\n\n### form\n\nType: `property`\n\nRenvoie le modèle de données et efface l'état touché et modifié des composants situés dans le path du plugin.\n\nReturns: `Object` Renvoie le modèle de données et efface l'état touché et modifié des composants situés dans le path du plugin.\n\nExample: Lire un formulaire et réinitialiser son état\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.name\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('field', function(self) {\n    window.com = self;\n});\n\ncom.modify('Anna');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\nconsole.log(plugin.form.name, com.element.hclass('ui-touched'));\n// logs: Anna false\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nS'exécute quand le plugin est créé.\n\nExample: Initialiser le plugin\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = () => console.log(exports.path.toString());\n});\n// logs: orders\n</script>\n```\n\n### destroy()\n\nType: `delegate`\n\nS'exécute quand le plugin est supprimé.\n\nLe nettoyage régulier supprime les plugins dont l'élément a quitté la page.\n\nExample: Libérer les ressources\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.destroy = () => console.log('destroyed');\n});\n\n$('ui-plugin').remove();\njComponent.free();\n// logs: destroyed\n</script>\n```\n\n### get([path])\n\nType: `method`\n\nLit une valeur du modèle de données.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Un path relatif au plugin. |\n\nReturns: `Object` La valeur.\n\nSans path, la méthode renvoie tout le modèle de données. Un path avec le flag `@reset` efface aussi l'état des composants situés dans le path.\n\nExample: Lire une valeur\n```js\nplugin.set('user.name', 'Anna');\nconsole.log(plugin.get('user.name'));\n// logs: Anna\n```\n\n### set([path], value)\n\nType: `method`\n\nÉcrit une valeur dans le modèle de données et notifie tout ce qui est lié au path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relatif au plugin. |\n| `value` | `Object` | yes |  | La valeur à écrire. |\n\nAvec un objet comme seul argument, la méthode remplace tout le modèle de données.\n\nExample: Écrire une valeur\n```js\nplugin.set('status', 'open');\nconsole.log(orders.status);\n// logs: open\n```\n\nExample: Remplacer le modèle de données\n```js\nplugin.set({ status: 'new', items: [] });\nconsole.log(JSON.stringify(orders));\n// logs: {\"status\":\"new\",\"items\":[]}\n```\n\n### push(path, value)\n\nType: `method`\n\nAjoute une valeur à un tableau du modèle de données.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relatif au plugin. |\n| `value` | `Object` | yes |  | La valeur à écrire. |\n\nChaque élément d'une valeur de type tableau est ajouté séparément.\n\nExample: Ajouter des éléments\n```js\nplugin.push('items', 1);\nplugin.push('items', [2, 3]);\nconsole.log(orders.items.join());\n// logs: 1,2,3\n```\n\n### inc(path, [value])\n\nType: `method`\n\nAugmente un nombre du modèle de données.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relatif au plugin. |\n| `value` | `Number` | no | `1` | L'incrément. |\n\nExample: Compter\n```js\nplugin.inc('count');\nplugin.inc('count', 4);\nconsole.log(orders.count);\n// logs: 5\n```\n\n### toggle(path)\n\nType: `method`\n\nInverse une valeur du modèle de données.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relatif au plugin. |\n\nExample: Inverser une valeur\n```js\nplugin.toggle('open');\nconsole.log(orders.open);\n// logs: true\n```\n\n### nul(path)\n\nType: `method`\n\nÉcrit `null` dans le modèle de données.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relatif au plugin. |\n\nExample: Effacer une valeur\n```js\nplugin.set('user', 'Anna');\nplugin.nul('user');\nconsole.log(orders.user);\n// logs: null\n```\n\n### upd(path)\n\nType: `method`\n\nNotifie tout ce qui est lié à un path, sans modifier la valeur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relatif au plugin. |\n\nLa méthode est aussi disponible sous le nom `update()`.\n\nExample: Annoncer une modification directe\n```js\nplugin.watch('count', value => console.log(value));\norders.count = 5;\nplugin.upd('count');\n// logs: 5\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nAppelle une fonction à chaque modification d'un path du modèle de données.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relatif au plugin. |\n| `callback` | `Function` | yes |  | Une fonction `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Appelle immédiatement la fonction avec la valeur actuelle. |\n\nAvec une fonction comme premier argument, tout le modèle de données est observé. Relie plusieurs paths avec `+`.\n\nExample: Observer une valeur\n```js\nplugin.watch('status', (value, flags, path) => console.log(value, path));\nplugin.set('status', 'open');\n// logs: open orders.status\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nSupprime les observateurs enregistrés avec `watch()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relatif au plugin. |\n| `callback` | `Function` | no |  | L'observateur à supprimer. |\n\nSans `callback`, tous les observateurs du path sont supprimés. Avec une fonction comme seul argument, c'est l'observateur de tout le modèle de données qui est supprimé. Relie plusieurs paths avec `+`.\n\nExample: Arrêter d'observer une valeur\n```js\nvar log = value => console.log('status', value);\n\nplugin.watch('status', log);\nplugin.set('status', 'open');\nplugin.unwatch('status', log);\nplugin.set('status', 'closed');\n// logs: status open\n```\n\n### makepath(path)\n\nType: `method`\n\nRemplace le `?` d'un path par le path du plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Le path. |\n\nReturns: `String` Le path obtenu.\n\nExample: Construire un path\n```js\nconsole.log(plugin.makepath('?.items'));\n// logs: orders.items\n```\n\n### cachepath(path, expire, [def])\n\nType: `method`\n\nConserve une valeur du modèle de données dans le cache d'une visite à l'autre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relatif au plugin. |\n| `expire` | `String` | yes |  | La durée de vie de la valeur enregistrée, par exemple `1 day`. |\n| `def` | `Object|Function` | no |  | La valeur utilisée quand rien n'est enregistré. |\n\nIdentique à la fonction globale [CACHEPATH()](../globals/), avec un path relatif au plugin.\n\nExample: Mémoriser un filtre\n```js\nplugin.cachepath('filter', '1 day', 'all');\nconsole.log(orders.filter);\n// logs: all\n```\n\n### format(value)\n\nType: `method`\n\nInsère le path du plugin dans un texte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Le texte. |\n\nReturns: `String` Le texte obtenu.\n\nLe texte `{0}` est remplacé par le path. Sans `{0}`, le path est ajouté à la fin du texte.\n\nExample: Insérer le path\n```js\nconsole.log(plugin.format('{0}.items'));\n// logs: orders.items\n```\n\n### exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nAppelle une méthode de ce plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la méthode. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n| `e` | `Object` | no |  | Le cinquième argument. |\n\nLe nom peut porter des flags. La méthode s'exécute sans `this` : fais donc référence au plugin avec `exports`.\n\nExample: Appeler une méthode\n```js\nplugin.exec('save', 1);\n// logs: save 1\n```\n\n### cmd(name, [a], [b], [c], [d])\n\nType: `method`\n\nExécute une commande sur les composants situés dans l'élément du plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La commande, éventuellement suivie de flags. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nLes composants enregistrent des commandes avec [command()](../component/). `CMD()` est la même méthode. Pour atteindre les composants de toute la page, utilise la fonction globale [CMD()](../globals/).\n\nExample: Vider les listes d'un plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"list\"></ui-component>\n</ui-plugin>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.command('clear', () => console.log('clear'));\n});\n\nPLUGIN('orders', function(exports) {});\n\nON('ready', () => PLUGINS.orders.cmd('clear'));\n// logs: clear\n</script>\n```\n\n### setter(name, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une méthode des composants situés dans le plugin, sous la forme `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La cible, par exemple `grid/refresh`. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nLa méthode est aussi disponible sous le nom `SETTER()`.\n\nExample: Appeler les composants situés dans le plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"grid\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nplugin.setter('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### alias(name)\n\nType: `method`\n\nEnregistre le plugin sous un autre nom dans `PLUGINS`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | L'autre nom. |\n\nExample: Utiliser un nom court\n```js\nplugin.alias('o');\nconsole.log(PLUGINS.o === plugin);\n// logs: true\n```\n\n### talker()\n\nType: `method`\n\nMarque ce plugin comme l'appelant du prochain appel à `EXEC()`.\n\nLe plugin appelé le trouve dans sa propriété `caller`.\n\nExample: Savoir qui a appelé\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nPLUGIN('users', function(exports) {\n    exports.load = () => console.log(exports.caller.name);\n});\n\nplugin.talker();\nEXEC('users/load');\n// logs: orders\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nEnregistre un gestionnaire d'un événement global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `callback` | `Function` | yes |  | Le gestionnaire. |\n\nJoins plusieurs noms d'événements avec `+`. Voir [Événements](../events/).\n\nExample: Gérer un événement\n```js\nvar handler = value => console.log(value);\nplugin.on('saved', handler);\nplugin.emit('saved', 1);\nplugin.off('saved', handler);\nplugin.emit('saved', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nSupprime un gestionnaire d'un événement global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `callback` | `Function` | no |  | Le gestionnaire à supprimer. |\n\nSans callback, tous les gestionnaires de l'événement enregistrés sur ce plugin sont supprimés.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nÉmet un événement global.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'événement. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\n### ajax(url, [data], [callback])\n\nType: `method`\n\nEnvoie une requête.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La méthode et l'adresse. |\n| `data` | `Object` | no |  | Les données à envoyer. |\n| `callback` | `Function` | no |  | Une fonction `(response)`, ou un path. |\n\nL'adresse a la forme `METHOD /url`. Une chaîne fournie comme callback est un path relatif au plugin qui reçoit la réponse.\n\nExample: Stocker la réponse dans le modèle de données\n```js\nplugin.ajax('GET /api/orders/', 'items');\nconsole.log(orders.items.length);\n// logs: 2\n```\n\n### tapi(name, [data], [callback])\n\nType: `method`\n\nAppelle une opération de l'API à l'adresse de `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'opération. |\n| `data` | `Object` | no |  | Les données à envoyer. |\n| `callback` | `Function` | no |  | Une fonction `(response)`, ou un path. |\n\nUne chaîne fournie comme callback est un path relatif au plugin qui reçoit la réponse.\n\nExample: Appeler une opération d'API\n```js\nDEF.api = '/api/';\nplugin.tapi('orders_list', 'items');\n// sends: POST /api/ {\"schema\":\"orders_list\"}\n```\n\n### pipe(name, [data], [callback])\n\nType: `method`\n\nAppelle une opération de l'API à l'adresse de `DEF.pipe`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'opération. |\n| `data` | `Object` | no |  | Les données à envoyer. |\n| `callback` | `Function` | no |  | Une fonction `(response)`, ou un path. |\n\nFonctionne de la même manière que `tapi()`.\n\nExample: Appeler une opération pipe\n```js\nDEF.pipe = '/pipe/';\nplugin.pipe('orders_save', { id: 1 }, response => console.log(response.ok));\n// logs: true\n```\n","entries":[{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"caller","since":"","deprecated":false},{"type":"property","name":"model","signature":"model","since":"","deprecated":false},{"type":"property","name":"modified","signature":"modified","since":"","deprecated":false},{"type":"property","name":"data","signature":"data","since":"","deprecated":false},{"type":"property","name":"form","signature":"form","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set([path], value)","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(path, value)","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"inc(path, [value])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"toggle(path)","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"nul(path)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd(path)","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"cachepath()","signature":"cachepath(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"format(value)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"cmd()","signature":"cmd(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setter()","signature":"setter(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"alias()","signature":"alias(name)","since":"","deprecated":false},{"type":"method","name":"talker()","signature":"talker()","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"pipe()","signature":"pipe(name, [data], [callback])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcX882o61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Plugin","summary":"Le proprietà, i metodi e i delegate di un'istanza di plugin.","markdown":"---\ntitle: Plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Plugin\n\n> Le proprietà, i metodi e i delegate di un'istanza di plugin.\n\nUn'istanza di plugin è il primo argomento della funzione passata a `PLUGIN()`, di solito chiamato `exports`. Viene creata per ogni elemento [ui-plugin](../ui-plugin/). I metodi lavorano con path relativi al plugin, come spiegato nella guida [Plugin](../../guides/plugins/). Gli esempi qui sotto usano un plugin con il path `orders`.\n\n## API\n\n### name\n\nType: `property`\n\nIl path del plugin.\n\nReturns: `String` Il path del plugin.\n\n### path\n\nType: `property`\n\nIl path del modello del plugin.\n\nReturns: `Path` Il path del modello del plugin.\n\nVedi [Path](../path/).\n\n### config\n\nType: `property`\n\nLa configurazione del plugin.\n\nReturns: `Object` La configurazione del plugin.\n\n### element\n\nType: `property`\n\nL'elemento del plugin come oggetto jQuery.\n\nReturns: `jQuery` L'elemento del plugin come oggetto jQuery.\n\n### dom\n\nType: `property`\n\nL'elemento del plugin.\n\nReturns: `HTMLElement` L'elemento del plugin.\n\n### scope\n\nType: `property`\n\nL'oggetto rispetto al quale vengono risolti i path, cioè `window`.\n\nReturns: `Object` L'oggetto rispetto al quale vengono risolti i path, cioè `window`.\n\n### cls\n\nType: `property`\n\nIl valore dell'attributo `path` dell'elemento.\n\nReturns: `String` Il valore dell'attributo `path` dell'elemento.\n\n### ready\n\nType: `property`\n\nÈ `true` quando il plugin è inizializzato.\n\nReturns: `Boolean` È `true` quando il plugin è inizializzato.\n\n### plugin\n\nType: `property`\n\nIl plugin genitore di un plugin annidato con un `?` nel suo path, altrimenti `null`.\n\nReturns: `Plugin` Il plugin genitore di un plugin annidato con un `?` nel suo path, altrimenti `null`.\n\n### parent\n\nType: `property`\n\nLo stesso valore della proprietà `plugin`.\n\nReturns: `Plugin` Lo stesso valore della proprietà `plugin`.\n\nExample: Un plugin annidato\n```html\n<ui-plugin path=\"orders\">\n    <ui-plugin path=\"?.detail\"></ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nPLUGIN('orders.detail', function(exports) {\n    exports.make = () => console.log(exports.name, exports.parent.name);\n});\n// logs: orders.detail orders\n</script>\n```\n\n### caller\n\nType: `property`\n\nIl plugin che ha chiamato un metodo di questo plugin tramite `EXEC()`.\n\nReturns: `Plugin` Il plugin che ha chiamato un metodo di questo plugin tramite `EXEC()`.\n\nVedi `talker()`.\n\n### model\n\nType: `property`\n\nLegge o sostituisce il modello del plugin.\n\nReturns: `Object` Legge o sostituisce il modello del plugin.\n\nL'assegnazione di un valore non notifica nulla di ciò che è associato al path. Per farlo, usa `set()` o `upd()`.\n\nExample: Leggi il modello\n```js\nplugin.set('count', 2);\nconsole.log(JSON.stringify(plugin.model));\n// logs: {\"count\":2}\nplugin.model = { count: 3 };\nconsole.log(orders.count);\n// logs: 3\n```\n\n### modified\n\nType: `property`\n\nRestituisce il modello e azzera lo stato dei suoi componenti.\n\nReturns: `Object` Il modello del plugin.\n\nLeggere la proprietà restituisce l'intero modello, come `get()`, e azzera lo stato toccato e modificato dei componenti nel plugin, come il flag `@reset`. Leggila dopo aver salvato un modulo.\n\nExample: Salva un modulo\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nPLUGIN('orders', function(exports) {\n    exports.save = function() {\n        console.log(JSON.stringify(exports.modified));\n        console.log(FIND('field').config.modified);\n    };\n});\n\nON('ready', function() {\n    SET('orders.city @change', 'Prague');\n    EXEC('orders/save');\n});\n// logs: {\"city\":\"Prague\"}\n// logs: 0\n</script>\n```\n\n### data\n\nType: `property`\n\nLo stesso valore della proprietà `model`.\n\nReturns: `Object` Lo stesso valore della proprietà `model`.\n\n### form\n\nType: `property`\n\nRestituisce il modello e azzera lo stato toccato e modificato dei componenti nel path del plugin.\n\nReturns: `Object` Restituisce il modello e azzera lo stato toccato e modificato dei componenti nel path del plugin.\n\nExample: Leggi un modulo e azzera il suo stato\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.name\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('field', function(self) {\n    window.com = self;\n});\n\ncom.modify('Anna');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\nconsole.log(plugin.form.name, com.element.hclass('ui-touched'));\n// logs: Anna false\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nViene eseguito quando viene creato il plugin.\n\nExample: Inizializza il plugin\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = () => console.log(exports.path.toString());\n});\n// logs: orders\n</script>\n```\n\n### destroy()\n\nType: `delegate`\n\nViene eseguito quando il plugin viene rimosso.\n\nLa pulizia periodica rimuove i plugin il cui elemento è uscito dalla pagina.\n\nExample: Rilascia le risorse\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.destroy = () => console.log('destroyed');\n});\n\n$('ui-plugin').remove();\njComponent.free();\n// logs: destroyed\n</script>\n```\n\n### get([path])\n\nType: `method`\n\nLegge un valore dal modello.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Un path relativo al plugin. |\n\nReturns: `Object` Il valore.\n\nSenza un path, il metodo restituisce l'intero modello. Un path con il flag `@reset` azzera anche lo stato dei componenti nel path.\n\nExample: Leggi un valore\n```js\nplugin.set('user.name', 'Anna');\nconsole.log(plugin.get('user.name'));\n// logs: Anna\n```\n\n### set([path], value)\n\nType: `method`\n\nScrive un valore nel modello e notifica tutto ciò che è associato al path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `value` | `Object` | yes |  | Il valore da scrivere. |\n\nCon un oggetto come unico argomento, il metodo sostituisce l'intero modello.\n\nExample: Scrivi un valore\n```js\nplugin.set('status', 'open');\nconsole.log(orders.status);\n// logs: open\n```\n\nExample: Sostituisci il modello\n```js\nplugin.set({ status: 'new', items: [] });\nconsole.log(JSON.stringify(orders));\n// logs: {\"status\":\"new\",\"items\":[]}\n```\n\n### push(path, value)\n\nType: `method`\n\nAggiunge un valore a un array nel modello.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `value` | `Object` | yes |  | Il valore da scrivere. |\n\nOgni elemento di un valore di tipo array viene aggiunto separatamente.\n\nExample: Aggiungi degli elementi\n```js\nplugin.push('items', 1);\nplugin.push('items', [2, 3]);\nconsole.log(orders.items.join());\n// logs: 1,2,3\n```\n\n### inc(path, [value])\n\nType: `method`\n\nIncrementa un numero nel modello.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `value` | `Number` | no | `1` | L'incremento. |\n\nExample: Conta\n```js\nplugin.inc('count');\nplugin.inc('count', 4);\nconsole.log(orders.count);\n// logs: 5\n```\n\n### toggle(path)\n\nType: `method`\n\nNega un valore nel modello.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n\nExample: Inverti un valore\n```js\nplugin.toggle('open');\nconsole.log(orders.open);\n// logs: true\n```\n\n### nul(path)\n\nType: `method`\n\nScrive `null` nel modello.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n\nExample: Svuota un valore\n```js\nplugin.set('user', 'Anna');\nplugin.nul('user');\nconsole.log(orders.user);\n// logs: null\n```\n\n### upd(path)\n\nType: `method`\n\nNotifica tutto ciò che è associato a un path, senza modificare il valore.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n\nIl metodo è disponibile anche come `update()`.\n\nExample: Annuncia una modifica diretta\n```js\nplugin.watch('count', value => console.log(value));\norders.count = 5;\nplugin.upd('count');\n// logs: 5\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nChiama una funzione a ogni modifica in un path del modello.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `callback` | `Function` | yes |  | Una funzione `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Chiama subito la funzione con il valore corrente. |\n\nCon una funzione come primo argomento, viene osservato l'intero modello. Unisci più path con `+`.\n\nExample: Osserva un valore\n```js\nplugin.watch('status', (value, flags, path) => console.log(value, path));\nplugin.set('status', 'open');\n// logs: open orders.status\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nRimuove gli osservatori registrati con `watch()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `callback` | `Function` | no |  | L'osservatore da rimuovere. |\n\nSenza `callback`, vengono rimossi tutti gli osservatori del path. Con una funzione come unico argomento, viene rimosso l'osservatore dell'intero modello. Unisci più path con `+`.\n\nExample: Smetti di osservare un valore\n```js\nvar log = value => console.log('status', value);\n\nplugin.watch('status', log);\nplugin.set('status', 'open');\nplugin.unwatch('status', log);\nplugin.set('status', 'closed');\n// logs: status open\n```\n\n### makepath(path)\n\nType: `method`\n\nSostituisce il `?` in un path con il path del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Il path. |\n\nReturns: `String` Il path risultante.\n\nExample: Costruisci un path\n```js\nconsole.log(plugin.makepath('?.items'));\n// logs: orders.items\n```\n\n### cachepath(path, expire, [def])\n\nType: `method`\n\nConserva un valore del modello nella cache tra una visita e l'altra.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Un path relativo al plugin. |\n| `expire` | `String` | yes |  | La durata del valore salvato, ad esempio `1 day`. |\n| `def` | `Object|Function` | no |  | Il valore usato quando non c'è nulla di salvato. |\n\nCome la funzione globale [CACHEPATH()](../globals/), con un path relativo al plugin.\n\nExample: Ricorda un filtro\n```js\nplugin.cachepath('filter', '1 day', 'all');\nconsole.log(orders.filter);\n// logs: all\n```\n\n### format(value)\n\nType: `method`\n\nInserisce il path del plugin in un testo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Il testo. |\n\nReturns: `String` Il testo risultante.\n\nIl testo `{0}` viene sostituito con il path. Senza `{0}`, il path viene aggiunto alla fine del testo.\n\nExample: Inserisci il path\n```js\nconsole.log(plugin.format('{0}.items'));\n// logs: orders.items\n```\n\n### exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nChiama un metodo di questo plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del metodo. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n| `e` | `Object` | no |  | Il quinto argomento. |\n\nIl nome può contenere flag. Il metodo viene eseguito senza `this`, quindi fai riferimento al plugin con `exports`.\n\nExample: Chiama un metodo\n```js\nplugin.exec('save', 1);\n// logs: save 1\n```\n\n### cmd(name, [a], [b], [c], [d])\n\nType: `method`\n\nEsegue un comando sui componenti all'interno dell'elemento del plugin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il comando, eventualmente seguito da flag. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nI componenti registrano i comandi con [command()](../component/). `CMD()` è lo stesso metodo. Per raggiungere i componenti dell'intera pagina, usa la funzione globale [CMD()](../globals/).\n\nExample: Svuota gli elenchi di un plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"list\"></ui-component>\n</ui-plugin>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.command('clear', () => console.log('clear'));\n});\n\nPLUGIN('orders', function(exports) {});\n\nON('ready', () => PLUGINS.orders.cmd('clear'));\n// logs: clear\n</script>\n```\n\n### setter(name, [a], [b], [c], [d])\n\nType: `method`\n\nChiama un metodo dei componenti all'interno del plugin, nella forma `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La destinazione, ad esempio `grid/refresh`. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nIl metodo è disponibile anche come `SETTER()`.\n\nExample: Chiama i componenti all'interno del plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"grid\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nplugin.setter('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### alias(name)\n\nType: `method`\n\nRegistra il plugin con un altro nome in `PLUGINS`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | L'altro nome. |\n\nExample: Usa un nome breve\n```js\nplugin.alias('o');\nconsole.log(PLUGINS.o === plugin);\n// logs: true\n```\n\n### talker()\n\nType: `method`\n\nSegna questo plugin come chiamante della prossima chiamata `EXEC()`.\n\nIl plugin chiamato lo trova nella sua proprietà `caller`.\n\nExample: Scopri chi ha chiamato\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nPLUGIN('users', function(exports) {\n    exports.load = () => console.log(exports.caller.name);\n});\n\nplugin.talker();\nEXEC('users/load');\n// logs: orders\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nRegistra un gestore di un evento globale.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `callback` | `Function` | yes |  | Il gestore. |\n\nUnisci più nomi di eventi con `+`. Vedi [Eventi](../events/).\n\nExample: Gestisci un evento\n```js\nvar handler = value => console.log(value);\nplugin.on('saved', handler);\nplugin.emit('saved', 1);\nplugin.off('saved', handler);\nplugin.emit('saved', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nRimuove un gestore di un evento globale.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `callback` | `Function` | no |  | Il gestore da rimuovere. |\n\nSenza un callback, vengono rimossi tutti i gestori dell'evento registrati su questo plugin.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nEmette un evento globale.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'evento. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\n### ajax(url, [data], [callback])\n\nType: `method`\n\nInvia una richiesta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Il metodo e l'indirizzo. |\n| `data` | `Object` | no |  | I dati da inviare. |\n| `callback` | `Function` | no |  | Una funzione `(response)`, oppure un path. |\n\nL'indirizzo ha la forma `METHOD /url`. Una stringa usata come callback è un path relativo al plugin che riceve la risposta.\n\nExample: Memorizza la risposta nel modello\n```js\nplugin.ajax('GET /api/orders/', 'items');\nconsole.log(orders.items.length);\n// logs: 2\n```\n\n### tapi(name, [data], [callback])\n\nType: `method`\n\nChiama un'operazione dell'API all'indirizzo in `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'operazione. |\n| `data` | `Object` | no |  | I dati da inviare. |\n| `callback` | `Function` | no |  | Una funzione `(response)`, oppure un path. |\n\nUna stringa usata come callback è un path relativo al plugin che riceve la risposta.\n\nExample: Chiama un'operazione dell'API\n```js\nDEF.api = '/api/';\nplugin.tapi('orders_list', 'items');\n// sends: POST /api/ {\"schema\":\"orders_list\"}\n```\n\n### pipe(name, [data], [callback])\n\nType: `method`\n\nChiama un'operazione dell'API all'indirizzo in `DEF.pipe`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'operazione. |\n| `data` | `Object` | no |  | I dati da inviare. |\n| `callback` | `Function` | no |  | Una funzione `(response)`, oppure un path. |\n\nFunziona allo stesso modo di `tapi()`.\n\nExample: Chiama un'operazione pipe\n```js\nDEF.pipe = '/pipe/';\nplugin.pipe('orders_save', { id: 1 }, response => console.log(response.ok));\n// logs: true\n```\n","entries":[{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"caller","since":"","deprecated":false},{"type":"property","name":"model","signature":"model","since":"","deprecated":false},{"type":"property","name":"modified","signature":"modified","since":"","deprecated":false},{"type":"property","name":"data","signature":"data","since":"","deprecated":false},{"type":"property","name":"form","signature":"form","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set([path], value)","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(path, value)","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"inc(path, [value])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"toggle(path)","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"nul(path)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd(path)","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"cachepath()","signature":"cachepath(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"format(value)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"cmd()","signature":"cmd(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setter()","signature":"setter(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"alias()","signature":"alias(name)","since":"","deprecated":false},{"type":"method","name":"talker()","signature":"talker()","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"pipe()","signature":"pipe(name, [data], [callback])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcX882o61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/plugin/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Plugin","summary":"Vlastnosti, metódy a delegate inštancie pluginu.","markdown":"---\ntitle: Plugin\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/plugin/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Plugin\n\n> Vlastnosti, metódy a delegate inštancie pluginu.\n\nInštancia pluginu je prvým argumentom funkcie odovzdanej do `PLUGIN()`, zvyčajne s názvom `exports`. Vytvára sa pre každý element [ui-plugin](../ui-plugin/). Metódy pracujú s paths relatívnymi k pluginu, ako vysvetľuje príručka [Pluginy](../../guides/plugins/). Príklady nižšie používajú plugin s path `orders`.\n\n## API\n\n### name\n\nType: `property`\n\nPath pluginu.\n\nReturns: `String` Path pluginu.\n\n### path\n\nType: `property`\n\nPath modelu pluginu.\n\nReturns: `Path` Path modelu pluginu.\n\nPozri [Path](../path/).\n\n### config\n\nType: `property`\n\nKonfigurácia pluginu.\n\nReturns: `Object` Konfigurácia pluginu.\n\n### element\n\nType: `property`\n\nElement pluginu ako objekt jQuery.\n\nReturns: `jQuery` Element pluginu ako objekt jQuery.\n\n### dom\n\nType: `property`\n\nElement pluginu.\n\nReturns: `HTMLElement` Element pluginu.\n\n### scope\n\nType: `property`\n\nObjekt, voči ktorému sa vyhodnocujú paths, teda `window`.\n\nReturns: `Object` Objekt, voči ktorému sa vyhodnocujú paths, teda `window`.\n\n### cls\n\nType: `property`\n\nHodnota atribútu `path` elementu.\n\nReturns: `String` Hodnota atribútu `path` elementu.\n\n### ready\n\nType: `property`\n\nJe `true`, keď je plugin inicializovaný.\n\nReturns: `Boolean` Je `true`, keď je plugin inicializovaný.\n\n### plugin\n\nType: `property`\n\nNadradený plugin pluginu vnoreného pomocou `?` v jeho path, inak `null`.\n\nReturns: `Plugin` Nadradený plugin pluginu vnoreného pomocou `?` v jeho path, inak `null`.\n\n### parent\n\nType: `property`\n\nRovnaká hodnota ako vlastnosť `plugin`.\n\nReturns: `Plugin` Rovnaká hodnota ako vlastnosť `plugin`.\n\nExample: Vnorený plugin\n```html\n<ui-plugin path=\"orders\">\n    <ui-plugin path=\"?.detail\"></ui-plugin>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {});\n\nPLUGIN('orders.detail', function(exports) {\n    exports.make = () => console.log(exports.name, exports.parent.name);\n});\n// logs: orders.detail orders\n</script>\n```\n\n### caller\n\nType: `property`\n\nPlugin, ktorý zavolal metódu tohto pluginu cez `EXEC()`.\n\nReturns: `Plugin` Plugin, ktorý zavolal metódu tohto pluginu cez `EXEC()`.\n\nPozri `talker()`.\n\n### model\n\nType: `property`\n\nPrečíta alebo nahradí model pluginu.\n\nReturns: `Object` Prečíta alebo nahradí model pluginu.\n\nPriradenie hodnoty neupozorní nič, čo je naviazané na path. Na to použi `set()` alebo `upd()`.\n\nExample: Prečítaj model\n```js\nplugin.set('count', 2);\nconsole.log(JSON.stringify(plugin.model));\n// logs: {\"count\":2}\nplugin.model = { count: 3 };\nconsole.log(orders.count);\n// logs: 3\n```\n\n### modified\n\nType: `property`\n\nVráti model a vynuluje stav jeho komponentov.\n\nReturns: `Object` Model pluginu.\n\nPrečítanie vlastnosti vráti celý model, rovnako ako `get()`, a vynuluje stav dotknutia a úpravy komponentov v plugine, rovnako ako flag `@reset`. Prečítaj ju po uložení formulára.\n\nExample: Ulož formulár\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.city\"></ui-component>\n</ui-plugin>\n\n<script>\nCOMPONENT('field', function(self) {});\n\nPLUGIN('orders', function(exports) {\n    exports.save = function() {\n        console.log(JSON.stringify(exports.modified));\n        console.log(FIND('field').config.modified);\n    };\n});\n\nON('ready', function() {\n    SET('orders.city @change', 'Prague');\n    EXEC('orders/save');\n});\n// logs: {\"city\":\"Prague\"}\n// logs: 0\n</script>\n```\n\n### data\n\nType: `property`\n\nRovnaká hodnota ako vlastnosť `model`.\n\nReturns: `Object` Rovnaká hodnota ako vlastnosť `model`.\n\n### form\n\nType: `property`\n\nVráti model a vymaže stav dotknutia a úpravy komponentov na path pluginu.\n\nReturns: `Object` Vráti model a vymaže stav dotknutia a úpravy komponentov na path pluginu.\n\nExample: Prečítaj formulár a obnov jeho stav\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"field\" path=\"?.name\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('field', function(self) {\n    window.com = self;\n});\n\ncom.modify('Anna');\nconsole.log(com.element.attr('class'));\n// logs: ui-touched ui-modified\nconsole.log(plugin.form.name, com.element.hclass('ui-touched'));\n// logs: Anna false\n</script>\n```\n\n### make()\n\nType: `delegate`\n\nSpustí sa pri vytvorení pluginu.\n\nExample: Inicializuj plugin\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.make = () => console.log(exports.path.toString());\n});\n// logs: orders\n</script>\n```\n\n### destroy()\n\nType: `delegate`\n\nSpustí sa pri odstránení pluginu.\n\nPravidelné čistenie odstraňuje pluginy, ktorých element opustil stránku.\n\nExample: Uvoľni prostriedky\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    exports.destroy = () => console.log('destroyed');\n});\n\n$('ui-plugin').remove();\njComponent.free();\n// logs: destroyed\n</script>\n```\n\n### get([path])\n\nType: `method`\n\nPrečíta hodnotu z modelu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Path relatívny k pluginu. |\n\nReturns: `Object` Hodnota.\n\nBez path metóda vráti celý model. Path s flagom `@reset` navyše vymaže stav komponentov na danom path.\n\nExample: Prečítaj hodnotu\n```js\nplugin.set('user.name', 'Anna');\nconsole.log(plugin.get('user.name'));\n// logs: Anna\n```\n\n### set([path], value)\n\nType: `method`\n\nZapíše hodnotu do modelu a upozorní všetko, čo je naviazané na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path relatívny k pluginu. |\n| `value` | `Object` | yes |  | Hodnota na zápis. |\n\nS objektom ako jediným argumentom metóda nahradí celý model.\n\nExample: Zapíš hodnotu\n```js\nplugin.set('status', 'open');\nconsole.log(orders.status);\n// logs: open\n```\n\nExample: Nahraď model\n```js\nplugin.set({ status: 'new', items: [] });\nconsole.log(JSON.stringify(orders));\n// logs: {\"status\":\"new\",\"items\":[]}\n```\n\n### push(path, value)\n\nType: `method`\n\nPridá hodnotu do poľa v modeli.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path relatívny k pluginu. |\n| `value` | `Object` | yes |  | Hodnota na zápis. |\n\nKaždá položka hodnoty typu pole sa pridá samostatne.\n\nExample: Pridaj položky\n```js\nplugin.push('items', 1);\nplugin.push('items', [2, 3]);\nconsole.log(orders.items.join());\n// logs: 1,2,3\n```\n\n### inc(path, [value])\n\nType: `method`\n\nZvýši číslo v modeli.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path relatívny k pluginu. |\n| `value` | `Number` | no | `1` | Prírastok. |\n\nExample: Počítaj\n```js\nplugin.inc('count');\nplugin.inc('count', 4);\nconsole.log(orders.count);\n// logs: 5\n```\n\n### toggle(path)\n\nType: `method`\n\nNeguje hodnotu v modeli.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path relatívny k pluginu. |\n\nExample: Prepni hodnotu\n```js\nplugin.toggle('open');\nconsole.log(orders.open);\n// logs: true\n```\n\n### nul(path)\n\nType: `method`\n\nZapíše do modelu `null`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path relatívny k pluginu. |\n\nExample: Vymaž hodnotu\n```js\nplugin.set('user', 'Anna');\nplugin.nul('user');\nconsole.log(orders.user);\n// logs: null\n```\n\n### upd(path)\n\nType: `method`\n\nUpozorní všetko naviazané na path bez zmeny hodnoty.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path relatívny k pluginu. |\n\nMetóda je dostupná aj ako `update()`.\n\nExample: Oznám priamu zmenu\n```js\nplugin.watch('count', value => console.log(value));\norders.count = 5;\nplugin.upd('count');\n// logs: 5\n```\n\n### watch(path, callback, [autoinit])\n\nType: `method`\n\nZavolá funkciu pri každej zmene na path modelu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path relatívny k pluginu. |\n| `callback` | `Function` | yes |  | Funkcia `(value, flags, path)`. |\n| `autoinit` | `Boolean` | no | `false` | Zavolá funkciu hneď s aktuálnou hodnotou. |\n\nS funkciou ako prvým argumentom sa sleduje celý model. Viac paths spoj znakom `+`.\n\nExample: Sleduj hodnotu\n```js\nplugin.watch('status', (value, flags, path) => console.log(value, path));\nplugin.set('status', 'open');\n// logs: open orders.status\n```\n\n### unwatch(path, [callback])\n\nType: `method`\n\nOdstráni sledovače zaregistrované cez `watch()`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path relatívny k pluginu. |\n| `callback` | `Function` | no |  | Sledovač, ktorý sa má odstrániť. |\n\nBez `callback` sa odstránia všetky sledovače daného path. S funkciou ako jediným argumentom sa odstráni sledovač celého modelu. Viac paths spoj znakom `+`.\n\nExample: Prestaň sledovať hodnotu\n```js\nvar log = value => console.log('status', value);\n\nplugin.watch('status', log);\nplugin.set('status', 'open');\nplugin.unwatch('status', log);\nplugin.set('status', 'closed');\n// logs: status open\n```\n\n### makepath(path)\n\nType: `method`\n\nNahradí znak `?` v path za path pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path. |\n\nReturns: `String` Výsledný path.\n\nExample: Vytvor path\n```js\nconsole.log(plugin.makepath('?.items'));\n// logs: orders.items\n```\n\n### cachepath(path, expire, [def])\n\nType: `method`\n\nUchová hodnotu modelu v cache medzi návštevami.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | yes |  | Path relatívny k pluginu. |\n| `expire` | `String` | yes |  | Životnosť uloženej hodnoty, napríklad `1 day`. |\n| `def` | `Object|Function` | no |  | Hodnota, ktorá sa použije, keď nie je uložené nič. |\n\nTo isté ako globálne [CACHEPATH()](../globals/), s path relatívnym k pluginu.\n\nExample: Zapamätaj si filter\n```js\nplugin.cachepath('filter', '1 day', 'all');\nconsole.log(orders.filter);\n// logs: all\n```\n\n### format(value)\n\nType: `method`\n\nVloží path pluginu do textu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Text. |\n\nReturns: `String` Výsledný text.\n\nText `{0}` sa nahradí za path. Bez `{0}` sa path pridá na koniec textu.\n\nExample: Vlož path\n```js\nconsole.log(plugin.format('{0}.items'));\n// logs: orders.items\n```\n\n### exec(name, [a], [b], [c], [d], [e])\n\nType: `method`\n\nZavolá metódu tohto pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov metódy. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n| `e` | `Object` | no |  | Piaty argument. |\n\nNázov môže niesť flagy. Metóda beží bez `this`, preto na plugin odkazuj pomocou `exports`.\n\nExample: Zavolaj metódu\n```js\nplugin.exec('save', 1);\n// logs: save 1\n```\n\n### cmd(name, [a], [b], [c], [d])\n\nType: `method`\n\nSpustí príkaz na komponentoch vnútri elementu pluginu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Príkaz, voliteľne s flagmi za ním. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nKomponenty registrujú príkazy cez [command()](../component/). `CMD()` je tá istá metóda. Ak sa chceš dostať ku komponentom celej stránky, použi globálne [CMD()](../globals/).\n\nExample: Vyčisti zoznamy pluginu\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"list\"></ui-component>\n</ui-plugin>\n<ui-component name=\"list\"></ui-component>\n\n<script>\nCOMPONENT('list', function(self) {\n    self.command('clear', () => console.log('clear'));\n});\n\nPLUGIN('orders', function(exports) {});\n\nON('ready', () => PLUGINS.orders.cmd('clear'));\n// logs: clear\n</script>\n```\n\n### setter(name, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá metódu komponentov vnútri pluginu v tvare `component/method`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Cieľ, napríklad `grid/refresh`. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nMetóda je dostupná aj ako `SETTER()`.\n\nExample: Zavolaj komponenty vnútri pluginu\n```html\n<ui-plugin path=\"orders\">\n    <ui-component name=\"grid\"></ui-component>\n</ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nCOMPONENT('grid', function(self) {\n    self.reload = value => console.log('reload', value);\n});\n\nplugin.setter('grid/reload', 1);\n// logs: reload 1\n</script>\n```\n\n### alias(name)\n\nType: `method`\n\nZaregistruje plugin pod iným názvom v `PLUGINS`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Druhý názov. |\n\nExample: Použi krátky názov\n```js\nplugin.alias('o');\nconsole.log(PLUGINS.o === plugin);\n// logs: true\n```\n\n### talker()\n\nType: `method`\n\nOznačí tento plugin ako volajúceho pri nasledujúcom volaní `EXEC()`.\n\nVolaný plugin ho nájde vo svojej vlastnosti `caller`.\n\nExample: Zisti, kto volal\n```html\n<ui-plugin path=\"orders\"></ui-plugin>\n<ui-plugin path=\"users\"></ui-plugin>\n\n<script>\nPLUGIN('orders', function(exports) {\n    window.plugin = exports;\n});\n\nPLUGIN('users', function(exports) {\n    exports.load = () => console.log(exports.caller.name);\n});\n\nplugin.talker();\nEXEC('users/load');\n// logs: orders\n</script>\n```\n\n### on(name, callback)\n\nType: `method`\n\nZaregistruje obslužnú funkciu globálnej udalosti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | yes |  | Obslužná funkcia. |\n\nViacero názvov udalostí spoj znakom `+`. Pozri [Udalosti](../events/).\n\nExample: Obslúž udalosť\n```js\nvar handler = value => console.log(value);\nplugin.on('saved', handler);\nplugin.emit('saved', 1);\nplugin.off('saved', handler);\nplugin.emit('saved', 2);\n// logs: 1\n```\n\n### off(name, [callback])\n\nType: `method`\n\nOdstráni obslužnú funkciu globálnej udalosti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `callback` | `Function` | no |  | Obslužná funkcia na odstránenie. |\n\nBez callbacku sa odstránia všetky obslužné funkcie udalosti zaregistrované na tomto plugine.\n\n### emit(name, [a], [b], [c], [d])\n\nType: `method`\n\nVyšle globálnu udalosť.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov udalosti. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\n### ajax(url, [data], [callback])\n\nType: `method`\n\nOdošle požiadavku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Metóda a adresa. |\n| `data` | `Object` | no |  | Dáta na odoslanie. |\n| `callback` | `Function` | no |  | Funkcia `(response)` alebo path. |\n\nAdresa má tvar `METHOD /url`. Reťazec ako callback je path relatívny k pluginu, ktorý dostane odpoveď.\n\nExample: Ulož odpoveď do modelu\n```js\nplugin.ajax('GET /api/orders/', 'items');\nconsole.log(orders.items.length);\n// logs: 2\n```\n\n### tapi(name, [data], [callback])\n\nType: `method`\n\nZavolá operáciu API na adrese v `DEF.api`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov operácie. |\n| `data` | `Object` | no |  | Dáta na odoslanie. |\n| `callback` | `Function` | no |  | Funkcia `(response)` alebo path. |\n\nReťazec ako callback je path relatívny k pluginu, ktorý dostane odpoveď.\n\nExample: Zavolaj operáciu API\n```js\nDEF.api = '/api/';\nplugin.tapi('orders_list', 'items');\n// sends: POST /api/ {\"schema\":\"orders_list\"}\n```\n\n### pipe(name, [data], [callback])\n\nType: `method`\n\nZavolá operáciu API na adrese v `DEF.pipe`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov operácie. |\n| `data` | `Object` | no |  | Dáta na odoslanie. |\n| `callback` | `Function` | no |  | Funkcia `(response)` alebo path. |\n\nFunguje rovnako ako `tapi()`.\n\nExample: Zavolaj operáciu pipe\n```js\nDEF.pipe = '/pipe/';\nplugin.pipe('orders_save', { id: 1 }, response => console.log(response.ok));\n// logs: true\n```\n","entries":[{"type":"property","name":"name","signature":"name","since":"","deprecated":false},{"type":"property","name":"path","signature":"path","since":"","deprecated":false},{"type":"property","name":"config","signature":"config","since":"","deprecated":false},{"type":"property","name":"element","signature":"element","since":"","deprecated":false},{"type":"property","name":"dom","signature":"dom","since":"","deprecated":false},{"type":"property","name":"scope","signature":"scope","since":"","deprecated":false},{"type":"property","name":"cls","signature":"cls","since":"","deprecated":false},{"type":"property","name":"ready","signature":"ready","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin","since":"","deprecated":false},{"type":"property","name":"parent","signature":"parent","since":"","deprecated":false},{"type":"property","name":"caller","signature":"caller","since":"","deprecated":false},{"type":"property","name":"model","signature":"model","since":"","deprecated":false},{"type":"property","name":"modified","signature":"modified","since":"","deprecated":false},{"type":"property","name":"data","signature":"data","since":"","deprecated":false},{"type":"property","name":"form","signature":"form","since":"","deprecated":false},{"type":"delegate","name":"make()","signature":"make()","since":"","deprecated":false},{"type":"delegate","name":"destroy()","signature":"destroy()","since":"","deprecated":false},{"type":"method","name":"get()","signature":"get([path])","since":"","deprecated":false},{"type":"method","name":"set()","signature":"set([path], value)","since":"","deprecated":false},{"type":"method","name":"push()","signature":"push(path, value)","since":"","deprecated":false},{"type":"method","name":"inc()","signature":"inc(path, [value])","since":"","deprecated":false},{"type":"method","name":"toggle()","signature":"toggle(path)","since":"","deprecated":false},{"type":"method","name":"nul()","signature":"nul(path)","since":"","deprecated":false},{"type":"method","name":"upd()","signature":"upd(path)","since":"","deprecated":false},{"type":"method","name":"watch()","signature":"watch(path, callback, [autoinit])","since":"","deprecated":false},{"type":"method","name":"unwatch()","signature":"unwatch(path, [callback])","since":"","deprecated":false},{"type":"method","name":"makepath()","signature":"makepath(path)","since":"","deprecated":false},{"type":"method","name":"cachepath()","signature":"cachepath(path, expire, [def])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"format(value)","since":"","deprecated":false},{"type":"method","name":"exec()","signature":"exec(name, [a], [b], [c], [d], [e])","since":"","deprecated":false},{"type":"method","name":"cmd()","signature":"cmd(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"setter()","signature":"setter(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"alias()","signature":"alias(name)","since":"","deprecated":false},{"type":"method","name":"talker()","signature":"talker()","since":"","deprecated":false},{"type":"method","name":"on()","signature":"on(name, callback)","since":"","deprecated":false},{"type":"method","name":"off()","signature":"off(name, [callback])","since":"","deprecated":false},{"type":"method","name":"emit()","signature":"emit(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"ajax()","signature":"ajax(url, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"tapi()","signature":"tapi(name, [data], [callback])","since":"","deprecated":false},{"type":"method","name":"pipe()","signature":"pipe(name, [data], [callback])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaoCQo61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/ui-import/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"ui-import","summary":"The attributes and the config keys of the ui-import element.","markdown":"---\ntitle: ui-import\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/ui-import/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-import\n\n> The attributes and the config keys of the ui-import element.\n\nThe `<ui-import>` element downloads content from your server and inserts it into the page. It uses `IMPORT()`, described in the [Importing content](../../guides/importing/) guide together with the flags that the address accepts.\n\n## API\n\n### path=\"URL\"\n\nType: `property`\n\nThe address of the content.\n\nThe address can carry the flags of `IMPORT()`, for example `/parts/menu.html @prepend`. The content is appended to the element unless `target` says otherwise.\n\nExample: Import a part of the page\n```html\n<ui-import path=\"/parts/menu.html\"></ui-import>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nThe options of the import.\n\nThe format is the same as in [ui-component](../ui-component/).\n\n### plugin=\"path\"\n\nType: `property`\n\nCreates a plugin on the element itself.\n\nThe plugin is created ahead of the download, so the imported content can use its path.\n\nExample: Import into a new plugin\n```html\n<ui-import path=\"/parts/form.html\" plugin=\"myform\"></ui-import>\n\n<script>\nPLUGIN('myform', function(exports) {\n    console.log('plugin', exports.path.toString());\n});\n// logs: plugin myform\n</script>\n```\n\n### url:address\n\nType: `config`\n\nThe address of the content, used when the `path` attribute is empty.\n\nExample: Set the address in the configuration\n```html\n<ui-import config=\"url:/parts/footer.html\"></ui-import>\n```\n\n### target:selector\n\nType: `config`\n\nInserts the content into another element.\n\nExample: Choose where the content goes\n```html\n<div id=\"content\"></div>\n<ui-import path=\"/parts/news.html\" config=\"target:#content\"></ui-import>\n```\n\n### path:value\n\nType: `config`\n\nReplaces the keywords `~PATH~` and `CLASS` in the imported content.\n\nThe value is also added to `<ui-plugin>` elements without a `path` attribute, and given as the name to a `PLUGIN(function(...` declaration without a name.\n\nExample: Reuse one part with different paths\n```html\n<ui-import path=\"/parts/item.html\" config=\"path:orders;id:o1\"></ui-import>\n```\n\n### id:value\n\nType: `config`\n\nReplaces the keyword `~ID~` in the imported content.\n\n### init:path\n\nType: `config`\n\nCalls a function when the content is in the page.\n\nA value that starts with `?` refers to the closest plugin of the target element.\n\nExample: Run code after the import\n```html\n<ui-import path=\"/parts/chart.html\" config=\"init:FUNC.imported\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n    console.log($('ui-import canvas').length);\n};\n// logs: 1\n</script>\n```\n\n### class:name\n\nType: `config`\n\nToggles a CSS class on the target element when the content is in the page.\n\nExample: Mark the element as loaded\n```html\n<ui-import path=\"/parts/text.html\" config=\"class:loaded\"></ui-import>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"URL\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:address","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:value","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:value","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaoCQo61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/ui-import/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"ui-import","summary":"Die Attribute und Config-Keys des Elements ui-import.","markdown":"---\ntitle: ui-import\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/ui-import/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-import\n\n> Die Attribute und Config-Keys des Elements ui-import.\n\nDas Element `<ui-import>` lädt Inhalt von deinem Server herunter und fügt ihn in die Seite ein. Es verwendet `IMPORT()`, das zusammen mit den Flags, die die Adresse akzeptiert, in der Anleitung [Inhalte importieren](../../guides/importing/) beschrieben ist.\n\n## API\n\n### path=\"URL\"\n\nType: `property`\n\nDie Adresse des Inhalts.\n\nDie Adresse kann die Flags von `IMPORT()` enthalten, zum Beispiel `/parts/menu.html @prepend`. Der Inhalt wird an das Element angehängt, sofern `target` nichts anderes angibt.\n\nExample: Teil der Seite importieren\n```html\n<ui-import path=\"/parts/menu.html\"></ui-import>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nDie Optionen des Imports.\n\nDas Format ist dasselbe wie bei [ui-component](../ui-component/).\n\n### plugin=\"path\"\n\nType: `property`\n\nErstellt ein Plugin auf dem Element selbst.\n\nDas Plugin wird vor dem Download erstellt, sodass der importierte Inhalt seinen Path verwenden kann.\n\nExample: In ein neues Plugin importieren\n```html\n<ui-import path=\"/parts/form.html\" plugin=\"myform\"></ui-import>\n\n<script>\nPLUGIN('myform', function(exports) {\n    console.log('plugin', exports.path.toString());\n});\n// logs: plugin myform\n</script>\n```\n\n### url:address\n\nType: `config`\n\nDie Adresse des Inhalts, die verwendet wird, wenn das Attribut `path` leer ist.\n\nExample: Adresse in der Konfiguration setzen\n```html\n<ui-import config=\"url:/parts/footer.html\"></ui-import>\n```\n\n### target:selector\n\nType: `config`\n\nFügt den Inhalt in ein anderes Element ein.\n\nExample: Festlegen, wohin der Inhalt kommt\n```html\n<div id=\"content\"></div>\n<ui-import path=\"/parts/news.html\" config=\"target:#content\"></ui-import>\n```\n\n### path:value\n\nType: `config`\n\nErsetzt die Schlüsselwörter `~PATH~` und `CLASS` im importierten Inhalt.\n\nDer Wert wird auch `<ui-plugin>`-Elementen ohne Attribut `path` hinzugefügt und einer `PLUGIN(function(...`-Deklaration ohne Namen als Name gegeben.\n\nExample: Einen Teil mit verschiedenen Paths wiederverwenden\n```html\n<ui-import path=\"/parts/item.html\" config=\"path:orders;id:o1\"></ui-import>\n```\n\n### id:value\n\nType: `config`\n\nErsetzt das Schlüsselwort `~ID~` im importierten Inhalt.\n\n### init:path\n\nType: `config`\n\nRuft eine Funktion auf, wenn der Inhalt auf der Seite ist.\n\nEin Wert, der mit `?` beginnt, verweist auf das nächstgelegene Plugin des Zielelements.\n\nExample: Code nach dem Import ausführen\n```html\n<ui-import path=\"/parts/chart.html\" config=\"init:FUNC.imported\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n    console.log($('ui-import canvas').length);\n};\n// logs: 1\n</script>\n```\n\n### class:name\n\nType: `config`\n\nSchaltet eine CSS-Klasse am Zielelement um, wenn der Inhalt auf der Seite ist.\n\nExample: Element als geladen markieren\n```html\n<ui-import path=\"/parts/text.html\" config=\"class:loaded\"></ui-import>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"URL\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:address","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:value","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:value","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaoCQo61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/ui-import/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"ui-import","summary":"Los atributos y las claves de configuración del elemento ui-import.","markdown":"---\ntitle: ui-import\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/ui-import/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-import\n\n> Los atributos y las claves de configuración del elemento ui-import.\n\nEl elemento `<ui-import>` descarga contenido de tu servidor y lo inserta en la página. Usa `IMPORT()`, que se describe en la guía [Importar contenido](../../guides/importing/) junto con los flags que acepta la dirección.\n\n## API\n\n### path=\"URL\"\n\nType: `property`\n\nLa dirección del contenido.\n\nLa dirección puede llevar los flags de `IMPORT()`, por ejemplo `/parts/menu.html @prepend`. El contenido se añade al final del elemento, salvo que `target` indique otra cosa.\n\nExample: Importar una parte de la página\n```html\n<ui-import path=\"/parts/menu.html\"></ui-import>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nLas opciones de la importación.\n\nEl formato es el mismo que en [ui-component](../ui-component/).\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea un plugin en el propio elemento.\n\nEl plugin se crea antes de la descarga, así que el contenido importado puede usar su path.\n\nExample: Importar en un plugin nuevo\n```html\n<ui-import path=\"/parts/form.html\" plugin=\"myform\"></ui-import>\n\n<script>\nPLUGIN('myform', function(exports) {\n    console.log('plugin', exports.path.toString());\n});\n// logs: plugin myform\n</script>\n```\n\n### url:address\n\nType: `config`\n\nLa dirección del contenido, que se usa cuando el atributo `path` está vacío.\n\nExample: Establecer la dirección en la configuración\n```html\n<ui-import config=\"url:/parts/footer.html\"></ui-import>\n```\n\n### target:selector\n\nType: `config`\n\nInserta el contenido en otro elemento.\n\nExample: Elegir dónde va el contenido\n```html\n<div id=\"content\"></div>\n<ui-import path=\"/parts/news.html\" config=\"target:#content\"></ui-import>\n```\n\n### path:value\n\nType: `config`\n\nSustituye las palabras clave `~PATH~` y `CLASS` en el contenido importado.\n\nEl valor también se añade a los elementos `<ui-plugin>` sin atributo `path`, y se da como nombre a una declaración `PLUGIN(function(...` sin nombre.\n\nExample: Reutilizar una parte con paths distintos\n```html\n<ui-import path=\"/parts/item.html\" config=\"path:orders;id:o1\"></ui-import>\n```\n\n### id:value\n\nType: `config`\n\nSustituye la palabra clave `~ID~` en el contenido importado.\n\n### init:path\n\nType: `config`\n\nLlama a una función cuando el contenido está en la página.\n\nUn valor que empieza por `?` hace referencia al plugin más cercano del elemento de destino.\n\nExample: Ejecutar código después de la importación\n```html\n<ui-import path=\"/parts/chart.html\" config=\"init:FUNC.imported\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n    console.log($('ui-import canvas').length);\n};\n// logs: 1\n</script>\n```\n\n### class:name\n\nType: `config`\n\nAlterna una clase CSS en el elemento de destino cuando el contenido está en la página.\n\nExample: Marcar el elemento como cargado\n```html\n<ui-import path=\"/parts/text.html\" config=\"class:loaded\"></ui-import>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"URL\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:address","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:value","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:value","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaoCQo61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/ui-import/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"ui-import","summary":"Les attributs et les clés de configuration de l'élément ui-import.","markdown":"---\ntitle: ui-import\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/ui-import/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-import\n\n> Les attributs et les clés de configuration de l'élément ui-import.\n\nL'élément `<ui-import>` télécharge du contenu depuis ton serveur et l'insère dans la page. Il utilise `IMPORT()`, décrit dans le guide [Importer du contenu](../../guides/importing/) avec les flags que l'adresse accepte.\n\n## API\n\n### path=\"URL\"\n\nType: `property`\n\nL'adresse du contenu.\n\nL'adresse peut porter les flags de `IMPORT()`, par exemple `/parts/menu.html @prepend`. Le contenu est ajouté à la fin de l'élément, sauf si `target` indique autre chose.\n\nExample: Importer une partie de la page\n```html\n<ui-import path=\"/parts/menu.html\"></ui-import>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nLes options de l'import.\n\nLe format est le même que dans [ui-component](../ui-component/).\n\n### plugin=\"path\"\n\nType: `property`\n\nCrée un plugin sur l'élément lui-même.\n\nLe plugin est créé avant le téléchargement : le contenu importé peut donc utiliser son path.\n\nExample: Importer dans un nouveau plugin\n```html\n<ui-import path=\"/parts/form.html\" plugin=\"myform\"></ui-import>\n\n<script>\nPLUGIN('myform', function(exports) {\n    console.log('plugin', exports.path.toString());\n});\n// logs: plugin myform\n</script>\n```\n\n### url:address\n\nType: `config`\n\nL'adresse du contenu, utilisée quand l'attribut `path` est vide.\n\nExample: Définir l'adresse dans la configuration\n```html\n<ui-import config=\"url:/parts/footer.html\"></ui-import>\n```\n\n### target:selector\n\nType: `config`\n\nInsère le contenu dans un autre élément.\n\nExample: Choisir où va le contenu\n```html\n<div id=\"content\"></div>\n<ui-import path=\"/parts/news.html\" config=\"target:#content\"></ui-import>\n```\n\n### path:value\n\nType: `config`\n\nRemplace les mots-clés `~PATH~` et `CLASS` dans le contenu importé.\n\nLa valeur est aussi ajoutée aux éléments `<ui-plugin>` sans attribut `path`, et donnée comme nom à une déclaration `PLUGIN(function(...` sans nom.\n\nExample: Réutiliser une partie avec différents paths\n```html\n<ui-import path=\"/parts/item.html\" config=\"path:orders;id:o1\"></ui-import>\n```\n\n### id:value\n\nType: `config`\n\nRemplace le mot-clé `~ID~` dans le contenu importé.\n\n### init:path\n\nType: `config`\n\nAppelle une fonction quand le contenu est dans la page.\n\nUne valeur qui commence par `?` fait référence au plugin le plus proche de l'élément cible.\n\nExample: Exécuter du code après l'import\n```html\n<ui-import path=\"/parts/chart.html\" config=\"init:FUNC.imported\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n    console.log($('ui-import canvas').length);\n};\n// logs: 1\n</script>\n```\n\n### class:name\n\nType: `config`\n\nBascule une classe CSS sur l'élément cible quand le contenu est dans la page.\n\nExample: Marquer l'élément comme chargé\n```html\n<ui-import path=\"/parts/text.html\" config=\"class:loaded\"></ui-import>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"URL\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:address","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:value","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:value","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaoCQo61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/ui-import/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"ui-import","summary":"Gli attributi e le chiavi di configurazione dell'elemento ui-import.","markdown":"---\ntitle: ui-import\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/ui-import/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-import\n\n> Gli attributi e le chiavi di configurazione dell'elemento ui-import.\n\nL'elemento `<ui-import>` scarica i contenuti dal tuo server e li inserisce nella pagina. Usa `IMPORT()`, descritto nella guida [Importare contenuti](../../guides/importing/) insieme ai flag accettati dall'indirizzo.\n\n## API\n\n### path=\"URL\"\n\nType: `property`\n\nL'indirizzo del contenuto.\n\nL'indirizzo può contenere i flag di `IMPORT()`, ad esempio `/parts/menu.html @prepend`. Il contenuto viene aggiunto all'elemento, a meno che `target` non indichi altrimenti.\n\nExample: Importa una parte della pagina\n```html\n<ui-import path=\"/parts/menu.html\"></ui-import>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nLe opzioni dell'importazione.\n\nIl formato è lo stesso di [ui-component](../ui-component/).\n\n### plugin=\"path\"\n\nType: `property`\n\nCrea un plugin sull'elemento stesso.\n\nIl plugin viene creato prima del download, quindi il contenuto importato può usare il suo path.\n\nExample: Importa in un nuovo plugin\n```html\n<ui-import path=\"/parts/form.html\" plugin=\"myform\"></ui-import>\n\n<script>\nPLUGIN('myform', function(exports) {\n    console.log('plugin', exports.path.toString());\n});\n// logs: plugin myform\n</script>\n```\n\n### url:address\n\nType: `config`\n\nL'indirizzo del contenuto, usato quando l'attributo `path` è vuoto.\n\nExample: Imposta l'indirizzo nella configurazione\n```html\n<ui-import config=\"url:/parts/footer.html\"></ui-import>\n```\n\n### target:selector\n\nType: `config`\n\nInserisce il contenuto in un altro elemento.\n\nExample: Scegli dove inserire il contenuto\n```html\n<div id=\"content\"></div>\n<ui-import path=\"/parts/news.html\" config=\"target:#content\"></ui-import>\n```\n\n### path:value\n\nType: `config`\n\nSostituisce le parole chiave `~PATH~` e `CLASS` nel contenuto importato.\n\nIl valore viene aggiunto anche agli elementi `<ui-plugin>` senza attributo `path` e assegnato come nome a una dichiarazione `PLUGIN(function(...` senza nome.\n\nExample: Riutilizza una parte con path diversi\n```html\n<ui-import path=\"/parts/item.html\" config=\"path:orders;id:o1\"></ui-import>\n```\n\n### id:value\n\nType: `config`\n\nSostituisce la parola chiave `~ID~` nel contenuto importato.\n\n### init:path\n\nType: `config`\n\nChiama una funzione quando il contenuto è nella pagina.\n\nUn valore che inizia con `?` fa riferimento al plugin più vicino all'elemento di destinazione.\n\nExample: Esegui codice dopo l'importazione\n```html\n<ui-import path=\"/parts/chart.html\" config=\"init:FUNC.imported\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n    console.log($('ui-import canvas').length);\n};\n// logs: 1\n</script>\n```\n\n### class:name\n\nType: `config`\n\nAttiva o disattiva una classe CSS sull'elemento di destinazione quando il contenuto è nella pagina.\n\nExample: Segna l'elemento come caricato\n```html\n<ui-import path=\"/parts/text.html\" config=\"class:loaded\"></ui-import>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"URL\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:address","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:value","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:value","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcaoCQo61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/ui-import/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"ui-import","summary":"Atribúty a konfiguračné kľúče elementu ui-import.","markdown":"---\ntitle: ui-import\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/ui-import/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# ui-import\n\n> Atribúty a konfiguračné kľúče elementu ui-import.\n\nElement `<ui-import>` stiahne obsah z tvojho servera a vloží ho na stránku. Používa `IMPORT()`, ktorý opisuje príručka [Import obsahu](../../guides/importing/) spolu s flagmi, ktoré adresa prijíma.\n\n## API\n\n### path=\"URL\"\n\nType: `property`\n\nAdresa obsahu.\n\nAdresa môže niesť flagy `IMPORT()`, napríklad `/parts/menu.html @prepend`. Obsah sa pridá do elementu, pokiaľ `target` neurčuje inak.\n\nExample: Importuj časť stránky\n```html\n<ui-import path=\"/parts/menu.html\"></ui-import>\n```\n\n### config=\"key:value;key:value\"\n\nType: `property`\n\nMožnosti importu.\n\nFormát je rovnaký ako pri [ui-component](../ui-component/).\n\n### plugin=\"path\"\n\nType: `property`\n\nVytvorí plugin priamo na elemente.\n\nPlugin sa vytvorí pred stiahnutím, takže importovaný obsah môže používať jeho path.\n\nExample: Importuj do nového pluginu\n```html\n<ui-import path=\"/parts/form.html\" plugin=\"myform\"></ui-import>\n\n<script>\nPLUGIN('myform', function(exports) {\n    console.log('plugin', exports.path.toString());\n});\n// logs: plugin myform\n</script>\n```\n\n### url:address\n\nType: `config`\n\nAdresa obsahu, ktorá sa použije, keď je atribút `path` prázdny.\n\nExample: Nastav adresu v konfigurácii\n```html\n<ui-import config=\"url:/parts/footer.html\"></ui-import>\n```\n\n### target:selector\n\nType: `config`\n\nVloží obsah do iného elementu.\n\nExample: Vyber, kam obsah pôjde\n```html\n<div id=\"content\"></div>\n<ui-import path=\"/parts/news.html\" config=\"target:#content\"></ui-import>\n```\n\n### path:value\n\nType: `config`\n\nNahradí kľúčové slová `~PATH~` a `CLASS` v importovanom obsahu.\n\nHodnota sa pridá aj do elementov `<ui-plugin>` bez atribútu `path` a odovzdá sa ako názov deklarácii `PLUGIN(function(...` bez názvu.\n\nExample: Použi jednu časť opakovane s rôznymi paths\n```html\n<ui-import path=\"/parts/item.html\" config=\"path:orders;id:o1\"></ui-import>\n```\n\n### id:value\n\nType: `config`\n\nNahradí kľúčové slovo `~ID~` v importovanom obsahu.\n\n### init:path\n\nType: `config`\n\nZavolá funkciu, keď je obsah na stránke.\n\nHodnota, ktorá sa začína znakom `?`, odkazuje na najbližší plugin cieľového elementu.\n\nExample: Spusti kód po importe\n```html\n<ui-import path=\"/parts/chart.html\" config=\"init:FUNC.imported\"></ui-import>\n\n<script>\nFUNC.imported = function() {\n    console.log($('ui-import canvas').length);\n};\n// logs: 1\n</script>\n```\n\n### class:name\n\nType: `config`\n\nPrepne triedu CSS na cieľovom elemente, keď je obsah na stránke.\n\nExample: Označ element ako načítaný\n```html\n<ui-import path=\"/parts/text.html\" config=\"class:loaded\"></ui-import>\n```\n","entries":[{"type":"property","name":"path","signature":"path=\"URL\"","since":"","deprecated":false},{"type":"property","name":"config","signature":"config=\"key:value;key:value\"","since":"","deprecated":false},{"type":"property","name":"plugin","signature":"plugin=\"path\"","since":"","deprecated":false},{"type":"config","name":"url","signature":"url:address","since":"","deprecated":false},{"type":"config","name":"target","signature":"target:selector","since":"","deprecated":false},{"type":"config","name":"path","signature":"path:value","since":"","deprecated":false},{"type":"config","name":"id","signature":"id:value","since":"","deprecated":false},{"type":"config","name":"init","signature":"init:path","since":"","deprecated":false},{"type":"config","name":"class","signature":"class:name","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYtA8o61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/tangular-helpers/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"Tangular helpers","summary":"The helpers available in every Tangular template for encoding, formatting and reading code lists.","markdown":"---\ntitle: Tangular helpers\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Tangular helpers\n\n> The helpers available in every Tangular template for encoding, formatting and reading code lists.\n\nA helper follows the value in a template, as in `{{ price | format(2) }}`, and helpers can be chained. A value with no helper is encoded with `encode`. To write templates and register custom helpers, see [Templates with Tangular](../../guides/tangular/).\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nWrites a field of an item in a code list.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The code list name. |\n| `key` | `String` | no | `name` | The field to write. |\n\nReturns: `String` The value of the field.\n\nThe code list is the array in `DEF.cl[name]`, and the item is found by its `id`. When nothing is found, the helper writes `DEF.empty`, or an empty string when `key` is set.\n\nExample: Reading a code list\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', code: 'R' }];\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 2 })); // Red\nconsole.log(Tangular.render(\"{{ id | cl('colors', 'code') }}\", { id: 2 })); // R\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 9 })); // ---\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nWrites an item of a code list as a colored label.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The code list name. |\n| `key` | `String` | no | `name` | The field to write. |\n\nReturns: `String` The HTML of the label.\n\nThe helper writes a `<span class=\"ui-clcolor\">` with the item color as its background, the item icon and the field. It writes an empty string when the item is not found. The output is not encoded.\n\nExample: A colored label\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clcolor('colors') }}\", { id: 2 })); // <span class=\"ui-clcolor\" style=\"background:#f00\"><i class=\"ti ti-circle mr5\"></i>Red</span>\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nWrites an item of a code list with its icon.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The code list name. |\n| `key` | `String` | no | `name` | The field to write. |\n\nReturns: `String` The HTML of the item.\n\nThe icon takes the item color. An item without an icon writes only the field, and an item that is not found writes an empty string. The output is not encoded.\n\nExample: An item with an icon\n```js\nDEF.cl.colors = [{ id: 1, name: 'Plain' }, { id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 2 })); // <i class=\"ti ti-circle mr5\" style=\"color:#f00\"></i>Red\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 1 })); // Plain\n```\n\n### {{ value | currency([name]) }}\n\nType: `method`\n\nFormats a number or a numeric string with a registered currency.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | The currency name. |\n\nReturns: `String` The formatted price.\n\nThe helper uses [currency()](../number/). A value of another type writes an empty string.\n\nExample: Prices\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: 5 })); // 5.00 EUR\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: '7.5' })); // 7.50 EUR\n```\n\n### {{ value | def([text], [raw]) }}\n\nType: `method`\n\nAn alias of the `empty` helper.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | The text for an empty value. |\n| `raw` | `Boolean` | no | `false` | `true` writes the value without encoding. |\n\nReturns: `String` The value or the text.\n\nExample: Default text\n```js\nconsole.log(Tangular.render(\"{{ name | def('n/a') }}\", { name: null })); // n/a\n```\n\n### {{ value | empty([text], [raw]) }}\n\nType: `method`\n\nWrites a default text for an empty value.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | The text for an empty value. |\n| `raw` | `Boolean` | no | `false` | `true` writes the value without encoding. |\n\nReturns: `String` The value or the text.\n\nEvery falsy value is empty, including `0`. Other values are encoded unless `raw` is `true`. Passing `true` as the first argument also turns on `raw`.\n\nExample: Empty values\n```js\nconsole.log(Tangular.render('{{ name | empty }}', { name: '' })); // ---\nconsole.log(Tangular.render(\"{{ name | empty('n/a') }}\", { name: '' })); // n/a\nconsole.log(Tangular.render('{{ name | empty }}', { name: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render('{{ name | empty(true) }}', { name: '<b>' })); // <b>\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nEncodes a value for output.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | no |  | `json` for JSON, `json2` for indented JSON, `url` or `urlencoded` for `encodeURIComponent()`, and `querify` for a query string. |\n\nReturns: `String` The encoded value.\n\nWithout `type`, the helper escapes `<`, `>`, `&` and `\"`, and writes an empty string for `null` and `undefined`.\n\nExample: Encoding\n```js\nconsole.log(Tangular.render('{{ value | encode }}', { value: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render(\"{{ value | encode('json') }}\", { value: { a: 1 } })); // {\"a\":1}\nconsole.log(Tangular.render(\"{{ value | encode('url') }}\", { value: 'a b' })); // a%20b\nconsole.log(Tangular.render(\"{{ value | encode('querify') }}\", { value: { a: 1, b: 'x y' } })); // ?a=1&b=x%20y\n```\n\n### {{ value | format([format], [separator], [decimalSeparator]) }}\n\nType: `method`\n\nFormats a number or a date.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | The decimal places for a number, or the layout for a date. |\n| `separator` | `String` | no |  | The thousands separator of a number. |\n| `decimalSeparator` | `String` | no |  | The decimal separator of a number. |\n\nReturns: `String` The formatted value.\n\nFor a number, the arguments are those of [format()](../number/), and a number without `decimals` is written without its decimal part. For a `Date`, the first argument is the layout of [format()](../date/).\n\nA string that holds a date is converted first and uses `dd.MM.yyyy` by default, and a string that holds a number is converted to a number. `null` and `undefined` write an empty string.\n\nExample: Numbers\n```js\nconsole.log(Tangular.render('{{ value | format(2) }}', { value: 1234.5 })); // 1 234.50\nconsole.log(Tangular.render(\"{{ value | format(2, ',', '.') }}\", { value: 1234.5 })); // 1,234.50\nconsole.log(Tangular.render('{{ value | format }}', { value: 1234.5 })); // 1 234\n```\n\nExample: Dates\n```js\nvar date = new Date(2026, 10, 8, 15, 4);\nconsole.log(Tangular.render(\"{{ value | format('dd.MM.yyyy HH:mm') }}\", { value: date })); // 08.11.2026 15:04\nconsole.log(Tangular.render('{{ value | format }}', { value: '2026-11-08' })); // 08.11.2026\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nSelects the text that matches a number.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String` | yes |  | The text for 0. |\n| `one` | `String` | yes |  | The text for 1. |\n| `few` | `String` | yes |  | The text for numbers from 2 to 4. |\n| `other` | `String` | yes |  | The text for other numbers. |\n\nReturns: `String` The selected text.\n\nThe arguments are those of [pluralize()](../number/). A numeric string is converted to a number, and an empty value counts as `0`.\n\nExample: Counting items\n```js\nvar template = \"{{ count | pluralize('no items', '# item', '# items', '# items') }}\";\nconsole.log(Tangular.render(template, { count: 3 })); // 3 items\nconsole.log(Tangular.render(template, { count: 1 })); // 1 item\nconsole.log(Tangular.render(template, { count: null })); // no items\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nWrites a value without encoding.\n\nReturns: `Object` The unchanged value.\n\nUse it only for content that is safe to insert as HTML.\n\nExample: Writing HTML\n```js\nconsole.log(Tangular.render('{{ value | raw }}', { value: '<b>Hi</b>' })); // <b>Hi</b>\nconsole.log(Tangular.render('{{ value }}', { value: '<b>Hi</b>' })); // &lt;b&gt;Hi&lt;/b&gt;\n```\n","entries":[{"type":"method","name":"cl","signature":"{{ id | cl(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clcolor","signature":"{{ id | clcolor(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clicon","signature":"{{ id | clicon(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"currency","signature":"{{ value | currency([name]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [separator], [decimalSeparator]) }}","since":"","deprecated":false},{"type":"method","name":"pluralize","signature":"{{ value | pluralize(zero, one, few, other) }}","since":"","deprecated":false},{"type":"method","name":"raw","signature":"{{ value | raw }}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYtA8o61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/tangular-helpers/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"Tangular-Helper","summary":"Die Helper, die in jedem Tangular-Template zum Kodieren, Formatieren und Lesen von Codelisten zur Verfügung stehen.","markdown":"---\ntitle: Tangular-Helper\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Tangular-Helper\n\n> Die Helper, die in jedem Tangular-Template zum Kodieren, Formatieren und Lesen von Codelisten zur Verfügung stehen.\n\nEin Helper folgt im Template auf den Wert, wie in `{{ price | format(2) }}`, und Helper lassen sich verketten. Ein Wert ohne Helper wird mit `encode` kodiert. Wie du Templates schreibst und eigene Helper registrierst, erfährst du in [Templates mit Tangular](../../guides/tangular/).\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nSchreibt ein Feld eines Eintrags aus einer Codeliste.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Codeliste. |\n| `key` | `String` | no | `name` | Das zu schreibende Feld. |\n\nReturns: `String` Der Wert des Feldes.\n\nDie Codeliste ist das Array in `DEF.cl[name]`, und der Eintrag wird über seine `id` gefunden. Wird nichts gefunden, schreibt der Helper `DEF.empty` oder einen leeren String, wenn `key` gesetzt ist.\n\nExample: Codeliste lesen\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', code: 'R' }];\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 2 })); // Red\nconsole.log(Tangular.render(\"{{ id | cl('colors', 'code') }}\", { id: 2 })); // R\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 9 })); // ---\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nSchreibt einen Eintrag einer Codeliste als farbiges Label.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Codeliste. |\n| `key` | `String` | no | `name` | Das zu schreibende Feld. |\n\nReturns: `String` Das HTML des Labels.\n\nDer Helper schreibt ein `<span class=\"ui-clcolor\">` mit der Farbe des Eintrags als Hintergrund, dem Icon des Eintrags und dem Feld. Wird der Eintrag nicht gefunden, schreibt er einen leeren String. Die Ausgabe wird nicht kodiert.\n\nExample: Ein farbiges Label\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clcolor('colors') }}\", { id: 2 })); // <span class=\"ui-clcolor\" style=\"background:#f00\"><i class=\"ti ti-circle mr5\"></i>Red</span>\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nSchreibt einen Eintrag einer Codeliste mit seinem Icon.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name der Codeliste. |\n| `key` | `String` | no | `name` | Das zu schreibende Feld. |\n\nReturns: `String` Das HTML des Eintrags.\n\nDas Icon übernimmt die Farbe des Eintrags. Ein Eintrag ohne Icon schreibt nur das Feld, und ein nicht gefundener Eintrag schreibt einen leeren String. Die Ausgabe wird nicht kodiert.\n\nExample: Ein Eintrag mit Icon\n```js\nDEF.cl.colors = [{ id: 1, name: 'Plain' }, { id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 2 })); // <i class=\"ti ti-circle mr5\" style=\"color:#f00\"></i>Red\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 1 })); // Plain\n```\n\n### {{ value | currency([name]) }}\n\nType: `method`\n\nFormatiert eine Zahl oder einen numerischen String mit einer registrierten Währung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | Der Name der Währung. |\n\nReturns: `String` Der formatierte Preis.\n\nDer Helper verwendet [currency()](../number/). Ein Wert eines anderen Typs schreibt einen leeren String.\n\nExample: Preise\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: 5 })); // 5.00 EUR\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: '7.5' })); // 7.50 EUR\n```\n\n### {{ value | def([text], [raw]) }}\n\nType: `method`\n\nEin Alias des Helpers `empty`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Der Text für einen leeren Wert. |\n| `raw` | `Boolean` | no | `false` | `true` schreibt den Wert ohne Kodierung. |\n\nReturns: `String` Der Wert oder der Text.\n\nExample: Standardtext\n```js\nconsole.log(Tangular.render(\"{{ name | def('n/a') }}\", { name: null })); // n/a\n```\n\n### {{ value | empty([text], [raw]) }}\n\nType: `method`\n\nSchreibt einen Standardtext für einen leeren Wert.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Der Text für einen leeren Wert. |\n| `raw` | `Boolean` | no | `false` | `true` schreibt den Wert ohne Kodierung. |\n\nReturns: `String` Der Wert oder der Text.\n\nJeder falsy Wert gilt als leer, auch `0`. Andere Werte werden kodiert, es sei denn, `raw` ist `true`. Wird `true` als erstes Argument übergeben, ist `raw` ebenfalls aktiv.\n\nExample: Leere Werte\n```js\nconsole.log(Tangular.render('{{ name | empty }}', { name: '' })); // ---\nconsole.log(Tangular.render(\"{{ name | empty('n/a') }}\", { name: '' })); // n/a\nconsole.log(Tangular.render('{{ name | empty }}', { name: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render('{{ name | empty(true) }}', { name: '<b>' })); // <b>\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nKodiert einen Wert für die Ausgabe.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | no |  | `json` für JSON, `json2` für eingerücktes JSON, `url` oder `urlencoded` für `encodeURIComponent()` und `querify` für einen Query-String. |\n\nReturns: `String` Der kodierte Wert.\n\nOhne `type` maskiert der Helper `<`, `>`, `&` und `\"` und schreibt für `null` und `undefined` einen leeren String.\n\nExample: Kodierung\n```js\nconsole.log(Tangular.render('{{ value | encode }}', { value: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render(\"{{ value | encode('json') }}\", { value: { a: 1 } })); // {\"a\":1}\nconsole.log(Tangular.render(\"{{ value | encode('url') }}\", { value: 'a b' })); // a%20b\nconsole.log(Tangular.render(\"{{ value | encode('querify') }}\", { value: { a: 1, b: 'x y' } })); // ?a=1&b=x%20y\n```\n\n### {{ value | format([format], [separator], [decimalSeparator]) }}\n\nType: `method`\n\nFormatiert eine Zahl oder ein Datum.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | Die Dezimalstellen einer Zahl oder das Layout eines Datums. |\n| `separator` | `String` | no |  | Das Tausendertrennzeichen einer Zahl. |\n| `decimalSeparator` | `String` | no |  | Das Dezimaltrennzeichen einer Zahl. |\n\nReturns: `String` Der formatierte Wert.\n\nBei einer Zahl sind die Argumente die von [format()](../number/), und eine Zahl ohne `decimals` wird ohne ihren Dezimalteil geschrieben. Bei einem `Date` ist das erste Argument das Layout von [format()](../date/).\n\nEin String, der ein Datum enthält, wird zuerst umgewandelt und verwendet standardmäßig `dd.MM.yyyy`, und ein String, der eine Zahl enthält, wird in eine Zahl umgewandelt. `null` und `undefined` schreiben einen leeren String.\n\nExample: Zahlen\n```js\nconsole.log(Tangular.render('{{ value | format(2) }}', { value: 1234.5 })); // 1 234.50\nconsole.log(Tangular.render(\"{{ value | format(2, ',', '.') }}\", { value: 1234.5 })); // 1,234.50\nconsole.log(Tangular.render('{{ value | format }}', { value: 1234.5 })); // 1 234\n```\n\nExample: Datumswerte\n```js\nvar date = new Date(2026, 10, 8, 15, 4);\nconsole.log(Tangular.render(\"{{ value | format('dd.MM.yyyy HH:mm') }}\", { value: date })); // 08.11.2026 15:04\nconsole.log(Tangular.render('{{ value | format }}', { value: '2026-11-08' })); // 08.11.2026\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nWählt den Text aus, der zu einer Zahl passt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String` | yes |  | Der Text für 0. |\n| `one` | `String` | yes |  | Der Text für 1. |\n| `few` | `String` | yes |  | Der Text für Zahlen von 2 bis 4. |\n| `other` | `String` | yes |  | Der Text für andere Zahlen. |\n\nReturns: `String` Der ausgewählte Text.\n\nDie Argumente sind die von [pluralize()](../number/). Ein numerischer String wird in eine Zahl umgewandelt, und ein leerer Wert zählt als `0`.\n\nExample: Einträge zählen\n```js\nvar template = \"{{ count | pluralize('no items', '# item', '# items', '# items') }}\";\nconsole.log(Tangular.render(template, { count: 3 })); // 3 items\nconsole.log(Tangular.render(template, { count: 1 })); // 1 item\nconsole.log(Tangular.render(template, { count: null })); // no items\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nSchreibt einen Wert ohne Kodierung.\n\nReturns: `Object` Der unveränderte Wert.\n\nVerwende das nur für Inhalte, die sich sicher als HTML einfügen lassen.\n\nExample: HTML schreiben\n```js\nconsole.log(Tangular.render('{{ value | raw }}', { value: '<b>Hi</b>' })); // <b>Hi</b>\nconsole.log(Tangular.render('{{ value }}', { value: '<b>Hi</b>' })); // &lt;b&gt;Hi&lt;/b&gt;\n```\n","entries":[{"type":"method","name":"cl","signature":"{{ id | cl(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clcolor","signature":"{{ id | clcolor(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clicon","signature":"{{ id | clicon(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"currency","signature":"{{ value | currency([name]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [separator], [decimalSeparator]) }}","since":"","deprecated":false},{"type":"method","name":"pluralize","signature":"{{ value | pluralize(zero, one, few, other) }}","since":"","deprecated":false},{"type":"method","name":"raw","signature":"{{ value | raw }}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYtA8o61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/tangular-helpers/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Helpers de Tangular","summary":"Los helpers disponibles en todas las plantillas de Tangular para codificar, dar formato y leer listas de códigos.","markdown":"---\ntitle: Helpers de Tangular\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Helpers de Tangular\n\n> Los helpers disponibles en todas las plantillas de Tangular para codificar, dar formato y leer listas de códigos.\n\nUn helper va después del valor en una plantilla, como en `{{ price | format(2) }}`, y los helpers se pueden encadenar. Un valor sin helper se codifica con `encode`. Para escribir plantillas y registrar helpers personalizados, consulta [Plantillas con Tangular](../../guides/tangular/).\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nEscribe un campo de un elemento de una lista de códigos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la lista de códigos. |\n| `key` | `String` | no | `name` | El campo que se escribe. |\n\nReturns: `String` El valor del campo.\n\nLa lista de códigos es el array de `DEF.cl[name]`, y el elemento se busca por su `id`. Cuando no se encuentra nada, el helper escribe `DEF.empty`, o una cadena vacía cuando `key` está definido.\n\nExample: Leer una lista de códigos\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', code: 'R' }];\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 2 })); // Red\nconsole.log(Tangular.render(\"{{ id | cl('colors', 'code') }}\", { id: 2 })); // R\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 9 })); // ---\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nEscribe un elemento de una lista de códigos como una etiqueta de color.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la lista de códigos. |\n| `key` | `String` | no | `name` | El campo que se escribe. |\n\nReturns: `String` El HTML de la etiqueta.\n\nEl helper escribe un `<span class=\"ui-clcolor\">` con el color del elemento como fondo, el icono del elemento y el campo. Escribe una cadena vacía cuando no se encuentra el elemento. La salida no se codifica.\n\nExample: Una etiqueta de color\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clcolor('colors') }}\", { id: 2 })); // <span class=\"ui-clcolor\" style=\"background:#f00\"><i class=\"ti ti-circle mr5\"></i>Red</span>\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nEscribe un elemento de una lista de códigos con su icono.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la lista de códigos. |\n| `key` | `String` | no | `name` | El campo que se escribe. |\n\nReturns: `String` El HTML del elemento.\n\nEl icono toma el color del elemento. Un elemento sin icono escribe solo el campo, y un elemento que no se encuentra escribe una cadena vacía. La salida no se codifica.\n\nExample: Un elemento con icono\n```js\nDEF.cl.colors = [{ id: 1, name: 'Plain' }, { id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 2 })); // <i class=\"ti ti-circle mr5\" style=\"color:#f00\"></i>Red\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 1 })); // Plain\n```\n\n### {{ value | currency([name]) }}\n\nType: `method`\n\nDa formato a un número o a una cadena numérica con una moneda registrada.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | El nombre de la moneda. |\n\nReturns: `String` El precio con formato.\n\nEl helper usa [currency()](../number/). Un valor de otro tipo escribe una cadena vacía.\n\nExample: Precios\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: 5 })); // 5.00 EUR\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: '7.5' })); // 7.50 EUR\n```\n\n### {{ value | def([text], [raw]) }}\n\nType: `method`\n\nUn alias del helper `empty`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | El texto para un valor vacío. |\n| `raw` | `Boolean` | no | `false` | `true` escribe el valor sin codificar. |\n\nReturns: `String` El valor o el texto.\n\nExample: Texto predeterminado\n```js\nconsole.log(Tangular.render(\"{{ name | def('n/a') }}\", { name: null })); // n/a\n```\n\n### {{ value | empty([text], [raw]) }}\n\nType: `method`\n\nEscribe un texto predeterminado para un valor vacío.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | El texto para un valor vacío. |\n| `raw` | `Boolean` | no | `false` | `true` escribe el valor sin codificar. |\n\nReturns: `String` El valor o el texto.\n\nTodo valor falsy se considera vacío, incluido `0`. Los demás valores se codifican salvo que `raw` sea `true`. Pasar `true` como primer argumento también activa `raw`.\n\nExample: Valores vacíos\n```js\nconsole.log(Tangular.render('{{ name | empty }}', { name: '' })); // ---\nconsole.log(Tangular.render(\"{{ name | empty('n/a') }}\", { name: '' })); // n/a\nconsole.log(Tangular.render('{{ name | empty }}', { name: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render('{{ name | empty(true) }}', { name: '<b>' })); // <b>\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nCodifica un valor para la salida.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | no |  | `json` para JSON, `json2` para JSON con sangría, `url` o `urlencoded` para `encodeURIComponent()`, y `querify` para una cadena de consulta. |\n\nReturns: `String` El valor codificado.\n\nSin `type`, el helper escapa `<`, `>`, `&` y `\"`, y escribe una cadena vacía para `null` y `undefined`.\n\nExample: Codificación\n```js\nconsole.log(Tangular.render('{{ value | encode }}', { value: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render(\"{{ value | encode('json') }}\", { value: { a: 1 } })); // {\"a\":1}\nconsole.log(Tangular.render(\"{{ value | encode('url') }}\", { value: 'a b' })); // a%20b\nconsole.log(Tangular.render(\"{{ value | encode('querify') }}\", { value: { a: 1, b: 'x y' } })); // ?a=1&b=x%20y\n```\n\n### {{ value | format([format], [separator], [decimalSeparator]) }}\n\nType: `method`\n\nDa formato a un número o a una fecha.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | Los decimales de un número o el patrón de una fecha. |\n| `separator` | `String` | no |  | El separador de miles de un número. |\n| `decimalSeparator` | `String` | no |  | El separador decimal de un número. |\n\nReturns: `String` El valor con formato.\n\nPara un número, los argumentos son los de [format()](../number/), y un número sin `decimals` se escribe sin su parte decimal. Para un `Date`, el primer argumento es el patrón de [format()](../date/).\n\nUna cadena que contiene una fecha se convierte primero y usa `dd.MM.yyyy` de forma predeterminada, y una cadena que contiene un número se convierte en número. `null` y `undefined` escriben una cadena vacía.\n\nExample: Números\n```js\nconsole.log(Tangular.render('{{ value | format(2) }}', { value: 1234.5 })); // 1 234.50\nconsole.log(Tangular.render(\"{{ value | format(2, ',', '.') }}\", { value: 1234.5 })); // 1,234.50\nconsole.log(Tangular.render('{{ value | format }}', { value: 1234.5 })); // 1 234\n```\n\nExample: Fechas\n```js\nvar date = new Date(2026, 10, 8, 15, 4);\nconsole.log(Tangular.render(\"{{ value | format('dd.MM.yyyy HH:mm') }}\", { value: date })); // 08.11.2026 15:04\nconsole.log(Tangular.render('{{ value | format }}', { value: '2026-11-08' })); // 08.11.2026\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nSelecciona el texto que corresponde a un número.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String` | yes |  | El texto para 0. |\n| `one` | `String` | yes |  | El texto para 1. |\n| `few` | `String` | yes |  | El texto para los números del 2 al 4. |\n| `other` | `String` | yes |  | El texto para los demás números. |\n\nReturns: `String` El texto seleccionado.\n\nLos argumentos son los de [pluralize()](../number/). Una cadena numérica se convierte en número, y un valor vacío cuenta como `0`.\n\nExample: Contar elementos\n```js\nvar template = \"{{ count | pluralize('no items', '# item', '# items', '# items') }}\";\nconsole.log(Tangular.render(template, { count: 3 })); // 3 items\nconsole.log(Tangular.render(template, { count: 1 })); // 1 item\nconsole.log(Tangular.render(template, { count: null })); // no items\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nEscribe un valor sin codificar.\n\nReturns: `Object` El valor sin cambios.\n\nÚsalo solo con contenido que sea seguro insertar como HTML.\n\nExample: Escribir HTML\n```js\nconsole.log(Tangular.render('{{ value | raw }}', { value: '<b>Hi</b>' })); // <b>Hi</b>\nconsole.log(Tangular.render('{{ value }}', { value: '<b>Hi</b>' })); // &lt;b&gt;Hi&lt;/b&gt;\n```\n","entries":[{"type":"method","name":"cl","signature":"{{ id | cl(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clcolor","signature":"{{ id | clcolor(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clicon","signature":"{{ id | clicon(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"currency","signature":"{{ value | currency([name]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [separator], [decimalSeparator]) }}","since":"","deprecated":false},{"type":"method","name":"pluralize","signature":"{{ value | pluralize(zero, one, few, other) }}","since":"","deprecated":false},{"type":"method","name":"raw","signature":"{{ value | raw }}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYtA8o61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/tangular-helpers/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Helpers Tangular","summary":"Les helpers disponibles dans chaque modèle Tangular pour encoder, formater et lire les listes de codes.","markdown":"---\ntitle: Helpers Tangular\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Helpers Tangular\n\n> Les helpers disponibles dans chaque modèle Tangular pour encoder, formater et lire les listes de codes.\n\nUn helper suit la valeur dans un modèle, comme dans `{{ price | format(2) }}`, et les helpers peuvent être enchaînés. Une valeur sans helper est encodée avec `encode`. Pour écrire des modèles et enregistrer des helpers personnalisés, consulte [Modèles avec Tangular](../../guides/tangular/).\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nÉcrit un champ d'un élément d'une liste de codes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la liste de codes. |\n| `key` | `String` | no | `name` | Le champ à écrire. |\n\nReturns: `String` La valeur du champ.\n\nLa liste de codes est le tableau de `DEF.cl[name]`, et l'élément est trouvé par son `id`. Quand rien n'est trouvé, le helper écrit `DEF.empty`, ou une chaîne vide si `key` est défini.\n\nExample: Lire une liste de codes\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', code: 'R' }];\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 2 })); // Red\nconsole.log(Tangular.render(\"{{ id | cl('colors', 'code') }}\", { id: 2 })); // R\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 9 })); // ---\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nÉcrit un élément d'une liste de codes sous forme de libellé coloré.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la liste de codes. |\n| `key` | `String` | no | `name` | Le champ à écrire. |\n\nReturns: `String` Le HTML du libellé.\n\nLe helper écrit un `<span class=\"ui-clcolor\">` avec la couleur de l'élément en arrière-plan, l'icône de l'élément et le champ. Il écrit une chaîne vide quand l'élément est introuvable. La sortie n'est pas encodée.\n\nExample: Un libellé coloré\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clcolor('colors') }}\", { id: 2 })); // <span class=\"ui-clcolor\" style=\"background:#f00\"><i class=\"ti ti-circle mr5\"></i>Red</span>\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nÉcrit un élément d'une liste de codes avec son icône.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la liste de codes. |\n| `key` | `String` | no | `name` | Le champ à écrire. |\n\nReturns: `String` Le HTML de l'élément.\n\nL'icône prend la couleur de l'élément. Un élément sans icône écrit seulement le champ, et un élément introuvable écrit une chaîne vide. La sortie n'est pas encodée.\n\nExample: Un élément avec une icône\n```js\nDEF.cl.colors = [{ id: 1, name: 'Plain' }, { id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 2 })); // <i class=\"ti ti-circle mr5\" style=\"color:#f00\"></i>Red\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 1 })); // Plain\n```\n\n### {{ value | currency([name]) }}\n\nType: `method`\n\nFormate un nombre ou une chaîne numérique avec une devise enregistrée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | Le nom de la devise. |\n\nReturns: `String` Le prix formaté.\n\nLe helper utilise [currency()](../number/). Une valeur d'un autre type écrit une chaîne vide.\n\nExample: Prix\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: 5 })); // 5.00 EUR\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: '7.5' })); // 7.50 EUR\n```\n\n### {{ value | def([text], [raw]) }}\n\nType: `method`\n\nUn alias du helper `empty`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Le texte d'une valeur vide. |\n| `raw` | `Boolean` | no | `false` | `true` écrit la valeur sans l'encoder. |\n\nReturns: `String` La valeur ou le texte.\n\nExample: Texte par défaut\n```js\nconsole.log(Tangular.render(\"{{ name | def('n/a') }}\", { name: null })); // n/a\n```\n\n### {{ value | empty([text], [raw]) }}\n\nType: `method`\n\nÉcrit un texte par défaut pour une valeur vide.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Le texte d'une valeur vide. |\n| `raw` | `Boolean` | no | `false` | `true` écrit la valeur sans l'encoder. |\n\nReturns: `String` La valeur ou le texte.\n\nToute valeur falsy est vide, y compris `0`. Les autres valeurs sont encodées sauf si `raw` vaut `true`. Passer `true` comme premier argument active aussi `raw`.\n\nExample: Valeurs vides\n```js\nconsole.log(Tangular.render('{{ name | empty }}', { name: '' })); // ---\nconsole.log(Tangular.render(\"{{ name | empty('n/a') }}\", { name: '' })); // n/a\nconsole.log(Tangular.render('{{ name | empty }}', { name: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render('{{ name | empty(true) }}', { name: '<b>' })); // <b>\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nEncode une valeur pour la sortie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | no |  | `json` pour du JSON, `json2` pour du JSON indenté, `url` ou `urlencoded` pour `encodeURIComponent()`, et `querify` pour une chaîne de requête. |\n\nReturns: `String` La valeur encodée.\n\nSans `type`, le helper échappe `<`, `>`, `&` et `\"`, et écrit une chaîne vide pour `null` et `undefined`.\n\nExample: Encodage\n```js\nconsole.log(Tangular.render('{{ value | encode }}', { value: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render(\"{{ value | encode('json') }}\", { value: { a: 1 } })); // {\"a\":1}\nconsole.log(Tangular.render(\"{{ value | encode('url') }}\", { value: 'a b' })); // a%20b\nconsole.log(Tangular.render(\"{{ value | encode('querify') }}\", { value: { a: 1, b: 'x y' } })); // ?a=1&b=x%20y\n```\n\n### {{ value | format([format], [separator], [decimalSeparator]) }}\n\nType: `method`\n\nFormate un nombre ou une date.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | Le nombre de décimales d'un nombre, ou la disposition d'une date. |\n| `separator` | `String` | no |  | Le séparateur de milliers d'un nombre. |\n| `decimalSeparator` | `String` | no |  | Le séparateur décimal d'un nombre. |\n\nReturns: `String` La valeur formatée.\n\nPour un nombre, les arguments sont ceux de [format()](../number/), et un nombre sans `decimals` est écrit sans sa partie décimale. Pour une `Date`, le premier argument est la disposition de [format()](../date/).\n\nUne chaîne contenant une date est d'abord convertie et utilise `dd.MM.yyyy` par défaut, et une chaîne contenant un nombre est convertie en nombre. `null` et `undefined` écrivent une chaîne vide.\n\nExample: Nombres\n```js\nconsole.log(Tangular.render('{{ value | format(2) }}', { value: 1234.5 })); // 1 234.50\nconsole.log(Tangular.render(\"{{ value | format(2, ',', '.') }}\", { value: 1234.5 })); // 1,234.50\nconsole.log(Tangular.render('{{ value | format }}', { value: 1234.5 })); // 1 234\n```\n\nExample: Dates\n```js\nvar date = new Date(2026, 10, 8, 15, 4);\nconsole.log(Tangular.render(\"{{ value | format('dd.MM.yyyy HH:mm') }}\", { value: date })); // 08.11.2026 15:04\nconsole.log(Tangular.render('{{ value | format }}', { value: '2026-11-08' })); // 08.11.2026\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nSélectionne le texte qui correspond à un nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String` | yes |  | Le texte pour 0. |\n| `one` | `String` | yes |  | Le texte pour 1. |\n| `few` | `String` | yes |  | Le texte pour les nombres de 2 à 4. |\n| `other` | `String` | yes |  | Le texte pour les autres nombres. |\n\nReturns: `String` Le texte sélectionné.\n\nLes arguments sont ceux de [pluralize()](../number/). Une chaîne numérique est convertie en nombre, et une valeur vide compte pour `0`.\n\nExample: Compter des éléments\n```js\nvar template = \"{{ count | pluralize('no items', '# item', '# items', '# items') }}\";\nconsole.log(Tangular.render(template, { count: 3 })); // 3 items\nconsole.log(Tangular.render(template, { count: 1 })); // 1 item\nconsole.log(Tangular.render(template, { count: null })); // no items\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nÉcrit une valeur sans l'encoder.\n\nReturns: `Object` La valeur inchangée.\n\nUtilise-le uniquement pour du contenu qu'il est sûr d'insérer en HTML.\n\nExample: Écrire du HTML\n```js\nconsole.log(Tangular.render('{{ value | raw }}', { value: '<b>Hi</b>' })); // <b>Hi</b>\nconsole.log(Tangular.render('{{ value }}', { value: '<b>Hi</b>' })); // &lt;b&gt;Hi&lt;/b&gt;\n```\n","entries":[{"type":"method","name":"cl","signature":"{{ id | cl(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clcolor","signature":"{{ id | clcolor(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clicon","signature":"{{ id | clicon(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"currency","signature":"{{ value | currency([name]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [separator], [decimalSeparator]) }}","since":"","deprecated":false},{"type":"method","name":"pluralize","signature":"{{ value | pluralize(zero, one, few, other) }}","since":"","deprecated":false},{"type":"method","name":"raw","signature":"{{ value | raw }}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYtA8o61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/tangular-helpers/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Helper di Tangular","summary":"Gli helper disponibili in ogni template Tangular per codificare, formattare e leggere gli elenchi di codici.","markdown":"---\ntitle: Helper di Tangular\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Helper di Tangular\n\n> Gli helper disponibili in ogni template Tangular per codificare, formattare e leggere gli elenchi di codici.\n\nUn helper segue il valore in un template, come in `{{ price | format(2) }}`, e gli helper possono essere concatenati. Un valore senza helper viene codificato con `encode`. Per scrivere template e registrare helper personalizzati, vedi [Template con Tangular](../../guides/tangular/).\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nScrive un campo di un elemento di un elenco di codici.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'elenco di codici. |\n| `key` | `String` | no | `name` | Il campo da scrivere. |\n\nReturns: `String` Il valore del campo.\n\nL'elenco di codici è l'array in `DEF.cl[name]` e l'elemento viene trovato tramite il suo `id`. Quando non viene trovato nulla, l'helper scrive `DEF.empty`, oppure una stringa vuota quando `key` è impostato.\n\nExample: Leggere un elenco di codici\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', code: 'R' }];\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 2 })); // Red\nconsole.log(Tangular.render(\"{{ id | cl('colors', 'code') }}\", { id: 2 })); // R\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 9 })); // ---\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nScrive un elemento di un elenco di codici come etichetta colorata.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'elenco di codici. |\n| `key` | `String` | no | `name` | Il campo da scrivere. |\n\nReturns: `String` L'HTML dell'etichetta.\n\nL'helper scrive uno `<span class=\"ui-clcolor\">` con il colore dell'elemento come sfondo, l'icona dell'elemento e il campo. Scrive una stringa vuota quando l'elemento non viene trovato. L'output non viene codificato.\n\nExample: Un'etichetta colorata\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clcolor('colors') }}\", { id: 2 })); // <span class=\"ui-clcolor\" style=\"background:#f00\"><i class=\"ti ti-circle mr5\"></i>Red</span>\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nScrive un elemento di un elenco di codici con la sua icona.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'elenco di codici. |\n| `key` | `String` | no | `name` | Il campo da scrivere. |\n\nReturns: `String` L'HTML dell'elemento.\n\nL'icona assume il colore dell'elemento. Un elemento senza icona scrive solo il campo, e un elemento non trovato scrive una stringa vuota. L'output non viene codificato.\n\nExample: Un elemento con un'icona\n```js\nDEF.cl.colors = [{ id: 1, name: 'Plain' }, { id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 2 })); // <i class=\"ti ti-circle mr5\" style=\"color:#f00\"></i>Red\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 1 })); // Plain\n```\n\n### {{ value | currency([name]) }}\n\nType: `method`\n\nFormatta un numero o una stringa numerica con una valuta registrata.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | Il nome della valuta. |\n\nReturns: `String` Il prezzo formattato.\n\nL'helper usa [currency()](../number/). Un valore di un altro tipo scrive una stringa vuota.\n\nExample: Prezzi\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: 5 })); // 5.00 EUR\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: '7.5' })); // 7.50 EUR\n```\n\n### {{ value | def([text], [raw]) }}\n\nType: `method`\n\nUn alias dell'helper `empty`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Il testo per un valore vuoto. |\n| `raw` | `Boolean` | no | `false` | `true` scrive il valore senza codificarlo. |\n\nReturns: `String` Il valore o il testo.\n\nExample: Testo predefinito\n```js\nconsole.log(Tangular.render(\"{{ name | def('n/a') }}\", { name: null })); // n/a\n```\n\n### {{ value | empty([text], [raw]) }}\n\nType: `method`\n\nScrive un testo predefinito per un valore vuoto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Il testo per un valore vuoto. |\n| `raw` | `Boolean` | no | `false` | `true` scrive il valore senza codificarlo. |\n\nReturns: `String` Il valore o il testo.\n\nOgni valore falsy è considerato vuoto, compreso `0`. Gli altri valori vengono codificati a meno che `raw` non sia `true`. Passare `true` come primo argomento attiva anche `raw`.\n\nExample: Valori vuoti\n```js\nconsole.log(Tangular.render('{{ name | empty }}', { name: '' })); // ---\nconsole.log(Tangular.render(\"{{ name | empty('n/a') }}\", { name: '' })); // n/a\nconsole.log(Tangular.render('{{ name | empty }}', { name: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render('{{ name | empty(true) }}', { name: '<b>' })); // <b>\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nCodifica un valore per l'output.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | no |  | `json` per JSON, `json2` per JSON indentato, `url` o `urlencoded` per `encodeURIComponent()` e `querify` per una stringa di query. |\n\nReturns: `String` Il valore codificato.\n\nSenza `type`, l'helper esegue l'escape di `<`, `>`, `&` e `\"`, e scrive una stringa vuota per `null` e `undefined`.\n\nExample: Codifica\n```js\nconsole.log(Tangular.render('{{ value | encode }}', { value: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render(\"{{ value | encode('json') }}\", { value: { a: 1 } })); // {\"a\":1}\nconsole.log(Tangular.render(\"{{ value | encode('url') }}\", { value: 'a b' })); // a%20b\nconsole.log(Tangular.render(\"{{ value | encode('querify') }}\", { value: { a: 1, b: 'x y' } })); // ?a=1&b=x%20y\n```\n\n### {{ value | format([format], [separator], [decimalSeparator]) }}\n\nType: `method`\n\nFormatta un numero o una data.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | Le cifre decimali per un numero, oppure il layout per una data. |\n| `separator` | `String` | no |  | Il separatore delle migliaia di un numero. |\n| `decimalSeparator` | `String` | no |  | Il separatore decimale di un numero. |\n\nReturns: `String` Il valore formattato.\n\nPer un numero, gli argomenti sono quelli di [format()](../number/), e un numero senza `decimals` viene scritto senza la parte decimale. Per un `Date`, il primo argomento è il layout di [format()](../date/).\n\nUna stringa che contiene una data viene prima convertita e usa `dd.MM.yyyy` per impostazione predefinita, mentre una stringa che contiene un numero viene convertita in numero. `null` e `undefined` scrivono una stringa vuota.\n\nExample: Numeri\n```js\nconsole.log(Tangular.render('{{ value | format(2) }}', { value: 1234.5 })); // 1 234.50\nconsole.log(Tangular.render(\"{{ value | format(2, ',', '.') }}\", { value: 1234.5 })); // 1,234.50\nconsole.log(Tangular.render('{{ value | format }}', { value: 1234.5 })); // 1 234\n```\n\nExample: Date\n```js\nvar date = new Date(2026, 10, 8, 15, 4);\nconsole.log(Tangular.render(\"{{ value | format('dd.MM.yyyy HH:mm') }}\", { value: date })); // 08.11.2026 15:04\nconsole.log(Tangular.render('{{ value | format }}', { value: '2026-11-08' })); // 08.11.2026\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nSeleziona il testo che corrisponde a un numero.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String` | yes |  | Il testo per 0. |\n| `one` | `String` | yes |  | Il testo per 1. |\n| `few` | `String` | yes |  | Il testo per i numeri da 2 a 4. |\n| `other` | `String` | yes |  | Il testo per gli altri numeri. |\n\nReturns: `String` Il testo selezionato.\n\nGli argomenti sono quelli di [pluralize()](../number/). Una stringa numerica viene convertita in numero, e un valore vuoto conta come `0`.\n\nExample: Contare gli elementi\n```js\nvar template = \"{{ count | pluralize('no items', '# item', '# items', '# items') }}\";\nconsole.log(Tangular.render(template, { count: 3 })); // 3 items\nconsole.log(Tangular.render(template, { count: 1 })); // 1 item\nconsole.log(Tangular.render(template, { count: null })); // no items\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nScrive un valore senza codificarlo.\n\nReturns: `Object` Il valore invariato.\n\nUsalo solo per contenuti che possono essere inseriti come HTML in sicurezza.\n\nExample: Scrivere HTML\n```js\nconsole.log(Tangular.render('{{ value | raw }}', { value: '<b>Hi</b>' })); // <b>Hi</b>\nconsole.log(Tangular.render('{{ value }}', { value: '<b>Hi</b>' })); // &lt;b&gt;Hi&lt;/b&gt;\n```\n","entries":[{"type":"method","name":"cl","signature":"{{ id | cl(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clcolor","signature":"{{ id | clcolor(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clicon","signature":"{{ id | clicon(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"currency","signature":"{{ value | currency([name]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [separator], [decimalSeparator]) }}","since":"","deprecated":false},{"type":"method","name":"pluralize","signature":"{{ value | pluralize(zero, one, few, other) }}","since":"","deprecated":false},{"type":"method","name":"raw","signature":"{{ value | raw }}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYtA8o61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/tangular-helpers/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Helpery Tangularu","summary":"Helpery dostupné v každej šablóne Tangular na kódovanie, formátovanie a čítanie zoznamov kódov.","markdown":"---\ntitle: Helpery Tangularu\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/tangular-helpers/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Helpery Tangularu\n\n> Helpery dostupné v každej šablóne Tangular na kódovanie, formátovanie a čítanie zoznamov kódov.\n\nHelper nasleduje v šablóne za hodnotou, napríklad `{{ price | format(2) }}`, a helpery možno reťaziť. Hodnota bez helpera sa zakóduje pomocou `encode`. Ako písať šablóny a registrovať vlastné helpery, nájdeš v časti [Šablóny s Tangularom](../../guides/tangular/).\n\n## API\n\n### {{ id | cl(name, [key]) }}\n\nType: `method`\n\nZapíše pole položky zo zoznamu kódov.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov zoznamu kódov. |\n| `key` | `String` | no | `name` | Pole, ktoré sa má zapísať. |\n\nReturns: `String` Hodnota poľa.\n\nZoznam kódov je pole v `DEF.cl[name]` a položka sa hľadá podľa `id`. Keď sa nič nenájde, helper zapíše `DEF.empty`, alebo prázdny reťazec, ak je nastavený `key`.\n\nExample: Čítanie zoznamu kódov\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', code: 'R' }];\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 2 })); // Red\nconsole.log(Tangular.render(\"{{ id | cl('colors', 'code') }}\", { id: 2 })); // R\nconsole.log(Tangular.render(\"{{ id | cl('colors') }}\", { id: 9 })); // ---\n```\n\n### {{ id | clcolor(name, [key]) }}\n\nType: `method`\n\nZapíše položku zoznamu kódov ako farebný štítok.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov zoznamu kódov. |\n| `key` | `String` | no | `name` | Pole, ktoré sa má zapísať. |\n\nReturns: `String` HTML štítka.\n\nHelper zapíše `<span class=\"ui-clcolor\">` s farbou položky ako pozadím, ikonou položky a poľom. Keď sa položka nenájde, zapíše prázdny reťazec. Výstup sa nekóduje.\n\nExample: Farebný štítok\n```js\nDEF.cl.colors = [{ id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clcolor('colors') }}\", { id: 2 })); // <span class=\"ui-clcolor\" style=\"background:#f00\"><i class=\"ti ti-circle mr5\"></i>Red</span>\n```\n\n### {{ id | clicon(name, [key]) }}\n\nType: `method`\n\nZapíše položku zoznamu kódov s jej ikonou.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov zoznamu kódov. |\n| `key` | `String` | no | `name` | Pole, ktoré sa má zapísať. |\n\nReturns: `String` HTML položky.\n\nIkona preberá farbu položky. Položka bez ikony zapíše iba pole a nenájdená položka zapíše prázdny reťazec. Výstup sa nekóduje.\n\nExample: Položka s ikonou\n```js\nDEF.cl.colors = [{ id: 1, name: 'Plain' }, { id: 2, name: 'Red', icon: 'ti ti-circle', color: '#f00' }];\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 2 })); // <i class=\"ti ti-circle mr5\" style=\"color:#f00\"></i>Red\nconsole.log(Tangular.render(\"{{ id | clicon('colors') }}\", { id: 1 })); // Plain\n```\n\n### {{ value | currency([name]) }}\n\nType: `method`\n\nNaformátuje číslo alebo číselný reťazec pomocou zaregistrovanej meny.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | Názov meny. |\n\nReturns: `String` Naformátovaná cena.\n\nHelper používa [currency()](../number/). Hodnota iného typu zapíše prázdny reťazec.\n\nExample: Ceny\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: 5 })); // 5.00 EUR\nconsole.log(Tangular.render(\"{{ price | currency('eur') }}\", { price: '7.5' })); // 7.50 EUR\n```\n\n### {{ value | def([text], [raw]) }}\n\nType: `method`\n\nAlias helpera `empty`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Text pre prázdnu hodnotu. |\n| `raw` | `Boolean` | no | `false` | `true` zapíše hodnotu bez kódovania. |\n\nReturns: `String` Hodnota alebo text.\n\nExample: Predvolený text\n```js\nconsole.log(Tangular.render(\"{{ name | def('n/a') }}\", { name: null })); // n/a\n```\n\n### {{ value | empty([text], [raw]) }}\n\nType: `method`\n\nPre prázdnu hodnotu zapíše predvolený text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `text` | `String` | no | `DEF.empty` | Text pre prázdnu hodnotu. |\n| `raw` | `Boolean` | no | `false` | `true` zapíše hodnotu bez kódovania. |\n\nReturns: `String` Hodnota alebo text.\n\nPrázdna je každá nepravdivá hodnota vrátane `0`. Ostatné hodnoty sa kódujú, pokiaľ `raw` nie je `true`. Odovzdanie `true` ako prvého argumentu tiež zapne `raw`.\n\nExample: Prázdne hodnoty\n```js\nconsole.log(Tangular.render('{{ name | empty }}', { name: '' })); // ---\nconsole.log(Tangular.render(\"{{ name | empty('n/a') }}\", { name: '' })); // n/a\nconsole.log(Tangular.render('{{ name | empty }}', { name: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render('{{ name | empty(true) }}', { name: '<b>' })); // <b>\n```\n\n### {{ value | encode([type]) }}\n\nType: `method`\n\nZakóduje hodnotu pre výstup.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `String` | no |  | `json` pre JSON, `json2` pre odsadený JSON, `url` alebo `urlencoded` pre `encodeURIComponent()` a `querify` pre reťazec dotazu. |\n\nReturns: `String` Zakódovaná hodnota.\n\nBez `type` helper escapuje `<`, `>`, `&` a `\"` a pre `null` a `undefined` zapíše prázdny reťazec.\n\nExample: Kódovanie\n```js\nconsole.log(Tangular.render('{{ value | encode }}', { value: '<b>' })); // &lt;b&gt;\nconsole.log(Tangular.render(\"{{ value | encode('json') }}\", { value: { a: 1 } })); // {\"a\":1}\nconsole.log(Tangular.render(\"{{ value | encode('url') }}\", { value: 'a b' })); // a%20b\nconsole.log(Tangular.render(\"{{ value | encode('querify') }}\", { value: { a: 1, b: 'x y' } })); // ?a=1&b=x%20y\n```\n\n### {{ value | format([format], [separator], [decimalSeparator]) }}\n\nType: `method`\n\nNaformátuje číslo alebo dátum.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `Number or String` | no |  | Počet desatinných miest pre číslo alebo rozloženie pre dátum. |\n| `separator` | `String` | no |  | Oddeľovač tisícov čísla. |\n| `decimalSeparator` | `String` | no |  | Desatinný oddeľovač čísla. |\n\nReturns: `String` Naformátovaná hodnota.\n\nPri čísle sú argumenty rovnaké ako pri [format()](../number/) a číslo bez `decimals` sa zapíše bez desatinnej časti. Pri `Date` je prvým argumentom rozloženie z [format()](../date/).\n\nReťazec obsahujúci dátum sa najprv prevedie a predvolene používa `dd.MM.yyyy`, reťazec obsahujúci číslo sa prevedie na číslo. `null` a `undefined` zapíšu prázdny reťazec.\n\nExample: Čísla\n```js\nconsole.log(Tangular.render('{{ value | format(2) }}', { value: 1234.5 })); // 1 234.50\nconsole.log(Tangular.render(\"{{ value | format(2, ',', '.') }}\", { value: 1234.5 })); // 1,234.50\nconsole.log(Tangular.render('{{ value | format }}', { value: 1234.5 })); // 1 234\n```\n\nExample: Dátumy\n```js\nvar date = new Date(2026, 10, 8, 15, 4);\nconsole.log(Tangular.render(\"{{ value | format('dd.MM.yyyy HH:mm') }}\", { value: date })); // 08.11.2026 15:04\nconsole.log(Tangular.render('{{ value | format }}', { value: '2026-11-08' })); // 08.11.2026\n```\n\n### {{ value | pluralize(zero, one, few, other) }}\n\nType: `method`\n\nVyberie text zodpovedajúci číslu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String` | yes |  | Text pre 0. |\n| `one` | `String` | yes |  | Text pre 1. |\n| `few` | `String` | yes |  | Text pre čísla od 2 do 4. |\n| `other` | `String` | yes |  | Text pre ostatné čísla. |\n\nReturns: `String` Vybraný text.\n\nArgumenty sú rovnaké ako pri [pluralize()](../number/). Číselný reťazec sa prevedie na číslo a prázdna hodnota sa počíta ako `0`.\n\nExample: Počítanie položiek\n```js\nvar template = \"{{ count | pluralize('no items', '# item', '# items', '# items') }}\";\nconsole.log(Tangular.render(template, { count: 3 })); // 3 items\nconsole.log(Tangular.render(template, { count: 1 })); // 1 item\nconsole.log(Tangular.render(template, { count: null })); // no items\n```\n\n### {{ value | raw }}\n\nType: `method`\n\nZapíše hodnotu bez kódovania.\n\nReturns: `Object` Nezmenená hodnota.\n\nPoužívaj ho iba pre obsah, ktorý je bezpečné vložiť ako HTML.\n\nExample: Zápis HTML\n```js\nconsole.log(Tangular.render('{{ value | raw }}', { value: '<b>Hi</b>' })); // <b>Hi</b>\nconsole.log(Tangular.render('{{ value }}', { value: '<b>Hi</b>' })); // &lt;b&gt;Hi&lt;/b&gt;\n```\n","entries":[{"type":"method","name":"cl","signature":"{{ id | cl(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clcolor","signature":"{{ id | clcolor(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"clicon","signature":"{{ id | clicon(name, [key]) }}","since":"","deprecated":false},{"type":"method","name":"currency","signature":"{{ value | currency([name]) }}","since":"","deprecated":false},{"type":"method","name":"def","signature":"{{ value | def([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"empty","signature":"{{ value | empty([text], [raw]) }}","since":"","deprecated":false},{"type":"method","name":"encode","signature":"{{ value | encode([type]) }}","since":"","deprecated":false},{"type":"method","name":"format","signature":"{{ value | format([format], [separator], [decimalSeparator]) }}","since":"","deprecated":false},{"type":"method","name":"pluralize","signature":"{{ value | pluralize(zero, one, few, other) }}","since":"","deprecated":false},{"type":"method","name":"raw","signature":"{{ value | raw }}","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JanH6T1cG61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/routing/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"Routing","summary":"The client-side routing API: ROUTE(), REDIRECT(), MIDDLEWARE(), the NAV object, and the route options and events.","markdown":"---\ntitle: Routing\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/routing/\nupdated: 2026-11-18T17:06:08.115Z\n---\n\n# Routing\n\n> The client-side routing API: ROUTE(), REDIRECT(), MIDDLEWARE(), the NAV object, and the route options and events.\n\nThese functions map URLs to functions in a single-page application, and `NAV` holds the current state of the navigation. For an introduction with complete examples, read [Routing](../../guides/routing/).\n\n## API\n\n### ROUTE(url, callback, [middleware], [init])\n\nType: `method`\n\nRegisters a function for a URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The URL of the route. It can contain dynamic segments such as `{id}` and environment variables such as `[name]`. The value of `DEF.root` is added in front of it. |\n| `callback` | `Function` | yes |  | The function to run. It receives the values of the dynamic segments. |\n| `middleware` | `String or Array` | no |  | A comma-separated string or an array of [middleware names](#middleware-name), [roles](#role), [code lists](#code-list) and an [options object](#options-object). The options object is accepted only in an array. |\n| `init` | `Function` | no |  | A function that runs once, on the first visit, ahead of the middleware. It receives `next`, which must be called to continue. |\n\nReturns: `Object` The `NAV` object, so calls can be chained.\n\nThe route for the current URL runs when the application starts. Inside the callback, `this` is `NAV`, and the values of the [dynamic segments](#dynamic-segment) are the arguments.\n\nThe URL is compared in lowercase, so write fixed segments in lowercase. A missing trailing slash is added to the address. A static route wins over a dynamic one with the same number of segments, and registering the same URL again replaces the route.\n\nThe arguments can also be passed in these orders:\n\n- `ROUTE(url, middleware, callback, [init])`, with `middleware` as an array\n- `ROUTE(url, callback, init, [middleware])`\n\nWhen the current URL is in the 404 state, a route registered for it runs immediately.\n\nExample: Static and dynamic routes\n```js\nROUTE('/products/new/', function() {\n\tconsole.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n\tconsole.log('detail', id, this.url);\n});\n\nREDIRECT('/products/new/');\nREDIRECT('/products/AB-15');\n\n// Output:\n// form\n// detail AB-15 /products/AB-15/\n```\n\nExample: Prepare a route once\n```js\nROUTE('/reports/', function() {\n\tconsole.log('reports');\n}, function(next) {\n\tconsole.log('prepare once');\n\tnext();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n\n// Output:\n// prepare once\n// reports\n// reports\n```\n\n### REDIRECT([url])\n\nType: `method`\n\nNavigates to a URL without reloading the page.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | The target URL with an optional query string. It can contain environment variables such as `[name]`, and the value of `DEF.root` is added in front of it. The default value is the current URL. |\n\nWithout a URL, the current route runs again. `REDIRECT('./')` does the same, `REDIRECT('../')` goes one segment up, and `REDIRECT('../../')` goes two segments up. A query string can follow the dots, for example `REDIRECT('../?page=2')`.\n\nA word starting with `@` at the end of the URL is a [custom flag](#custom-flag).\n\nExample: Navigate\n```js\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id, NAV.query.tab);\n});\n\nREDIRECT('/users/15/?tab=orders');\n\n// Output:\n// user 15 orders\n```\n\nExample: Go one level up\n```js\nROUTE('/users/', function() {\n\tconsole.log('list');\n});\n\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id);\n});\n\nREDIRECT('/users/15/');\nREDIRECT('../');\nconsole.log(NAV.url);\n\n// Output:\n// user 15\n// list\n// /users/\n```\n\n### MIDDLEWARE(name, callback)\n\nType: `method`\n\nRegisters a named middleware, or runs a list of middleware.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String or Array` | yes |  | The name of the middleware, or an array of names to run. |\n| `callback` | `Function` | yes |  | The middleware. With an array of names, the function to call at the end. |\n\nReturns: `Object` The `NAV` object, so calls can be chained.\n\nA middleware runs ahead of the route callback and decides if the route continues. Inside the callback, `this` is `NAV`. The callback receives:\n\n| Argument | Type | Description |\n| --- | --- | --- |\n| `next` | Function | `next()` continues. `next(false)` and `next(new Error())` stop the route. |\n| `options` | Object | The [options object](#options-object) of the route. |\n| `roles` | Array | The [roles](#role) of the route. |\n| `route` | Object | The [route object](#route-object). |\n\nThe chain stops as well when the URL changes while a middleware is working.\n\nWith an array of names, `MIDDLEWARE(names, callback)` runs those middleware one after another and then calls `callback`. Each middleware receives only `next`, and unknown names are skipped.\n\nExample: Protect a route\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n\tconsole.log('auth', route.id);\n\tnext(user ? undefined : false);\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, 'auth');\n\nREDIRECT('/admin/');\n\nsetTimeout(function() {\n\tuser = { name: 'Ann' };\n\tREDIRECT('/admin/');\n}, 100);\n\n// Output:\n// auth /admin/\n// auth /admin/\n// admin page\n```\n\nExample: Run a list of middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nMIDDLEWARE(['first', 'second'], function() {\n\tconsole.log('done');\n});\n\n// Output:\n// first\n// second\n// done\n```\n\n### ROUTE('/items/{name}/', callback)\n\nType: `config`\n\nA dynamic segment of a route URL.\n\nA segment in curly brackets matches any value of that segment. The values are passed to the callback in order and are available in `NAV.params`. They keep their original case. The address must have the same number of segments as the route.\n\nExample: Read two segments\n```js\nROUTE('/items/{id}/{tab}/', function(id, tab) {\n\tconsole.log(id, tab, JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/AB-1/Photos/');\n\n// Output:\n// AB-1 Photos [\"AB-1\",\"Photos\"]\n```\n\n### ROUTE(url, callback, 'name')\n\nType: `config`\n\nRuns a registered middleware for the route.\n\nA plain name in the `middleware` argument of `ROUTE()` selects a middleware registered with [MIDDLEWARE()](#middleware). The middleware run in the listed order, and a name that is not registered is skipped.\n\nExample: Two middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders');\n}, 'first,second');\n\nREDIRECT('/orders/');\n\n// Output:\n// first\n// second\n// orders\n```\n\n### ROUTE(url, callback, ['name', '@role'])\n\nType: `config`\n\nAdds a role that middleware receive in the roles array.\n\nAn item starting with `@` is passed to every middleware of the route in the `roles` array, without the `@`. Roles have no effect of their own: the middleware decides what they mean.\n\nExample: Read the roles\n```js\nMIDDLEWARE('auth', function(next, options, roles) {\n\tconsole.log(roles.join());\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['auth', '@admin', '@editor']);\n\nREDIRECT('/admin/');\n\n// Output:\n// admin,editor\n// admin page\n```\n\n### ROUTE(url, callback, '#name')\n\nType: `config`\n\nLoads a code list ahead of the route callback.\n\nAn item starting with `#` loads the code list with that name through `CL()`, in its position in the middleware chain. See [Global functions](../globals/).\n\nExample: Load a code list\n```js\nCLINIT('countries', function(next) {\n\tconsole.log('loading countries');\n\tnext([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders', DEF.cl.countries.length);\n}, '#countries');\n\nREDIRECT('/orders/');\n\n// Output:\n// loading countries\n// orders 1\n```\n\n### ROUTE(url, callback, ['name', { key: value }])\n\nType: `config`\n\nPasses options to the middleware of the route.\n\nAn object in the middleware array is passed to every middleware of the route as `options`. It is also available in `options` of the [route object](#route-object).\n\nExample: Read the options\n```js\nMIDDLEWARE('layout', function(next, options) {\n\tconsole.log(options.title);\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['layout', { title: 'Administration' }]);\n\nREDIRECT('/admin/');\n\n// Output:\n// Administration\n// admin page\n```\n\n### REDIRECT('/url/ @name')\n\nType: `config`\n\nEmits a flag event when navigating.\n\nA word starting with `@` is removed from the URL, and the event `@flag name` is emitted ahead of the navigation. See [Events](../events/).\n\nExample: React to a flag\n```js\nON('@flag audit', function() {\n\tconsole.log('audit');\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// audit\n// /orders/\n```\n\n### NAV.routes[index]\n\nType: `type`\n\nDescribes one registered route.\n\nMiddleware receive this object as the `route` argument, and `NAV.routes` contains one for each route.\n\n| Property | Type | Description |\n| --- | --- | --- |\n| `id` | String | The URL of the route. |\n| `url` | Array | The segments of the URL. |\n| `fn` | Function | The route callback. |\n| `priority` | Number | The position in the matching order. A higher number is tried first. |\n| `params` | Array | The indexes of the dynamic segments. |\n| `middleware` | Array | The middleware names and code lists, or `null`. |\n| `init` | Function | The `init` function. It is `null` after it has run. |\n| `count` | Number | How many times the route has matched. |\n| `pending` | Boolean | `true` while the middleware or `init` are working. |\n| `options` | Object | The [options object](#options-object). |\n| `roles` | Array | The [roles](#role). |\n\nExample: Inspect a route\n```js\nROUTE('/items/{id}/', function() {}, ['auth', '@admin', { title: 'Items' }]);\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nvar route = NAV.routes[0];\nconsole.log(route.id, JSON.stringify(route.url), JSON.stringify(route.params));\nconsole.log(JSON.stringify(route.middleware), JSON.stringify(route.roles), route.options.title);\n\n// Output:\n// /items/{id}/ [\"items\",\"{id}\"] [1]\n// [\"auth\"] [\"admin\"] Items\n```\n\n### NAV.autosave()\n\nType: `method`\n\nSaves the history to the browser storage at each navigation.\n\nAfter this call, the history is stored the same way as with [NAV.save()](#nav-save) every time it changes. [NAV.load()](#nav-load) reads it back.\n\nExample: Keep the history\n```js\nNAV.autosave();\n\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.back()\n\nType: `method`\n\nGoes to the previous URL.\n\nReturns: `Object` The `NAV` object, so calls can be chained.\n\nWith an empty history, it goes to `/`.\n\nExample: Go back\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.url, NAV.next());\n\n// Output:\n// /a/ /b/\n```\n\n### NAV.clientside(selector)\n\nType: `method`\n\nTurns matching elements into client-side links.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | A jQuery selector of the links. |\n\nReturns: `Object` The `NAV` object, so calls can be chained.\n\nA click on a matching element navigates with `REDIRECT()`. The URL is read from `href`, `data-href` or `data-url`. The values `#` and `javascript:void(0)` are ignored. Elements added later work too.\n\nExample: Links\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<span class=\"link\" data-href=\"/contact/\">Contact</span>\n\n<script>\nNAV.clientside('.link');\n\nROUTE('/about/', function() {\n\tconsole.log('about');\n});\n\nROUTE('/contact/', function() {\n\tconsole.log('contact');\n});\n</script>\n\n<!-- Output:\nabout\ncontact\n-->\n```\n\n### NAV.custom()\n\nType: `method`\n\nKeeps the navigation inside the application.\n\nRoutes and `REDIRECT()` work as usual, and the address bar stays as it is. This suits an application embedded in another page. Call it at the start of the application.\n\nExample: Navigate inside the application\n```js\nNAV.custom();\n\nROUTE('/inbox/', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nREDIRECT('/inbox/');\n\n// Output:\n// inbox /inbox/\n```\n\n### NAV.forward()\n\nType: `method`\n\nGoes to the next URL after going back.\n\nReturns: `Object` The `NAV` object, so calls can be chained.\n\nWhen there is no next URL, it goes to `/`.\n\nExample: Go forward\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nNAV.forward();\nconsole.log(NAV.url);\n\n// Output:\n// /b/\n```\n\n### NAV.load()\n\nType: `method`\n\nRestores the history from the browser storage.\n\nIt reads what [NAV.save()](#nav-save) or [NAV.autosave()](#nav-autosave) stored. The next navigation does not add the current URL to the restored history.\n\nExample: Restore the history\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.location(url, [skiphistory])\n\nType: `method`\n\nRuns the route of a URL without changing the address bar.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The URL to process. |\n| `skiphistory` | `Boolean` | no | `false` | `true` does not add the current URL to the history. |\n\n`NAV` is updated, the events are emitted and the route runs, like in `REDIRECT()`. The address in the browser is not changed.\n\nExample: Process URLs\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.location('/a/');\nNAV.location('/b/');\nNAV.location('/c/', true);\n\nconsole.log(NAV.url, JSON.stringify(NAV.history));\n\n// Output:\n// a\n// /c/ [\"/a/\"]\n```\n\n### NAV.next()\n\nType: `method`\n\nReturns the URL that NAV.forward() opens.\n\nReturns: `String` The next URL, or `undefined` when there is none.\n\nExample: Read the next URL\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.next());\n\n// Output:\n// /b/\n```\n\n### NAV.path(url, [delimiter])\n\nType: `method`\n\nAdds the trailing delimiter to a URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The URL. |\n| `delimiter` | `String` | no | `'/'` | The character to add. |\n\nReturns: `String` The URL with the delimiter.\n\nA query string is kept after the delimiter. A URL starting with `#` is returned unchanged.\n\nExample: Normalize URLs\n```js\nconsole.log(NAV.path('/products'));\nconsole.log(NAV.path('/products?page=2'));\nconsole.log(NAV.path('#inbox'));\n\n// Output:\n// /products/\n// /products/?page=2\n// #inbox\n```\n\n### NAV.prev()\n\nType: `method`\n\nReturns the URL that NAV.back() opens.\n\nReturns: `String` The previous URL, or `undefined` when there is none.\n\nExample: Read the previous URL\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nconsole.log(NAV.prev());\n\n// Output:\n// /a/\n```\n\n### NAV.redirect([url])\n\nType: `method`\n\nThe same function as REDIRECT().\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | The target URL. The default value is the current URL. |\n\nSee [REDIRECT()](#redirect).\n\nExample: Navigate\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.redirect('/a/');\n\n// Output:\n// a\n```\n\n### NAV.refresh()\n\nType: `method`\n\nRuns the route of the current URL again.\n\nThe history does not change.\n\nExample: Run the route again\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.refresh();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// a\n// a\n// []\n```\n\n### NAV.reload()\n\nType: `method`\n\nThe same as NAV.refresh().\n\nSee [NAV.refresh()](#nav-refresh).\n\nExample: Run the route again\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.reload();\n\n// Output:\n// a\n// a\n```\n\n### NAV.remember(name, [value])\n\nType: `method`\n\nAdds a query parameter to every following REDIRECT().\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The name of the query parameter. |\n| `value` | `String` | no |  | The value, or `null` to stop. |\n\nWithout a value, the current value of the parameter in `NAV.query` is kept. The value `null` stops adding the parameter.\n\nExample: Keep a parameter\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\n// Output:\n// /list/?lang=de\n// /list/\n```\n\n### NAV.remove(url)\n\nType: `method`\n\nRemoves a route.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The URL used in `ROUTE()`. |\n\nReturns: `Object` The `NAV` object, so calls can be chained.\n\nExample: Remove a route\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.remove('/a/');\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n```\n\n### NAV.save()\n\nType: `method`\n\nStores the history in the browser storage once.\n\nThe previous and next URLs are written to `localStorage` under the key `DEF.localstorage + '.nav'`.\n\nExample: Store the history\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nvar data = JSON.parse(localStorage.getItem(DEF.localstorage + '.nav'));\nconsole.log(JSON.stringify(data.prev));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.status(code, [data])\n\nType: `method`\n\nEmits an event named after a code.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `Number or String` | yes |  | The name of the event. |\n| `data` | `Object` | no |  | The argument of the event. |\n\nReturns: `Object` The `NAV` object, so calls can be chained.\n\nThis gives an application one place to handle errors.\n\nExample: Report an error\n```js\nON('500', function(error) {\n\tconsole.log('failed:', error);\n});\n\nNAV.status(500, 'Database is down');\n\n// Output:\n// failed: Database is down\n```\n\n### NAV.hashtags\n\nType: `property`\n\nDrives the routes with the hash part of the URL.\n\nReturns: `Boolean` The default value is `false`.\n\nSet it to `true` at the start of the application. Write the routes with a leading `#`, and navigate with links or `location.hash`.\n\nExample: Routes on the hash\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nsetTimeout(function() {\n\tlocation.hash = '#inbox';\n}, 100);\n\n// Output:\n// inbox #inbox\n```\n\n### NAV.href\n\nType: `property`\n\nThe URL passed to the last navigation.\n\nReturns: `String` The URL with its query string.\n\nExample: Read the URL\n```js\nREDIRECT('/search/?q=lamp');\nconsole.log(NAV.href);\n\n// Output:\n// /search/?q=lamp\n```\n\n### NAV.history\n\nType: `property`\n\nThe previous URLs.\n\nReturns: `Array` An array of strings.\n\nThe items are paths without the query string. The last item is the most recent one.\n\nExample: List the previous URLs\n```js\nREDIRECT('/a/?page=2');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.is404\n\nType: `property`\n\nTells if no route matches the current URL.\n\nReturns: `Boolean` `true` when no route matches.\n\nExample: Check the state\n```js\nROUTE('/a/', function() {});\n\nREDIRECT('/missing/');\nconsole.log(NAV.is404);\n\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n// false\n```\n\n### NAV.isback\n\nType: `property`\n\nThe number of URLs to go back to.\n\nReturns: `Number` The number of previous URLs.\n\nIt is a path, so the markup can bind to it.\n\nExample: Count the previous URLs\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(NAV.isback);\n\n// Output:\n// 2\n```\n\n### NAV.isforward\n\nType: `property`\n\nThe number of URLs to go forward to.\n\nReturns: `Number` The number of next URLs.\n\nIt is a path, so the markup can bind to it.\n\nExample: Count the next URLs\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.isforward);\n\n// Output:\n// 1\n```\n\n### NAV.middlewares\n\nType: `property`\n\nThe registered middleware.\n\nReturns: `Object` The functions, with the middleware names as keys.\n\nExample: List the names\n```js\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nconsole.log(Object.keys(NAV.middlewares).join());\n\n// Output:\n// auth\n```\n\n### NAV.params\n\nType: `property`\n\nThe values of the dynamic segments of the current route.\n\nReturns: `Array` An array of strings.\n\nIt is a path, so the markup can bind to it.\n\nExample: Read the values\n```js\nROUTE('/items/{id}/{tab}/', function() {\n\tconsole.log(JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/15/photos/');\n\n// Output:\n// [\"15\",\"photos\"]\n```\n\n### NAV.query\n\nType: `property`\n\nThe parsed query string of the current URL.\n\nReturns: `Object` The parameters. All values are strings.\n\nThe names and values are decoded, and a `+` becomes a space. It is a path, so the markup can bind to it.\n\nExample: Read the query string\n```js\nREDIRECT('/search/?q=desk+lamp&page=2');\nconsole.log(JSON.stringify(NAV.query));\n\n// Output:\n// {\"q\":\"desk lamp\",\"page\":\"2\"}\n```\n\n### NAV.queryraw\n\nType: `property`\n\nThe query string as text.\n\nReturns: `String` The query string without the leading `?`.\n\nExample: Read the text\n```js\nREDIRECT('/search/?q=lamp&page=2');\nconsole.log(NAV.queryraw);\n\n// Output:\n// q=lamp&page=2\n```\n\n### NAV.routes\n\nType: `property`\n\nThe registered routes.\n\nReturns: `Array` An array of route objects.\n\nThe array is sorted in the matching order. Each item is a [route object](#route-object).\n\nExample: List the routes\n```js\nROUTE('/items/{id}/', function() {});\nROUTE('/items/new/', function() {});\n\nconsole.log(NAV.routes.map(route => route.id).join());\n\n// Output:\n// /items/new/,/items/{id}/\n```\n\n### NAV.ua\n\nType: `property`\n\nInformation about the browser.\n\nReturns: `Object` The object of `MAIN.ua`.\n\nIt is the same object as `MAIN.ua` and is available when the application has started. See [MAIN](../main/).\n\nExample: Compare with MAIN\n```js\nROUTE('/', function() {\n\tconsole.log(NAV.ua === MAIN.ua);\n});\n\n// Output:\n// true\n```\n\n### NAV.url\n\nType: `property`\n\nThe current path without the query string.\n\nReturns: `String` The path with a trailing slash.\n\nIt is a path, so the markup can bind to it with `<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>`.\n\nExample: Read the path\n```js\nREDIRECT('/search?q=lamp');\nconsole.log(NAV.url);\n\n// Output:\n// /search/\n```\n\n### ON('location', function(url) {})\n\nType: `event`\n\nEmitted when the URL changes, ahead of the route callback.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The path without the query string. |\n\nExample: Watch the navigation\n```js\nON('location', function(url) {\n\tconsole.log('location', url);\n});\n\nROUTE('/a/', function() {\n\tconsole.log('route');\n});\n\nREDIRECT('/a/?page=2');\n\n// Output:\n// location /a/\n// route\n```\n\n### ON('404', function() {})\n\nType: `event`\n\nEmitted when no route matches the URL.\n\nExample: Handle an unknown URL\n```js\nON('404', function() {\n\tconsole.log('not found', NAV.url);\n});\n\nREDIRECT('/missing/');\n\n// Output:\n// not found /missing/\n```\n\n### ON('route', function(url) {})\n\nType: `event`\n\nEmitted when a route is registered.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | The URL of the route. |\n\nExample: Watch the registration\n```js\nON('route', function(url) {\n\tconsole.log('registered', url);\n});\n\nROUTE('/a/', function() {});\n\n// Output:\n// registered /a/\n```\n","entries":[{"type":"method","name":"ROUTE()","signature":"ROUTE(url, callback, [middleware], [init])","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT([url])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, callback)","since":"","deprecated":false},{"type":"config","name":"{name}","signature":"ROUTE('/items/{name}/', callback)","since":"","deprecated":false},{"type":"config","name":"Middleware name","signature":"ROUTE(url, callback, 'name')","since":"","deprecated":false},{"type":"config","name":"@role","signature":"ROUTE(url, callback, ['name', '@role'])","since":"","deprecated":false},{"type":"config","name":"#codelist","signature":"ROUTE(url, callback, '#name')","since":"","deprecated":false},{"type":"config","name":"Options object","signature":"ROUTE(url, callback, ['name', { key: value }])","since":"","deprecated":false},{"type":"config","name":"@flag","signature":"REDIRECT('/url/ @name')","since":"","deprecated":false},{"type":"type","name":"Route object","signature":"NAV.routes[index]","since":"","deprecated":false},{"type":"method","name":"NAV.autosave()","signature":"NAV.autosave()","since":"","deprecated":false},{"type":"method","name":"NAV.back()","signature":"NAV.back()","since":"","deprecated":false},{"type":"method","name":"NAV.clientside()","signature":"NAV.clientside(selector)","since":"","deprecated":false},{"type":"method","name":"NAV.custom()","signature":"NAV.custom()","since":"","deprecated":false},{"type":"method","name":"NAV.forward()","signature":"NAV.forward()","since":"","deprecated":false},{"type":"method","name":"NAV.load()","signature":"NAV.load()","since":"","deprecated":false},{"type":"method","name":"NAV.location()","signature":"NAV.location(url, [skiphistory])","since":"","deprecated":false},{"type":"method","name":"NAV.next()","signature":"NAV.next()","since":"","deprecated":false},{"type":"method","name":"NAV.path()","signature":"NAV.path(url, [delimiter])","since":"","deprecated":false},{"type":"method","name":"NAV.prev()","signature":"NAV.prev()","since":"","deprecated":false},{"type":"method","name":"NAV.redirect()","signature":"NAV.redirect([url])","since":"","deprecated":false},{"type":"method","name":"NAV.refresh()","signature":"NAV.refresh()","since":"","deprecated":false},{"type":"method","name":"NAV.reload()","signature":"NAV.reload()","since":"","deprecated":false},{"type":"method","name":"NAV.remember()","signature":"NAV.remember(name, [value])","since":"","deprecated":false},{"type":"method","name":"NAV.remove()","signature":"NAV.remove(url)","since":"","deprecated":false},{"type":"method","name":"NAV.save()","signature":"NAV.save()","since":"","deprecated":false},{"type":"method","name":"NAV.status()","signature":"NAV.status(code, [data])","since":"","deprecated":false},{"type":"property","name":"NAV.hashtags","signature":"NAV.hashtags","since":"","deprecated":false},{"type":"property","name":"NAV.href","signature":"NAV.href","since":"","deprecated":false},{"type":"property","name":"NAV.history","signature":"NAV.history","since":"","deprecated":false},{"type":"property","name":"NAV.is404","signature":"NAV.is404","since":"","deprecated":false},{"type":"property","name":"NAV.isback","signature":"NAV.isback","since":"","deprecated":false},{"type":"property","name":"NAV.isforward","signature":"NAV.isforward","since":"","deprecated":false},{"type":"property","name":"NAV.middlewares","signature":"NAV.middlewares","since":"","deprecated":false},{"type":"property","name":"NAV.params","signature":"NAV.params","since":"","deprecated":false},{"type":"property","name":"NAV.query","signature":"NAV.query","since":"","deprecated":false},{"type":"property","name":"NAV.queryraw","signature":"NAV.queryraw","since":"","deprecated":false},{"type":"property","name":"NAV.routes","signature":"NAV.routes","since":"","deprecated":false},{"type":"property","name":"NAV.ua","signature":"NAV.ua","since":"","deprecated":false},{"type":"property","name":"NAV.url","signature":"NAV.url","since":"","deprecated":false},{"type":"event","name":"location","signature":"ON('location', function(url) {})","since":"","deprecated":false},{"type":"event","name":"404","signature":"ON('404', function() {})","since":"","deprecated":false},{"type":"event","name":"route","signature":"ON('route', function(url) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T17:06:08.115Z"}
{"id":"JanH6T1cG61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/routing/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"Routing","summary":"Die clientseitige Routing-API: ROUTE(), REDIRECT(), MIDDLEWARE(), das Objekt NAV sowie die Optionen und Ereignisse von Routen.","markdown":"---\ntitle: Routing\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/routing/\nupdated: 2026-11-18T17:06:08.115Z\n---\n\n# Routing\n\n> Die clientseitige Routing-API: ROUTE(), REDIRECT(), MIDDLEWARE(), das Objekt NAV sowie die Optionen und Ereignisse von Routen.\n\nDiese Funktionen ordnen in einer Single-Page-Anwendung URLs bestimmten Funktionen zu, und `NAV` enthält den aktuellen Zustand der Navigation. Eine Einführung mit vollständigen Beispielen findest du unter [Routing](../../guides/routing/).\n\n## API\n\n### ROUTE(url, callback, [middleware], [init])\n\nType: `method`\n\nRegistriert eine Funktion für eine URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die URL der Route. Darin können dynamische Segmente wie `{id}` und Umgebungsvariablen wie `[name]` stehen. Der Wert von `DEF.root` wird ihr vorangestellt. |\n| `callback` | `Function` | yes |  | Die auszuführende Funktion. Als Argumente erhält sie die Werte der dynamischen Segmente. |\n| `middleware` | `String or Array` | no |  | Ein kommagetrennter String oder ein Array aus [Middleware-Namen](#middleware-name), [Rollen](#role), [Codelisten](#code-list) und einem [Optionsobjekt](#options-object). Das Optionsobjekt wird nur in einem Array akzeptiert. |\n| `init` | `Function` | no |  | Eine Funktion, die einmalig beim ersten Besuch vor der Middleware läuft. Als Argument erhält sie `next`, das du aufrufen musst, damit es weitergeht. |\n\nReturns: `Object` Das Objekt `NAV`, sodass du Aufrufe verketten kannst.\n\nDie Route der aktuellen URL wird beim Start der Anwendung ausgeführt. Im Callback ist `this` das Objekt `NAV`, und die Werte der [dynamischen Segmente](#dynamic-segment) sind die Argumente.\n\nDie URL wird in Kleinbuchstaben verglichen, schreibe feste Segmente also klein. Fehlt der abschließende Schrägstrich, wird er der Adresse hinzugefügt. Eine statische Route hat Vorrang vor einer dynamischen mit gleich vielen Segmenten, und wenn du dieselbe URL erneut registrierst, wird die Route ersetzt.\n\nDu kannst die Argumente auch in diesen Reihenfolgen übergeben:\n\n- `ROUTE(url, middleware, callback, [init])`, mit `middleware` als Array\n- `ROUTE(url, callback, init, [middleware])`\n\nBefindet sich die aktuelle URL im 404-Zustand, wird eine dafür registrierte Route sofort ausgeführt.\n\nExample: Statische und dynamische Routen\n```js\nROUTE('/products/new/', function() {\n\tconsole.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n\tconsole.log('detail', id, this.url);\n});\n\nREDIRECT('/products/new/');\nREDIRECT('/products/AB-15');\n\n// Output:\n// form\n// detail AB-15 /products/AB-15/\n```\n\nExample: Eine Route einmalig vorbereiten\n```js\nROUTE('/reports/', function() {\n\tconsole.log('reports');\n}, function(next) {\n\tconsole.log('prepare once');\n\tnext();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n\n// Output:\n// prepare once\n// reports\n// reports\n```\n\n### REDIRECT([url])\n\nType: `method`\n\nNavigiert zu einer URL, ohne die Seite neu zu laden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | Die Ziel-URL mit optionalem Query-String. Darin können Umgebungsvariablen wie `[name]` stehen, und der Wert von `DEF.root` wird ihr vorangestellt. Der Standardwert ist die aktuelle URL. |\n\nOhne URL wird die aktuelle Route erneut ausgeführt. `REDIRECT('./')` bewirkt dasselbe, `REDIRECT('../')` geht ein Segment nach oben und `REDIRECT('../../')` zwei Segmente. Auf die Punkte kann ein Query-String folgen, zum Beispiel `REDIRECT('../?page=2')`.\n\nEin Wort am Ende der URL, das mit `@` beginnt, ist ein [benutzerdefiniertes Flag](#custom-flag).\n\nExample: Navigieren\n```js\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id, NAV.query.tab);\n});\n\nREDIRECT('/users/15/?tab=orders');\n\n// Output:\n// user 15 orders\n```\n\nExample: Eine Ebene nach oben gehen\n```js\nROUTE('/users/', function() {\n\tconsole.log('list');\n});\n\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id);\n});\n\nREDIRECT('/users/15/');\nREDIRECT('../');\nconsole.log(NAV.url);\n\n// Output:\n// user 15\n// list\n// /users/\n```\n\n### MIDDLEWARE(name, callback)\n\nType: `method`\n\nRegistriert eine benannte Middleware oder führt eine Liste von Middleware aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String or Array` | yes |  | Der Name der Middleware oder ein Array der auszuführenden Namen. |\n| `callback` | `Function` | yes |  | Die Middleware. Bei einem Array von Namen die Funktion, die am Ende aufgerufen wird. |\n\nReturns: `Object` Das Objekt `NAV`, sodass du Aufrufe verketten kannst.\n\nEine Middleware läuft vor dem Callback der Route und entscheidet, ob die Route fortgesetzt wird. Im Callback ist `this` das Objekt `NAV`. Der Callback erhält:\n\n| Argument | Typ | Beschreibung |\n| --- | --- | --- |\n| `next` | Function | `next()` setzt die Route fort. `next(false)` und `next(new Error())` stoppen die Route. |\n| `options` | Object | Das [Optionsobjekt](#options-object) der Route. |\n| `roles` | Array | Die [Rollen](#role) der Route. |\n| `route` | Object | Das [Routenobjekt](#route-object). |\n\nDie Kette stoppt auch, wenn sich die URL ändert, während eine Middleware noch arbeitet.\n\nMit einem Array von Namen führt `MIDDLEWARE(names, callback)` diese Middleware nacheinander aus und ruft anschließend `callback` auf. Jede Middleware erhält nur `next`, und unbekannte Namen werden übersprungen.\n\nExample: Eine Route schützen\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n\tconsole.log('auth', route.id);\n\tnext(user ? undefined : false);\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, 'auth');\n\nREDIRECT('/admin/');\n\nsetTimeout(function() {\n\tuser = { name: 'Ann' };\n\tREDIRECT('/admin/');\n}, 100);\n\n// Output:\n// auth /admin/\n// auth /admin/\n// admin page\n```\n\nExample: Eine Liste von Middleware ausführen\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nMIDDLEWARE(['first', 'second'], function() {\n\tconsole.log('done');\n});\n\n// Output:\n// first\n// second\n// done\n```\n\n### ROUTE('/items/{name}/', callback)\n\nType: `config`\n\nEin dynamisches Segment einer Routen-URL.\n\nEin Segment in geschweiften Klammern passt auf jeden Wert an dieser Stelle. Die Werte werden der Reihe nach an den Callback übergeben und stehen in `NAV.params` zur Verfügung. Dabei bleibt ihre ursprüngliche Groß- und Kleinschreibung erhalten. Die Adresse muss gleich viele Segmente haben wie die Route.\n\nExample: Zwei Segmente lesen\n```js\nROUTE('/items/{id}/{tab}/', function(id, tab) {\n\tconsole.log(id, tab, JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/AB-1/Photos/');\n\n// Output:\n// AB-1 Photos [\"AB-1\",\"Photos\"]\n```\n\n### ROUTE(url, callback, 'name')\n\nType: `config`\n\nFührt eine registrierte Middleware für die Route aus.\n\nEin einfacher Name im Argument `middleware` von `ROUTE()` wählt eine mit [MIDDLEWARE()](#middleware) registrierte Middleware aus. Die Middleware laufen in der angegebenen Reihenfolge, und ein nicht registrierter Name wird übersprungen.\n\nExample: Zwei Middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders');\n}, 'first,second');\n\nREDIRECT('/orders/');\n\n// Output:\n// first\n// second\n// orders\n```\n\n### ROUTE(url, callback, ['name', '@role'])\n\nType: `config`\n\nFügt eine Rolle hinzu, die Middleware im Array der Rollen erhalten.\n\nEin Eintrag, der mit `@` beginnt, wird ohne das `@` im Array `roles` an jede Middleware der Route übergeben. Rollen bewirken von sich aus nichts: Was sie bedeuten, entscheidet die Middleware.\n\nExample: Die Rollen lesen\n```js\nMIDDLEWARE('auth', function(next, options, roles) {\n\tconsole.log(roles.join());\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['auth', '@admin', '@editor']);\n\nREDIRECT('/admin/');\n\n// Output:\n// admin,editor\n// admin page\n```\n\n### ROUTE(url, callback, '#name')\n\nType: `config`\n\nLädt eine Codeliste vor dem Callback der Route.\n\nEin Eintrag, der mit `#` beginnt, lädt die Codeliste mit diesem Namen über `CL()`, und zwar an seiner Position in der Middleware-Kette. Siehe [Globale Funktionen](../globals/).\n\nExample: Eine Codeliste laden\n```js\nCLINIT('countries', function(next) {\n\tconsole.log('loading countries');\n\tnext([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders', DEF.cl.countries.length);\n}, '#countries');\n\nREDIRECT('/orders/');\n\n// Output:\n// loading countries\n// orders 1\n```\n\n### ROUTE(url, callback, ['name', { key: value }])\n\nType: `config`\n\nÜbergibt Optionen an die Middleware der Route.\n\nEin Objekt im Middleware-Array wird jeder Middleware der Route als `options` übergeben. Außerdem steht es in `options` des [Routenobjekts](#route-object) zur Verfügung.\n\nExample: Die Optionen lesen\n```js\nMIDDLEWARE('layout', function(next, options) {\n\tconsole.log(options.title);\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['layout', { title: 'Administration' }]);\n\nREDIRECT('/admin/');\n\n// Output:\n// Administration\n// admin page\n```\n\n### REDIRECT('/url/ @name')\n\nType: `config`\n\nLöst beim Navigieren ein Flag-Ereignis aus.\n\nEin Wort, das mit `@` beginnt, wird aus der URL entfernt, und vor der Navigation wird das Ereignis `@flag name` ausgelöst. Siehe [Ereignisse](../events/).\n\nExample: Auf ein Flag reagieren\n```js\nON('@flag audit', function() {\n\tconsole.log('audit');\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// audit\n// /orders/\n```\n\n### NAV.routes[index]\n\nType: `type`\n\nBeschreibt eine registrierte Route.\n\nMiddleware erhalten dieses Objekt als Argument `route`, und `NAV.routes` enthält eines für jede Route.\n\n| Eigenschaft | Typ | Beschreibung |\n| --- | --- | --- |\n| `id` | String | Die URL der Route. |\n| `url` | Array | Die Segmente der URL. |\n| `fn` | Function | Der Callback der Route. |\n| `priority` | Number | Die Position in der Abgleichsreihenfolge. Eine höhere Zahl wird zuerst geprüft. |\n| `params` | Array | Die Indizes der dynamischen Segmente. |\n| `middleware` | Array | Die Namen der Middleware und die Codelisten oder `null`. |\n| `init` | Function | Die Funktion `init`. Nach ihrer Ausführung ist der Wert `null`. |\n| `count` | Number | Wie oft die Route gepasst hat. |\n| `pending` | Boolean | `true`, solange die Middleware oder `init` noch arbeiten. |\n| `options` | Object | Das [Optionsobjekt](#options-object). |\n| `roles` | Array | Die [Rollen](#role). |\n\nExample: Eine Route untersuchen\n```js\nROUTE('/items/{id}/', function() {}, ['auth', '@admin', { title: 'Items' }]);\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nvar route = NAV.routes[0];\nconsole.log(route.id, JSON.stringify(route.url), JSON.stringify(route.params));\nconsole.log(JSON.stringify(route.middleware), JSON.stringify(route.roles), route.options.title);\n\n// Output:\n// /items/{id}/ [\"items\",\"{id}\"] [1]\n// [\"auth\"] [\"admin\"] Items\n```\n\n### NAV.autosave()\n\nType: `method`\n\nSpeichert den Verlauf bei jeder Navigation im Browserspeicher.\n\nNach diesem Aufruf wird der Verlauf bei jeder Änderung genauso gespeichert wie mit [NAV.save()](#nav-save). [NAV.load()](#nav-load) liest ihn wieder ein.\n\nExample: Den Verlauf behalten\n```js\nNAV.autosave();\n\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.back()\n\nType: `method`\n\nGeht zur vorherigen URL.\n\nReturns: `Object` Das Objekt `NAV`, sodass du Aufrufe verketten kannst.\n\nBei leerem Verlauf geht es zu `/`.\n\nExample: Zurückgehen\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.url, NAV.next());\n\n// Output:\n// /a/ /b/\n```\n\n### NAV.clientside(selector)\n\nType: `method`\n\nMacht passende Elemente zu clientseitigen Links.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Ein jQuery-Selektor für die Links. |\n\nReturns: `Object` Das Objekt `NAV`, sodass du Aufrufe verketten kannst.\n\nEin Klick auf ein passendes Element navigiert mit `REDIRECT()`. Die URL wird aus `href`, `data-href` oder `data-url` gelesen. Die Werte `#` und `javascript:void(0)` werden ignoriert. Auch später hinzugefügte Elemente funktionieren.\n\nExample: Links\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<span class=\"link\" data-href=\"/contact/\">Contact</span>\n\n<script>\nNAV.clientside('.link');\n\nROUTE('/about/', function() {\n\tconsole.log('about');\n});\n\nROUTE('/contact/', function() {\n\tconsole.log('contact');\n});\n</script>\n\n<!-- Output:\nabout\ncontact\n-->\n```\n\n### NAV.custom()\n\nType: `method`\n\nHält die Navigation innerhalb der Anwendung.\n\nRouten und `REDIRECT()` funktionieren wie gewohnt, und die Adressleiste bleibt unverändert. Das eignet sich für eine Anwendung, die in eine andere Seite eingebettet ist. Rufe die Funktion beim Start der Anwendung auf.\n\nExample: Innerhalb der Anwendung navigieren\n```js\nNAV.custom();\n\nROUTE('/inbox/', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nREDIRECT('/inbox/');\n\n// Output:\n// inbox /inbox/\n```\n\n### NAV.forward()\n\nType: `method`\n\nGeht nach dem Zurückgehen zur nächsten URL.\n\nReturns: `Object` Das Objekt `NAV`, sodass du Aufrufe verketten kannst.\n\nGibt es keine nächste URL, geht es zu `/`.\n\nExample: Vorwärtsgehen\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nNAV.forward();\nconsole.log(NAV.url);\n\n// Output:\n// /b/\n```\n\n### NAV.load()\n\nType: `method`\n\nStellt den Verlauf aus dem Browserspeicher wieder her.\n\nDie Funktion liest, was [NAV.save()](#nav-save) oder [NAV.autosave()](#nav-autosave) gespeichert haben. Die nächste Navigation fügt die aktuelle URL nicht zum wiederhergestellten Verlauf hinzu.\n\nExample: Den Verlauf wiederherstellen\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.location(url, [skiphistory])\n\nType: `method`\n\nFührt die Route einer URL aus, ohne die Adressleiste zu ändern.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die zu verarbeitende URL. |\n| `skiphistory` | `Boolean` | no | `false` | `true` fügt die aktuelle URL nicht zum Verlauf hinzu. |\n\n`NAV` wird aktualisiert, die Ereignisse werden ausgelöst und die Route läuft wie bei `REDIRECT()`. Die Adresse im Browser ändert sich nicht.\n\nExample: URLs verarbeiten\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.location('/a/');\nNAV.location('/b/');\nNAV.location('/c/', true);\n\nconsole.log(NAV.url, JSON.stringify(NAV.history));\n\n// Output:\n// a\n// /c/ [\"/a/\"]\n```\n\n### NAV.next()\n\nType: `method`\n\nGibt die URL zurück, die NAV.forward() öffnet.\n\nReturns: `String` Die nächste URL oder `undefined`, wenn es keine gibt.\n\nExample: Die nächste URL lesen\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.next());\n\n// Output:\n// /b/\n```\n\n### NAV.path(url, [delimiter])\n\nType: `method`\n\nFügt einer URL das abschließende Trennzeichen hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die URL. |\n| `delimiter` | `String` | no | `'/'` | Das hinzuzufügende Zeichen. |\n\nReturns: `String` Die URL mit dem Trennzeichen.\n\nEin Query-String bleibt hinter dem Trennzeichen erhalten. Eine URL, die mit `#` beginnt, wird unverändert zurückgegeben.\n\nExample: URLs normalisieren\n```js\nconsole.log(NAV.path('/products'));\nconsole.log(NAV.path('/products?page=2'));\nconsole.log(NAV.path('#inbox'));\n\n// Output:\n// /products/\n// /products/?page=2\n// #inbox\n```\n\n### NAV.prev()\n\nType: `method`\n\nGibt die URL zurück, die NAV.back() öffnet.\n\nReturns: `String` Die vorherige URL oder `undefined`, wenn es keine gibt.\n\nExample: Die vorherige URL lesen\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nconsole.log(NAV.prev());\n\n// Output:\n// /a/\n```\n\n### NAV.redirect([url])\n\nType: `method`\n\nDieselbe Funktion wie REDIRECT().\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | Die Ziel-URL. Der Standardwert ist die aktuelle URL. |\n\nSiehe [REDIRECT()](#redirect).\n\nExample: Navigieren\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.redirect('/a/');\n\n// Output:\n// a\n```\n\n### NAV.refresh()\n\nType: `method`\n\nFührt die Route der aktuellen URL erneut aus.\n\nDer Verlauf ändert sich nicht.\n\nExample: Die Route erneut ausführen\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.refresh();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// a\n// a\n// []\n```\n\n### NAV.reload()\n\nType: `method`\n\nDasselbe wie NAV.refresh().\n\nSiehe [NAV.refresh()](#nav-refresh).\n\nExample: Die Route erneut ausführen\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.reload();\n\n// Output:\n// a\n// a\n```\n\n### NAV.remember(name, [value])\n\nType: `method`\n\nFügt jedem folgenden REDIRECT() einen Query-Parameter hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Name des Query-Parameters. |\n| `value` | `String` | no |  | Der Wert oder `null`, um das Hinzufügen zu beenden. |\n\nOhne Wert bleibt der aktuelle Wert des Parameters in `NAV.query` erhalten. Der Wert `null` beendet das Hinzufügen des Parameters.\n\nExample: Einen Parameter beibehalten\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\n// Output:\n// /list/?lang=de\n// /list/\n```\n\n### NAV.remove(url)\n\nType: `method`\n\nEntfernt eine Route.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die in `ROUTE()` verwendete URL. |\n\nReturns: `Object` Das Objekt `NAV`, sodass du Aufrufe verketten kannst.\n\nExample: Eine Route entfernen\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.remove('/a/');\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n```\n\n### NAV.save()\n\nType: `method`\n\nSpeichert den Verlauf einmalig im Browserspeicher.\n\nDie vorherigen und nächsten URLs werden unter dem Schlüssel `DEF.localstorage + '.nav'` in `localStorage` geschrieben.\n\nExample: Den Verlauf speichern\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nvar data = JSON.parse(localStorage.getItem(DEF.localstorage + '.nav'));\nconsole.log(JSON.stringify(data.prev));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.status(code, [data])\n\nType: `method`\n\nLöst ein Ereignis aus, das nach einem Code benannt ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `Number or String` | yes |  | Der Name des Ereignisses. |\n| `data` | `Object` | no |  | Das Argument des Ereignisses. |\n\nReturns: `Object` Das Objekt `NAV`, sodass du Aufrufe verketten kannst.\n\nSo hat eine Anwendung eine zentrale Stelle für die Fehlerbehandlung.\n\nExample: Einen Fehler melden\n```js\nON('500', function(error) {\n\tconsole.log('failed:', error);\n});\n\nNAV.status(500, 'Database is down');\n\n// Output:\n// failed: Database is down\n```\n\n### NAV.hashtags\n\nType: `property`\n\nSteuert die Routen über den Hash-Teil der URL.\n\nReturns: `Boolean` Der Standardwert ist `false`.\n\nSetze den Wert beim Start der Anwendung auf `true`. Schreibe die Routen mit führendem `#` und navigiere über Links oder `location.hash`.\n\nExample: Routen über den Hash\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nsetTimeout(function() {\n\tlocation.hash = '#inbox';\n}, 100);\n\n// Output:\n// inbox #inbox\n```\n\n### NAV.href\n\nType: `property`\n\nDie URL, die an die letzte Navigation übergeben wurde.\n\nReturns: `String` Die URL mit ihrem Query-String.\n\nExample: Die URL lesen\n```js\nREDIRECT('/search/?q=lamp');\nconsole.log(NAV.href);\n\n// Output:\n// /search/?q=lamp\n```\n\n### NAV.history\n\nType: `property`\n\nDie vorherigen URLs.\n\nReturns: `Array` Ein Array von Strings.\n\nDie Einträge sind Paths ohne Query-String. Der letzte Eintrag ist der neueste.\n\nExample: Die vorherigen URLs auflisten\n```js\nREDIRECT('/a/?page=2');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.is404\n\nType: `property`\n\nGibt an, ob keine Route zur aktuellen URL passt.\n\nReturns: `Boolean` `true`, wenn keine Route passt.\n\nExample: Den Zustand prüfen\n```js\nROUTE('/a/', function() {});\n\nREDIRECT('/missing/');\nconsole.log(NAV.is404);\n\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n// false\n```\n\n### NAV.isback\n\nType: `property`\n\nDie Anzahl der URLs, zu denen du zurückgehen kannst.\n\nReturns: `Number` Die Anzahl der vorherigen URLs.\n\nDas ist ein Path, an den sich das Markup binden kann.\n\nExample: Die vorherigen URLs zählen\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(NAV.isback);\n\n// Output:\n// 2\n```\n\n### NAV.isforward\n\nType: `property`\n\nDie Anzahl der URLs, zu denen du vorwärtsgehen kannst.\n\nReturns: `Number` Die Anzahl der nächsten URLs.\n\nDas ist ein Path, an den sich das Markup binden kann.\n\nExample: Die nächsten URLs zählen\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.isforward);\n\n// Output:\n// 1\n```\n\n### NAV.middlewares\n\nType: `property`\n\nDie registrierten Middleware.\n\nReturns: `Object` Die Funktionen, mit den Namen der Middleware als Schlüssel.\n\nExample: Die Namen auflisten\n```js\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nconsole.log(Object.keys(NAV.middlewares).join());\n\n// Output:\n// auth\n```\n\n### NAV.params\n\nType: `property`\n\nDie Werte der dynamischen Segmente der aktuellen Route.\n\nReturns: `Array` Ein Array von Strings.\n\nDas ist ein Path, an den sich das Markup binden kann.\n\nExample: Die Werte lesen\n```js\nROUTE('/items/{id}/{tab}/', function() {\n\tconsole.log(JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/15/photos/');\n\n// Output:\n// [\"15\",\"photos\"]\n```\n\n### NAV.query\n\nType: `property`\n\nDer geparste Query-String der aktuellen URL.\n\nReturns: `Object` Die Parameter. Alle Werte sind Strings.\n\nNamen und Werte werden dekodiert, und ein `+` wird zu einem Leerzeichen. Das ist ein Path, an den sich das Markup binden kann.\n\nExample: Den Query-String lesen\n```js\nREDIRECT('/search/?q=desk+lamp&page=2');\nconsole.log(JSON.stringify(NAV.query));\n\n// Output:\n// {\"q\":\"desk lamp\",\"page\":\"2\"}\n```\n\n### NAV.queryraw\n\nType: `property`\n\nDer Query-String als Text.\n\nReturns: `String` Der Query-String ohne das führende `?`.\n\nExample: Den Text lesen\n```js\nREDIRECT('/search/?q=lamp&page=2');\nconsole.log(NAV.queryraw);\n\n// Output:\n// q=lamp&page=2\n```\n\n### NAV.routes\n\nType: `property`\n\nDie registrierten Routen.\n\nReturns: `Array` Ein Array von Routenobjekten.\n\nDas Array ist in der Abgleichsreihenfolge sortiert. Jeder Eintrag ist ein [Routenobjekt](#route-object).\n\nExample: Die Routen auflisten\n```js\nROUTE('/items/{id}/', function() {});\nROUTE('/items/new/', function() {});\n\nconsole.log(NAV.routes.map(route => route.id).join());\n\n// Output:\n// /items/new/,/items/{id}/\n```\n\n### NAV.ua\n\nType: `property`\n\nInformationen über den Browser.\n\nReturns: `Object` Das Objekt von `MAIN.ua`.\n\nDas ist dasselbe Objekt wie `MAIN.ua` und steht zur Verfügung, sobald die Anwendung gestartet ist. Siehe [MAIN](../main/).\n\nExample: Mit MAIN vergleichen\n```js\nROUTE('/', function() {\n\tconsole.log(NAV.ua === MAIN.ua);\n});\n\n// Output:\n// true\n```\n\n### NAV.url\n\nType: `property`\n\nDer aktuelle Path ohne Query-String.\n\nReturns: `String` Der Path mit abschließendem Schrägstrich.\n\nDas ist ein Path, an den sich das Markup mit `<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>` binden kann.\n\nExample: Den Path lesen\n```js\nREDIRECT('/search?q=lamp');\nconsole.log(NAV.url);\n\n// Output:\n// /search/\n```\n\n### ON('location', function(url) {})\n\nType: `event`\n\nWird ausgelöst, wenn sich die URL ändert, noch vor dem Callback der Route.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Der Path ohne Query-String. |\n\nExample: Die Navigation beobachten\n```js\nON('location', function(url) {\n\tconsole.log('location', url);\n});\n\nROUTE('/a/', function() {\n\tconsole.log('route');\n});\n\nREDIRECT('/a/?page=2');\n\n// Output:\n// location /a/\n// route\n```\n\n### ON('404', function() {})\n\nType: `event`\n\nWird ausgelöst, wenn keine Route zur URL passt.\n\nExample: Eine unbekannte URL behandeln\n```js\nON('404', function() {\n\tconsole.log('not found', NAV.url);\n});\n\nREDIRECT('/missing/');\n\n// Output:\n// not found /missing/\n```\n\n### ON('route', function(url) {})\n\nType: `event`\n\nWird ausgelöst, wenn eine Route registriert wird.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Die URL der Route. |\n\nExample: Die Registrierung beobachten\n```js\nON('route', function(url) {\n\tconsole.log('registered', url);\n});\n\nROUTE('/a/', function() {});\n\n// Output:\n// registered /a/\n```\n","entries":[{"type":"method","name":"ROUTE()","signature":"ROUTE(url, callback, [middleware], [init])","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT([url])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, callback)","since":"","deprecated":false},{"type":"config","name":"{name}","signature":"ROUTE('/items/{name}/', callback)","since":"","deprecated":false},{"type":"config","name":"Middleware name","signature":"ROUTE(url, callback, 'name')","since":"","deprecated":false},{"type":"config","name":"@role","signature":"ROUTE(url, callback, ['name', '@role'])","since":"","deprecated":false},{"type":"config","name":"#codelist","signature":"ROUTE(url, callback, '#name')","since":"","deprecated":false},{"type":"config","name":"Options object","signature":"ROUTE(url, callback, ['name', { key: value }])","since":"","deprecated":false},{"type":"config","name":"@flag","signature":"REDIRECT('/url/ @name')","since":"","deprecated":false},{"type":"type","name":"Route object","signature":"NAV.routes[index]","since":"","deprecated":false},{"type":"method","name":"NAV.autosave()","signature":"NAV.autosave()","since":"","deprecated":false},{"type":"method","name":"NAV.back()","signature":"NAV.back()","since":"","deprecated":false},{"type":"method","name":"NAV.clientside()","signature":"NAV.clientside(selector)","since":"","deprecated":false},{"type":"method","name":"NAV.custom()","signature":"NAV.custom()","since":"","deprecated":false},{"type":"method","name":"NAV.forward()","signature":"NAV.forward()","since":"","deprecated":false},{"type":"method","name":"NAV.load()","signature":"NAV.load()","since":"","deprecated":false},{"type":"method","name":"NAV.location()","signature":"NAV.location(url, [skiphistory])","since":"","deprecated":false},{"type":"method","name":"NAV.next()","signature":"NAV.next()","since":"","deprecated":false},{"type":"method","name":"NAV.path()","signature":"NAV.path(url, [delimiter])","since":"","deprecated":false},{"type":"method","name":"NAV.prev()","signature":"NAV.prev()","since":"","deprecated":false},{"type":"method","name":"NAV.redirect()","signature":"NAV.redirect([url])","since":"","deprecated":false},{"type":"method","name":"NAV.refresh()","signature":"NAV.refresh()","since":"","deprecated":false},{"type":"method","name":"NAV.reload()","signature":"NAV.reload()","since":"","deprecated":false},{"type":"method","name":"NAV.remember()","signature":"NAV.remember(name, [value])","since":"","deprecated":false},{"type":"method","name":"NAV.remove()","signature":"NAV.remove(url)","since":"","deprecated":false},{"type":"method","name":"NAV.save()","signature":"NAV.save()","since":"","deprecated":false},{"type":"method","name":"NAV.status()","signature":"NAV.status(code, [data])","since":"","deprecated":false},{"type":"property","name":"NAV.hashtags","signature":"NAV.hashtags","since":"","deprecated":false},{"type":"property","name":"NAV.href","signature":"NAV.href","since":"","deprecated":false},{"type":"property","name":"NAV.history","signature":"NAV.history","since":"","deprecated":false},{"type":"property","name":"NAV.is404","signature":"NAV.is404","since":"","deprecated":false},{"type":"property","name":"NAV.isback","signature":"NAV.isback","since":"","deprecated":false},{"type":"property","name":"NAV.isforward","signature":"NAV.isforward","since":"","deprecated":false},{"type":"property","name":"NAV.middlewares","signature":"NAV.middlewares","since":"","deprecated":false},{"type":"property","name":"NAV.params","signature":"NAV.params","since":"","deprecated":false},{"type":"property","name":"NAV.query","signature":"NAV.query","since":"","deprecated":false},{"type":"property","name":"NAV.queryraw","signature":"NAV.queryraw","since":"","deprecated":false},{"type":"property","name":"NAV.routes","signature":"NAV.routes","since":"","deprecated":false},{"type":"property","name":"NAV.ua","signature":"NAV.ua","since":"","deprecated":false},{"type":"property","name":"NAV.url","signature":"NAV.url","since":"","deprecated":false},{"type":"event","name":"location","signature":"ON('location', function(url) {})","since":"","deprecated":false},{"type":"event","name":"404","signature":"ON('404', function() {})","since":"","deprecated":false},{"type":"event","name":"route","signature":"ON('route', function(url) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T17:06:08.115Z"}
{"id":"JanH6T1cG61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/routing/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Enrutamiento","summary":"La API de enrutamiento del lado del cliente: ROUTE(), REDIRECT(), MIDDLEWARE(), el objeto NAV y las opciones y los eventos de las rutas.","markdown":"---\ntitle: Enrutamiento\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/routing/\nupdated: 2026-11-18T17:06:08.115Z\n---\n\n# Enrutamiento\n\n> La API de enrutamiento del lado del cliente: ROUTE(), REDIRECT(), MIDDLEWARE(), el objeto NAV y las opciones y los eventos de las rutas.\n\nEstas funciones asocian URL a funciones en una aplicación de una sola página, y `NAV` guarda el estado actual de la navegación. Para ver una introducción con ejemplos completos, lee [Enrutamiento](../../guides/routing/).\n\n## API\n\n### ROUTE(url, callback, [middleware], [init])\n\nType: `method`\n\nRegistra una función para una URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La URL de la ruta. Puede contener segmentos dinámicos como `{id}` y variables de entorno como `[name]`. El valor de `DEF.root` se añade delante. |\n| `callback` | `Function` | yes |  | La función que se ejecuta. Recibe los valores de los segmentos dinámicos. |\n| `middleware` | `String or Array` | no |  | Una cadena separada por comas o un array de [nombres de middleware](#middleware-name), [roles](#role), [listas de códigos](#code-list) y un [objeto de opciones](#options-object). El objeto de opciones solo se acepta en un array. |\n| `init` | `Function` | no |  | Una función que se ejecuta una sola vez, en la primera visita, antes del middleware. Recibe `next`, al que debes llamar para continuar. |\n\nReturns: `Object` El objeto `NAV`, para que puedas encadenar llamadas.\n\nLa ruta de la URL actual se ejecuta al iniciarse la aplicación. Dentro del callback, `this` es `NAV`, y los valores de los [segmentos dinámicos](#dynamic-segment) son los argumentos.\n\nLa URL se compara en minúsculas, así que escribe los segmentos fijos en minúsculas. Si a la dirección le falta la barra final, se le añade. Una ruta estática tiene prioridad sobre una dinámica con el mismo número de segmentos, y si registras de nuevo la misma URL, se reemplaza la ruta.\n\nLos argumentos también se pueden pasar en estos órdenes:\n\n- `ROUTE(url, middleware, callback, [init])`, con `middleware` como array\n- `ROUTE(url, callback, init, [middleware])`\n\nCuando la URL actual está en el estado 404, una ruta registrada para ella se ejecuta de inmediato.\n\nExample: Rutas estáticas y dinámicas\n```js\nROUTE('/products/new/', function() {\n\tconsole.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n\tconsole.log('detail', id, this.url);\n});\n\nREDIRECT('/products/new/');\nREDIRECT('/products/AB-15');\n\n// Output:\n// form\n// detail AB-15 /products/AB-15/\n```\n\nExample: Prepara una ruta una sola vez\n```js\nROUTE('/reports/', function() {\n\tconsole.log('reports');\n}, function(next) {\n\tconsole.log('prepare once');\n\tnext();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n\n// Output:\n// prepare once\n// reports\n// reports\n```\n\n### REDIRECT([url])\n\nType: `method`\n\nNavega a una URL sin recargar la página.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | La URL de destino con una cadena de consulta opcional. Puede contener variables de entorno como `[name]`, y el valor de `DEF.root` se añade delante. El valor predeterminado es la URL actual. |\n\nSin una URL, la ruta actual se ejecuta de nuevo. `REDIRECT('./')` hace lo mismo, `REDIRECT('../')` sube un segmento y `REDIRECT('../../')` sube dos segmentos. Detrás de los puntos puede ir una cadena de consulta, por ejemplo `REDIRECT('../?page=2')`.\n\nUna palabra que empieza por `@` al final de la URL es un [flag personalizado](#custom-flag).\n\nExample: Navega\n```js\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id, NAV.query.tab);\n});\n\nREDIRECT('/users/15/?tab=orders');\n\n// Output:\n// user 15 orders\n```\n\nExample: Sube un nivel\n```js\nROUTE('/users/', function() {\n\tconsole.log('list');\n});\n\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id);\n});\n\nREDIRECT('/users/15/');\nREDIRECT('../');\nconsole.log(NAV.url);\n\n// Output:\n// user 15\n// list\n// /users/\n```\n\n### MIDDLEWARE(name, callback)\n\nType: `method`\n\nRegistra un middleware con nombre o ejecuta una lista de middleware.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String or Array` | yes |  | El nombre del middleware o un array de nombres que ejecutar. |\n| `callback` | `Function` | yes |  | El middleware. Con un array de nombres, la función a la que se llama al final. |\n\nReturns: `Object` El objeto `NAV`, para que puedas encadenar llamadas.\n\nUn middleware se ejecuta antes del callback de la ruta y decide si la ruta continúa. Dentro del callback, `this` es `NAV`. El callback recibe:\n\n| Argumento | Tipo | Descripción |\n| --- | --- | --- |\n| `next` | Function | `next()` continúa. `next(false)` y `next(new Error())` detienen la ruta. |\n| `options` | Object | El [objeto de opciones](#options-object) de la ruta. |\n| `roles` | Array | Los [roles](#role) de la ruta. |\n| `route` | Object | El [objeto de ruta](#route-object). |\n\nLa cadena también se detiene cuando la URL cambia mientras un middleware está trabajando.\n\nCon un array de nombres, `MIDDLEWARE(names, callback)` ejecuta esos middleware uno tras otro y después llama a `callback`. Cada middleware recibe solo `next`, y los nombres desconocidos se omiten.\n\nExample: Protege una ruta\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n\tconsole.log('auth', route.id);\n\tnext(user ? undefined : false);\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, 'auth');\n\nREDIRECT('/admin/');\n\nsetTimeout(function() {\n\tuser = { name: 'Ann' };\n\tREDIRECT('/admin/');\n}, 100);\n\n// Output:\n// auth /admin/\n// auth /admin/\n// admin page\n```\n\nExample: Ejecuta una lista de middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nMIDDLEWARE(['first', 'second'], function() {\n\tconsole.log('done');\n});\n\n// Output:\n// first\n// second\n// done\n```\n\n### ROUTE('/items/{name}/', callback)\n\nType: `config`\n\nUn segmento dinámico de la URL de una ruta.\n\nUn segmento entre llaves coincide con cualquier valor de ese segmento. Los valores se pasan al callback en orden y están disponibles en `NAV.params`. Conservan sus mayúsculas y minúsculas originales. La dirección debe tener el mismo número de segmentos que la ruta.\n\nExample: Lee dos segmentos\n```js\nROUTE('/items/{id}/{tab}/', function(id, tab) {\n\tconsole.log(id, tab, JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/AB-1/Photos/');\n\n// Output:\n// AB-1 Photos [\"AB-1\",\"Photos\"]\n```\n\n### ROUTE(url, callback, 'name')\n\nType: `config`\n\nEjecuta un middleware registrado para la ruta.\n\nUn nombre simple en el argumento `middleware` de `ROUTE()` selecciona un middleware registrado con [MIDDLEWARE()](#middleware). Los middleware se ejecutan en el orden indicado, y un nombre que no está registrado se omite.\n\nExample: Dos middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders');\n}, 'first,second');\n\nREDIRECT('/orders/');\n\n// Output:\n// first\n// second\n// orders\n```\n\n### ROUTE(url, callback, ['name', '@role'])\n\nType: `config`\n\nAñade un rol que los middleware reciben en el array de roles.\n\nUn elemento que empieza por `@` se pasa a todos los middleware de la ruta en el array `roles`, sin la `@`. Los roles no tienen ningún efecto por sí mismos: es el middleware quien decide qué significan.\n\nExample: Lee los roles\n```js\nMIDDLEWARE('auth', function(next, options, roles) {\n\tconsole.log(roles.join());\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['auth', '@admin', '@editor']);\n\nREDIRECT('/admin/');\n\n// Output:\n// admin,editor\n// admin page\n```\n\n### ROUTE(url, callback, '#name')\n\nType: `config`\n\nCarga una lista de códigos antes del callback de la ruta.\n\nUn elemento que empieza por `#` carga la lista de códigos con ese nombre mediante `CL()`, en su posición dentro de la cadena de middleware. Consulta [Funciones globales](../globals/).\n\nExample: Carga una lista de códigos\n```js\nCLINIT('countries', function(next) {\n\tconsole.log('loading countries');\n\tnext([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders', DEF.cl.countries.length);\n}, '#countries');\n\nREDIRECT('/orders/');\n\n// Output:\n// loading countries\n// orders 1\n```\n\n### ROUTE(url, callback, ['name', { key: value }])\n\nType: `config`\n\nPasa opciones a los middleware de la ruta.\n\nUn objeto en el array de middleware se pasa a todos los middleware de la ruta como `options`. También está disponible en `options` del [objeto de ruta](#route-object).\n\nExample: Lee las opciones\n```js\nMIDDLEWARE('layout', function(next, options) {\n\tconsole.log(options.title);\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['layout', { title: 'Administration' }]);\n\nREDIRECT('/admin/');\n\n// Output:\n// Administration\n// admin page\n```\n\n### REDIRECT('/url/ @name')\n\nType: `config`\n\nEmite un evento de flag al navegar.\n\nUna palabra que empieza por `@` se elimina de la URL, y el evento `@flag name` se emite antes de la navegación. Consulta [Eventos](../events/).\n\nExample: Reacciona a un flag\n```js\nON('@flag audit', function() {\n\tconsole.log('audit');\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// audit\n// /orders/\n```\n\n### NAV.routes[index]\n\nType: `type`\n\nDescribe una ruta registrada.\n\nLos middleware reciben este objeto como argumento `route`, y `NAV.routes` contiene uno por cada ruta.\n\n| Propiedad | Tipo | Descripción |\n| --- | --- | --- |\n| `id` | String | La URL de la ruta. |\n| `url` | Array | Los segmentos de la URL. |\n| `fn` | Function | El callback de la ruta. |\n| `priority` | Number | La posición en el orden de coincidencia. Un número más alto se prueba primero. |\n| `params` | Array | Los índices de los segmentos dinámicos. |\n| `middleware` | Array | Los nombres de middleware y las listas de códigos, o `null`. |\n| `init` | Function | La función `init`. Es `null` después de ejecutarse. |\n| `count` | Number | Cuántas veces ha coincidido la ruta. |\n| `pending` | Boolean | `true` mientras los middleware o `init` están trabajando. |\n| `options` | Object | El [objeto de opciones](#options-object). |\n| `roles` | Array | Los [roles](#role). |\n\nExample: Inspecciona una ruta\n```js\nROUTE('/items/{id}/', function() {}, ['auth', '@admin', { title: 'Items' }]);\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nvar route = NAV.routes[0];\nconsole.log(route.id, JSON.stringify(route.url), JSON.stringify(route.params));\nconsole.log(JSON.stringify(route.middleware), JSON.stringify(route.roles), route.options.title);\n\n// Output:\n// /items/{id}/ [\"items\",\"{id}\"] [1]\n// [\"auth\"] [\"admin\"] Items\n```\n\n### NAV.autosave()\n\nType: `method`\n\nGuarda el historial en el almacenamiento del navegador en cada navegación.\n\nDespués de esta llamada, el historial se guarda igual que con [NAV.save()](#nav-save) cada vez que cambia. [NAV.load()](#nav-load) lo vuelve a leer.\n\nExample: Conserva el historial\n```js\nNAV.autosave();\n\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.back()\n\nType: `method`\n\nVa a la URL anterior.\n\nReturns: `Object` El objeto `NAV`, para que puedas encadenar llamadas.\n\nCon el historial vacío, va a `/`.\n\nExample: Vuelve atrás\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.url, NAV.next());\n\n// Output:\n// /a/ /b/\n```\n\n### NAV.clientside(selector)\n\nType: `method`\n\nConvierte los elementos coincidentes en enlaces del lado del cliente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selector de jQuery de los enlaces. |\n\nReturns: `Object` El objeto `NAV`, para que puedas encadenar llamadas.\n\nUn clic en un elemento coincidente navega con `REDIRECT()`. La URL se lee de `href`, `data-href` o `data-url`. Los valores `#` y `javascript:void(0)` se ignoran. Los elementos que se añaden más tarde también funcionan.\n\nExample: Enlaces\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<span class=\"link\" data-href=\"/contact/\">Contact</span>\n\n<script>\nNAV.clientside('.link');\n\nROUTE('/about/', function() {\n\tconsole.log('about');\n});\n\nROUTE('/contact/', function() {\n\tconsole.log('contact');\n});\n</script>\n\n<!-- Output:\nabout\ncontact\n-->\n```\n\n### NAV.custom()\n\nType: `method`\n\nMantiene la navegación dentro de la aplicación.\n\nLas rutas y `REDIRECT()` funcionan como siempre, y la barra de direcciones no cambia. Esto es útil para una aplicación incrustada en otra página. Llámalo al inicio de la aplicación.\n\nExample: Navega dentro de la aplicación\n```js\nNAV.custom();\n\nROUTE('/inbox/', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nREDIRECT('/inbox/');\n\n// Output:\n// inbox /inbox/\n```\n\n### NAV.forward()\n\nType: `method`\n\nVa a la URL siguiente después de haber vuelto atrás.\n\nReturns: `Object` El objeto `NAV`, para que puedas encadenar llamadas.\n\nCuando no hay una URL siguiente, va a `/`.\n\nExample: Avanza\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nNAV.forward();\nconsole.log(NAV.url);\n\n// Output:\n// /b/\n```\n\n### NAV.load()\n\nType: `method`\n\nRestaura el historial desde el almacenamiento del navegador.\n\nLee lo que guardaron [NAV.save()](#nav-save) o [NAV.autosave()](#nav-autosave). La siguiente navegación no añade la URL actual al historial restaurado.\n\nExample: Restaura el historial\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.location(url, [skiphistory])\n\nType: `method`\n\nEjecuta la ruta de una URL sin cambiar la barra de direcciones.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La URL que se procesa. |\n| `skiphistory` | `Boolean` | no | `false` | `true` no añade la URL actual al historial. |\n\n`NAV` se actualiza, se emiten los eventos y la ruta se ejecuta, como en `REDIRECT()`. La dirección del navegador no cambia.\n\nExample: Procesa URL\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.location('/a/');\nNAV.location('/b/');\nNAV.location('/c/', true);\n\nconsole.log(NAV.url, JSON.stringify(NAV.history));\n\n// Output:\n// a\n// /c/ [\"/a/\"]\n```\n\n### NAV.next()\n\nType: `method`\n\nDevuelve la URL que abre NAV.forward().\n\nReturns: `String` La URL siguiente, o `undefined` cuando no hay ninguna.\n\nExample: Lee la URL siguiente\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.next());\n\n// Output:\n// /b/\n```\n\n### NAV.path(url, [delimiter])\n\nType: `method`\n\nAñade el delimitador final a una URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La URL. |\n| `delimiter` | `String` | no | `'/'` | El carácter que se añade. |\n\nReturns: `String` La URL con el delimitador.\n\nLa cadena de consulta se conserva después del delimitador. Una URL que empieza por `#` se devuelve sin cambios.\n\nExample: Normaliza URL\n```js\nconsole.log(NAV.path('/products'));\nconsole.log(NAV.path('/products?page=2'));\nconsole.log(NAV.path('#inbox'));\n\n// Output:\n// /products/\n// /products/?page=2\n// #inbox\n```\n\n### NAV.prev()\n\nType: `method`\n\nDevuelve la URL que abre NAV.back().\n\nReturns: `String` La URL anterior, o `undefined` cuando no hay ninguna.\n\nExample: Lee la URL anterior\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nconsole.log(NAV.prev());\n\n// Output:\n// /a/\n```\n\n### NAV.redirect([url])\n\nType: `method`\n\nLa misma función que REDIRECT().\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | La URL de destino. El valor predeterminado es la URL actual. |\n\nConsulta [REDIRECT()](#redirect).\n\nExample: Navega\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.redirect('/a/');\n\n// Output:\n// a\n```\n\n### NAV.refresh()\n\nType: `method`\n\nEjecuta de nuevo la ruta de la URL actual.\n\nEl historial no cambia.\n\nExample: Ejecuta la ruta de nuevo\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.refresh();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// a\n// a\n// []\n```\n\n### NAV.reload()\n\nType: `method`\n\nIgual que NAV.refresh().\n\nConsulta [NAV.refresh()](#nav-refresh).\n\nExample: Ejecuta la ruta de nuevo\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.reload();\n\n// Output:\n// a\n// a\n```\n\n### NAV.remember(name, [value])\n\nType: `method`\n\nAñade un parámetro de consulta a cada REDIRECT() posterior.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del parámetro de consulta. |\n| `value` | `String` | no |  | El valor, o `null` para dejar de añadirlo. |\n\nSin un valor, se conserva el valor actual del parámetro en `NAV.query`. El valor `null` deja de añadir el parámetro.\n\nExample: Conserva un parámetro\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\n// Output:\n// /list/?lang=de\n// /list/\n```\n\n### NAV.remove(url)\n\nType: `method`\n\nElimina una ruta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La URL usada en `ROUTE()`. |\n\nReturns: `Object` El objeto `NAV`, para que puedas encadenar llamadas.\n\nExample: Elimina una ruta\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.remove('/a/');\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n```\n\n### NAV.save()\n\nType: `method`\n\nGuarda el historial en el almacenamiento del navegador una sola vez.\n\nLas URL anteriores y siguientes se escriben en `localStorage` con la clave `DEF.localstorage + '.nav'`.\n\nExample: Guarda el historial\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nvar data = JSON.parse(localStorage.getItem(DEF.localstorage + '.nav'));\nconsole.log(JSON.stringify(data.prev));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.status(code, [data])\n\nType: `method`\n\nEmite un evento con el nombre de un código.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `Number or String` | yes |  | El nombre del evento. |\n| `data` | `Object` | no |  | El argumento del evento. |\n\nReturns: `Object` El objeto `NAV`, para que puedas encadenar llamadas.\n\nAsí la aplicación tiene un único lugar donde gestionar los errores.\n\nExample: Informa de un error\n```js\nON('500', function(error) {\n\tconsole.log('failed:', error);\n});\n\nNAV.status(500, 'Database is down');\n\n// Output:\n// failed: Database is down\n```\n\n### NAV.hashtags\n\nType: `property`\n\nControla las rutas con la parte hash de la URL.\n\nReturns: `Boolean` El valor predeterminado es `false`.\n\nEstablécelo en `true` al inicio de la aplicación. Escribe las rutas con un `#` delante y navega con enlaces o con `location.hash`.\n\nExample: Rutas en el hash\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nsetTimeout(function() {\n\tlocation.hash = '#inbox';\n}, 100);\n\n// Output:\n// inbox #inbox\n```\n\n### NAV.href\n\nType: `property`\n\nLa URL pasada en la última navegación.\n\nReturns: `String` La URL con su cadena de consulta.\n\nExample: Lee la URL\n```js\nREDIRECT('/search/?q=lamp');\nconsole.log(NAV.href);\n\n// Output:\n// /search/?q=lamp\n```\n\n### NAV.history\n\nType: `property`\n\nLas URL anteriores.\n\nReturns: `Array` Un array de cadenas.\n\nLos elementos son paths sin la cadena de consulta. El último elemento es el más reciente.\n\nExample: Lista las URL anteriores\n```js\nREDIRECT('/a/?page=2');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.is404\n\nType: `property`\n\nIndica si ninguna ruta coincide con la URL actual.\n\nReturns: `Boolean` `true` cuando ninguna ruta coincide.\n\nExample: Comprueba el estado\n```js\nROUTE('/a/', function() {});\n\nREDIRECT('/missing/');\nconsole.log(NAV.is404);\n\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n// false\n```\n\n### NAV.isback\n\nType: `property`\n\nEl número de URL a las que puedes volver.\n\nReturns: `Number` El número de URL anteriores.\n\nEs un path, así que el marcado puede enlazarse a él.\n\nExample: Cuenta las URL anteriores\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(NAV.isback);\n\n// Output:\n// 2\n```\n\n### NAV.isforward\n\nType: `property`\n\nEl número de URL a las que puedes avanzar.\n\nReturns: `Number` El número de URL siguientes.\n\nEs un path, así que el marcado puede enlazarse a él.\n\nExample: Cuenta las URL siguientes\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.isforward);\n\n// Output:\n// 1\n```\n\n### NAV.middlewares\n\nType: `property`\n\nLos middleware registrados.\n\nReturns: `Object` Las funciones, con los nombres de los middleware como claves.\n\nExample: Lista los nombres\n```js\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nconsole.log(Object.keys(NAV.middlewares).join());\n\n// Output:\n// auth\n```\n\n### NAV.params\n\nType: `property`\n\nLos valores de los segmentos dinámicos de la ruta actual.\n\nReturns: `Array` Un array de cadenas.\n\nEs un path, así que el marcado puede enlazarse a él.\n\nExample: Lee los valores\n```js\nROUTE('/items/{id}/{tab}/', function() {\n\tconsole.log(JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/15/photos/');\n\n// Output:\n// [\"15\",\"photos\"]\n```\n\n### NAV.query\n\nType: `property`\n\nLa cadena de consulta analizada de la URL actual.\n\nReturns: `Object` Los parámetros. Todos los valores son cadenas.\n\nLos nombres y los valores se decodifican, y un `+` se convierte en un espacio. Es un path, así que el marcado puede enlazarse a él.\n\nExample: Lee la cadena de consulta\n```js\nREDIRECT('/search/?q=desk+lamp&page=2');\nconsole.log(JSON.stringify(NAV.query));\n\n// Output:\n// {\"q\":\"desk lamp\",\"page\":\"2\"}\n```\n\n### NAV.queryraw\n\nType: `property`\n\nLa cadena de consulta como texto.\n\nReturns: `String` La cadena de consulta sin el `?` inicial.\n\nExample: Lee el texto\n```js\nREDIRECT('/search/?q=lamp&page=2');\nconsole.log(NAV.queryraw);\n\n// Output:\n// q=lamp&page=2\n```\n\n### NAV.routes\n\nType: `property`\n\nLas rutas registradas.\n\nReturns: `Array` Un array de objetos de ruta.\n\nEl array está ordenado según el orden de coincidencia. Cada elemento es un [objeto de ruta](#route-object).\n\nExample: Lista las rutas\n```js\nROUTE('/items/{id}/', function() {});\nROUTE('/items/new/', function() {});\n\nconsole.log(NAV.routes.map(route => route.id).join());\n\n// Output:\n// /items/new/,/items/{id}/\n```\n\n### NAV.ua\n\nType: `property`\n\nInformación sobre el navegador.\n\nReturns: `Object` El objeto de `MAIN.ua`.\n\nEs el mismo objeto que `MAIN.ua` y está disponible cuando la aplicación se ha iniciado. Consulta [MAIN](../main/).\n\nExample: Compara con MAIN\n```js\nROUTE('/', function() {\n\tconsole.log(NAV.ua === MAIN.ua);\n});\n\n// Output:\n// true\n```\n\n### NAV.url\n\nType: `property`\n\nEl path actual sin la cadena de consulta.\n\nReturns: `String` El path con una barra final.\n\nEs un path, así que el marcado puede enlazarse a él con `<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>`.\n\nExample: Lee el path\n```js\nREDIRECT('/search?q=lamp');\nconsole.log(NAV.url);\n\n// Output:\n// /search/\n```\n\n### ON('location', function(url) {})\n\nType: `event`\n\nSe emite cuando cambia la URL, antes del callback de la ruta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | El path sin la cadena de consulta. |\n\nExample: Observa la navegación\n```js\nON('location', function(url) {\n\tconsole.log('location', url);\n});\n\nROUTE('/a/', function() {\n\tconsole.log('route');\n});\n\nREDIRECT('/a/?page=2');\n\n// Output:\n// location /a/\n// route\n```\n\n### ON('404', function() {})\n\nType: `event`\n\nSe emite cuando ninguna ruta coincide con la URL.\n\nExample: Gestiona una URL desconocida\n```js\nON('404', function() {\n\tconsole.log('not found', NAV.url);\n});\n\nREDIRECT('/missing/');\n\n// Output:\n// not found /missing/\n```\n\n### ON('route', function(url) {})\n\nType: `event`\n\nSe emite cuando se registra una ruta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | La URL de la ruta. |\n\nExample: Observa el registro\n```js\nON('route', function(url) {\n\tconsole.log('registered', url);\n});\n\nROUTE('/a/', function() {});\n\n// Output:\n// registered /a/\n```\n","entries":[{"type":"method","name":"ROUTE()","signature":"ROUTE(url, callback, [middleware], [init])","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT([url])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, callback)","since":"","deprecated":false},{"type":"config","name":"{name}","signature":"ROUTE('/items/{name}/', callback)","since":"","deprecated":false},{"type":"config","name":"Middleware name","signature":"ROUTE(url, callback, 'name')","since":"","deprecated":false},{"type":"config","name":"@role","signature":"ROUTE(url, callback, ['name', '@role'])","since":"","deprecated":false},{"type":"config","name":"#codelist","signature":"ROUTE(url, callback, '#name')","since":"","deprecated":false},{"type":"config","name":"Options object","signature":"ROUTE(url, callback, ['name', { key: value }])","since":"","deprecated":false},{"type":"config","name":"@flag","signature":"REDIRECT('/url/ @name')","since":"","deprecated":false},{"type":"type","name":"Route object","signature":"NAV.routes[index]","since":"","deprecated":false},{"type":"method","name":"NAV.autosave()","signature":"NAV.autosave()","since":"","deprecated":false},{"type":"method","name":"NAV.back()","signature":"NAV.back()","since":"","deprecated":false},{"type":"method","name":"NAV.clientside()","signature":"NAV.clientside(selector)","since":"","deprecated":false},{"type":"method","name":"NAV.custom()","signature":"NAV.custom()","since":"","deprecated":false},{"type":"method","name":"NAV.forward()","signature":"NAV.forward()","since":"","deprecated":false},{"type":"method","name":"NAV.load()","signature":"NAV.load()","since":"","deprecated":false},{"type":"method","name":"NAV.location()","signature":"NAV.location(url, [skiphistory])","since":"","deprecated":false},{"type":"method","name":"NAV.next()","signature":"NAV.next()","since":"","deprecated":false},{"type":"method","name":"NAV.path()","signature":"NAV.path(url, [delimiter])","since":"","deprecated":false},{"type":"method","name":"NAV.prev()","signature":"NAV.prev()","since":"","deprecated":false},{"type":"method","name":"NAV.redirect()","signature":"NAV.redirect([url])","since":"","deprecated":false},{"type":"method","name":"NAV.refresh()","signature":"NAV.refresh()","since":"","deprecated":false},{"type":"method","name":"NAV.reload()","signature":"NAV.reload()","since":"","deprecated":false},{"type":"method","name":"NAV.remember()","signature":"NAV.remember(name, [value])","since":"","deprecated":false},{"type":"method","name":"NAV.remove()","signature":"NAV.remove(url)","since":"","deprecated":false},{"type":"method","name":"NAV.save()","signature":"NAV.save()","since":"","deprecated":false},{"type":"method","name":"NAV.status()","signature":"NAV.status(code, [data])","since":"","deprecated":false},{"type":"property","name":"NAV.hashtags","signature":"NAV.hashtags","since":"","deprecated":false},{"type":"property","name":"NAV.href","signature":"NAV.href","since":"","deprecated":false},{"type":"property","name":"NAV.history","signature":"NAV.history","since":"","deprecated":false},{"type":"property","name":"NAV.is404","signature":"NAV.is404","since":"","deprecated":false},{"type":"property","name":"NAV.isback","signature":"NAV.isback","since":"","deprecated":false},{"type":"property","name":"NAV.isforward","signature":"NAV.isforward","since":"","deprecated":false},{"type":"property","name":"NAV.middlewares","signature":"NAV.middlewares","since":"","deprecated":false},{"type":"property","name":"NAV.params","signature":"NAV.params","since":"","deprecated":false},{"type":"property","name":"NAV.query","signature":"NAV.query","since":"","deprecated":false},{"type":"property","name":"NAV.queryraw","signature":"NAV.queryraw","since":"","deprecated":false},{"type":"property","name":"NAV.routes","signature":"NAV.routes","since":"","deprecated":false},{"type":"property","name":"NAV.ua","signature":"NAV.ua","since":"","deprecated":false},{"type":"property","name":"NAV.url","signature":"NAV.url","since":"","deprecated":false},{"type":"event","name":"location","signature":"ON('location', function(url) {})","since":"","deprecated":false},{"type":"event","name":"404","signature":"ON('404', function() {})","since":"","deprecated":false},{"type":"event","name":"route","signature":"ON('route', function(url) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T17:06:08.115Z"}
{"id":"JanH6T1cG61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/routing/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Routage","summary":"L'API de routage côté client : ROUTE(), REDIRECT(), MIDDLEWARE(), l'objet NAV, ainsi que les options et les événements des routes.","markdown":"---\ntitle: Routage\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/routing/\nupdated: 2026-11-18T17:06:08.115Z\n---\n\n# Routage\n\n> L'API de routage côté client : ROUTE(), REDIRECT(), MIDDLEWARE(), l'objet NAV, ainsi que les options et les événements des routes.\n\nCes fonctions associent des URL à des fonctions dans une application monopage, et `NAV` contient l'état actuel de la navigation. Pour une introduction avec des exemples complets, lis [Routage](../../guides/routing/).\n\n## API\n\n### ROUTE(url, callback, [middleware], [init])\n\nType: `method`\n\nEnregistre une fonction pour une URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL de la route. Elle peut contenir des segments dynamiques comme `{id}` et des variables d'environnement comme `[name]`. La valeur de `DEF.root` est ajoutée devant. |\n| `callback` | `Function` | yes |  | La fonction à exécuter. Elle reçoit les valeurs des segments dynamiques. |\n| `middleware` | `String or Array` | no |  | Une chaîne séparée par des virgules ou un tableau de [noms de middleware](#middleware-name), de [rôles](#role), de [listes de codes](#code-list) et d'un [objet d'options](#options-object). L'objet d'options n'est accepté que dans un tableau. |\n| `init` | `Function` | no |  | Une fonction qui s'exécute une seule fois, à la première visite, avant les middleware. Elle reçoit `next`, que tu dois appeler pour continuer. |\n\nReturns: `Object` L'objet `NAV`, pour pouvoir enchaîner les appels.\n\nLa route de l'URL actuelle s'exécute au démarrage de l'application. Dans le callback, `this` est `NAV`, et les valeurs des [segments dynamiques](#dynamic-segment) sont les arguments.\n\nL'URL est comparée en minuscules : écris donc les segments fixes en minuscules. Une barre oblique finale manquante est ajoutée à l'adresse. Une route statique l'emporte sur une route dynamique qui a le même nombre de segments, et enregistrer de nouveau la même URL remplace la route.\n\nTu peux aussi passer les arguments dans ces ordres :\n\n- `ROUTE(url, middleware, callback, [init])`, avec `middleware` sous forme de tableau\n- `ROUTE(url, callback, init, [middleware])`\n\nQuand l'URL actuelle est à l'état 404, une route enregistrée pour cette URL s'exécute immédiatement.\n\nExample: Routes statiques et dynamiques\n```js\nROUTE('/products/new/', function() {\n\tconsole.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n\tconsole.log('detail', id, this.url);\n});\n\nREDIRECT('/products/new/');\nREDIRECT('/products/AB-15');\n\n// Output:\n// form\n// detail AB-15 /products/AB-15/\n```\n\nExample: Préparer une route une seule fois\n```js\nROUTE('/reports/', function() {\n\tconsole.log('reports');\n}, function(next) {\n\tconsole.log('prepare once');\n\tnext();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n\n// Output:\n// prepare once\n// reports\n// reports\n```\n\n### REDIRECT([url])\n\nType: `method`\n\nNavigue vers une URL sans recharger la page.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | L'URL cible, avec une chaîne de requête facultative. Elle peut contenir des variables d'environnement comme `[name]`, et la valeur de `DEF.root` est ajoutée devant. La valeur par défaut est l'URL actuelle. |\n\nSans URL, la route actuelle s'exécute de nouveau. `REDIRECT('./')` fait la même chose, `REDIRECT('../')` remonte d'un segment et `REDIRECT('../../')` remonte de deux segments. Une chaîne de requête peut suivre les points, par exemple `REDIRECT('../?page=2')`.\n\nUn mot commençant par `@` à la fin de l'URL est un [flag personnalisé](#custom-flag).\n\nExample: Naviguer\n```js\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id, NAV.query.tab);\n});\n\nREDIRECT('/users/15/?tab=orders');\n\n// Output:\n// user 15 orders\n```\n\nExample: Remonter d'un niveau\n```js\nROUTE('/users/', function() {\n\tconsole.log('list');\n});\n\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id);\n});\n\nREDIRECT('/users/15/');\nREDIRECT('../');\nconsole.log(NAV.url);\n\n// Output:\n// user 15\n// list\n// /users/\n```\n\n### MIDDLEWARE(name, callback)\n\nType: `method`\n\nEnregistre un middleware nommé ou exécute une liste de middleware.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String or Array` | yes |  | Le nom du middleware, ou un tableau de noms à exécuter. |\n| `callback` | `Function` | yes |  | Le middleware. Avec un tableau de noms, la fonction à appeler à la fin. |\n\nReturns: `Object` L'objet `NAV`, pour pouvoir enchaîner les appels.\n\nUn middleware s'exécute avant le callback de la route et décide si la route continue. Dans le callback, `this` est `NAV`. Le callback reçoit :\n\n| Argument | Type | Description |\n| --- | --- | --- |\n| `next` | Function | `next()` continue. `next(false)` et `next(new Error())` arrêtent la route. |\n| `options` | Object | L'[objet d'options](#options-object) de la route. |\n| `roles` | Array | Les [rôles](#role) de la route. |\n| `route` | Object | L'[objet route](#route-object). |\n\nLa chaîne s'arrête aussi quand l'URL change pendant qu'un middleware travaille.\n\nAvec un tableau de noms, `MIDDLEWARE(names, callback)` exécute ces middleware l'un après l'autre, puis appelle `callback`. Chaque middleware reçoit uniquement `next`, et les noms inconnus sont ignorés.\n\nExample: Protéger une route\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n\tconsole.log('auth', route.id);\n\tnext(user ? undefined : false);\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, 'auth');\n\nREDIRECT('/admin/');\n\nsetTimeout(function() {\n\tuser = { name: 'Ann' };\n\tREDIRECT('/admin/');\n}, 100);\n\n// Output:\n// auth /admin/\n// auth /admin/\n// admin page\n```\n\nExample: Exécuter une liste de middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nMIDDLEWARE(['first', 'second'], function() {\n\tconsole.log('done');\n});\n\n// Output:\n// first\n// second\n// done\n```\n\n### ROUTE('/items/{name}/', callback)\n\nType: `config`\n\nUn segment dynamique de l'URL d'une route.\n\nUn segment entre accolades correspond à n'importe quelle valeur de ce segment. Les valeurs sont passées au callback dans l'ordre et sont disponibles dans `NAV.params`. Elles conservent leur casse d'origine. L'adresse doit avoir le même nombre de segments que la route.\n\nExample: Lire deux segments\n```js\nROUTE('/items/{id}/{tab}/', function(id, tab) {\n\tconsole.log(id, tab, JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/AB-1/Photos/');\n\n// Output:\n// AB-1 Photos [\"AB-1\",\"Photos\"]\n```\n\n### ROUTE(url, callback, 'name')\n\nType: `config`\n\nExécute un middleware enregistré pour la route.\n\nUn simple nom dans l'argument `middleware` de `ROUTE()` sélectionne un middleware enregistré avec [MIDDLEWARE()](#middleware). Les middleware s'exécutent dans l'ordre de la liste, et un nom qui n'est pas enregistré est ignoré.\n\nExample: Deux middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders');\n}, 'first,second');\n\nREDIRECT('/orders/');\n\n// Output:\n// first\n// second\n// orders\n```\n\n### ROUTE(url, callback, ['name', '@role'])\n\nType: `config`\n\nAjoute un rôle que les middleware reçoivent dans le tableau des rôles.\n\nUn élément commençant par `@` est passé à chaque middleware de la route dans le tableau `roles`, sans le `@`. Les rôles n'ont aucun effet par eux-mêmes : c'est le middleware qui décide de leur signification.\n\nExample: Lire les rôles\n```js\nMIDDLEWARE('auth', function(next, options, roles) {\n\tconsole.log(roles.join());\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['auth', '@admin', '@editor']);\n\nREDIRECT('/admin/');\n\n// Output:\n// admin,editor\n// admin page\n```\n\n### ROUTE(url, callback, '#name')\n\nType: `config`\n\nCharge une liste de codes avant le callback de la route.\n\nUn élément commençant par `#` charge la liste de codes de ce nom via `CL()`, à sa position dans la chaîne de middleware. Consulte [Fonctions globales](../globals/).\n\nExample: Charger une liste de codes\n```js\nCLINIT('countries', function(next) {\n\tconsole.log('loading countries');\n\tnext([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders', DEF.cl.countries.length);\n}, '#countries');\n\nREDIRECT('/orders/');\n\n// Output:\n// loading countries\n// orders 1\n```\n\n### ROUTE(url, callback, ['name', { key: value }])\n\nType: `config`\n\nPasse des options aux middleware de la route.\n\nUn objet placé dans le tableau des middleware est passé à chaque middleware de la route sous le nom `options`. Il est aussi disponible dans `options` de l'[objet route](#route-object).\n\nExample: Lire les options\n```js\nMIDDLEWARE('layout', function(next, options) {\n\tconsole.log(options.title);\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['layout', { title: 'Administration' }]);\n\nREDIRECT('/admin/');\n\n// Output:\n// Administration\n// admin page\n```\n\n### REDIRECT('/url/ @name')\n\nType: `config`\n\nÉmet un événement de flag lors de la navigation.\n\nUn mot commençant par `@` est retiré de l'URL, et l'événement `@flag name` est émis avant la navigation. Consulte [Événements](../events/).\n\nExample: Réagir à un flag\n```js\nON('@flag audit', function() {\n\tconsole.log('audit');\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// audit\n// /orders/\n```\n\n### NAV.routes[index]\n\nType: `type`\n\nDécrit une route enregistrée.\n\nLes middleware reçoivent cet objet dans l'argument `route`, et `NAV.routes` en contient un pour chaque route.\n\n| Propriété | Type | Description |\n| --- | --- | --- |\n| `id` | String | L'URL de la route. |\n| `url` | Array | Les segments de l'URL. |\n| `fn` | Function | Le callback de la route. |\n| `priority` | Number | La position dans l'ordre de correspondance. Un nombre plus élevé est essayé en premier. |\n| `params` | Array | Les index des segments dynamiques. |\n| `middleware` | Array | Les noms de middleware et les listes de codes, ou `null`. |\n| `init` | Function | La fonction `init`. Elle vaut `null` après son exécution. |\n| `count` | Number | Le nombre de fois où la route a correspondu. |\n| `pending` | Boolean | `true` pendant que les middleware ou `init` travaillent. |\n| `options` | Object | L'[objet d'options](#options-object). |\n| `roles` | Array | Les [rôles](#role). |\n\nExample: Inspecter une route\n```js\nROUTE('/items/{id}/', function() {}, ['auth', '@admin', { title: 'Items' }]);\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nvar route = NAV.routes[0];\nconsole.log(route.id, JSON.stringify(route.url), JSON.stringify(route.params));\nconsole.log(JSON.stringify(route.middleware), JSON.stringify(route.roles), route.options.title);\n\n// Output:\n// /items/{id}/ [\"items\",\"{id}\"] [1]\n// [\"auth\"] [\"admin\"] Items\n```\n\n### NAV.autosave()\n\nType: `method`\n\nEnregistre l'historique dans le stockage du navigateur à chaque navigation.\n\nAprès cet appel, l'historique est stocké de la même façon qu'avec [NAV.save()](#nav-save) chaque fois qu'il change. [NAV.load()](#nav-load) le relit.\n\nExample: Conserver l'historique\n```js\nNAV.autosave();\n\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.back()\n\nType: `method`\n\nVa à l'URL précédente.\n\nReturns: `Object` L'objet `NAV`, pour pouvoir enchaîner les appels.\n\nSi l'historique est vide, va à `/`.\n\nExample: Revenir en arrière\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.url, NAV.next());\n\n// Output:\n// /a/ /b/\n```\n\n### NAV.clientside(selector)\n\nType: `method`\n\nTransforme les éléments correspondants en liens côté client.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un sélecteur jQuery des liens. |\n\nReturns: `Object` L'objet `NAV`, pour pouvoir enchaîner les appels.\n\nUn clic sur un élément correspondant navigue avec `REDIRECT()`. L'URL est lue depuis `href`, `data-href` ou `data-url`. Les valeurs `#` et `javascript:void(0)` sont ignorées. Les éléments ajoutés plus tard fonctionnent aussi.\n\nExample: Liens\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<span class=\"link\" data-href=\"/contact/\">Contact</span>\n\n<script>\nNAV.clientside('.link');\n\nROUTE('/about/', function() {\n\tconsole.log('about');\n});\n\nROUTE('/contact/', function() {\n\tconsole.log('contact');\n});\n</script>\n\n<!-- Output:\nabout\ncontact\n-->\n```\n\n### NAV.custom()\n\nType: `method`\n\nGarde la navigation à l'intérieur de l'application.\n\nLes routes et `REDIRECT()` fonctionnent normalement, et la barre d'adresse ne change pas. C'est adapté à une application intégrée dans une autre page. Appelle-la au démarrage de l'application.\n\nExample: Naviguer à l'intérieur de l'application\n```js\nNAV.custom();\n\nROUTE('/inbox/', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nREDIRECT('/inbox/');\n\n// Output:\n// inbox /inbox/\n```\n\n### NAV.forward()\n\nType: `method`\n\nVa à l'URL suivante après un retour en arrière.\n\nReturns: `Object` L'objet `NAV`, pour pouvoir enchaîner les appels.\n\nS'il n'y a pas d'URL suivante, va à `/`.\n\nExample: Avancer\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nNAV.forward();\nconsole.log(NAV.url);\n\n// Output:\n// /b/\n```\n\n### NAV.load()\n\nType: `method`\n\nRestaure l'historique depuis le stockage du navigateur.\n\nLit ce que [NAV.save()](#nav-save) ou [NAV.autosave()](#nav-autosave) a stocké. La navigation suivante n'ajoute pas l'URL actuelle à l'historique restauré.\n\nExample: Restaurer l'historique\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.location(url, [skiphistory])\n\nType: `method`\n\nExécute la route d'une URL sans modifier la barre d'adresse.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL à traiter. |\n| `skiphistory` | `Boolean` | no | `false` | `true` n'ajoute pas l'URL actuelle à l'historique. |\n\n`NAV` est mis à jour, les événements sont émis et la route s'exécute, comme avec `REDIRECT()`. L'adresse dans le navigateur ne change pas.\n\nExample: Traiter des URL\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.location('/a/');\nNAV.location('/b/');\nNAV.location('/c/', true);\n\nconsole.log(NAV.url, JSON.stringify(NAV.history));\n\n// Output:\n// a\n// /c/ [\"/a/\"]\n```\n\n### NAV.next()\n\nType: `method`\n\nRenvoie l'URL qu'ouvre NAV.forward().\n\nReturns: `String` L'URL suivante, ou `undefined` s'il n'y en a pas.\n\nExample: Lire l'URL suivante\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.next());\n\n// Output:\n// /b/\n```\n\n### NAV.path(url, [delimiter])\n\nType: `method`\n\nAjoute le délimiteur final à une URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL. |\n| `delimiter` | `String` | no | `'/'` | Le caractère à ajouter. |\n\nReturns: `String` L'URL avec le délimiteur.\n\nUne chaîne de requête est conservée après le délimiteur. Une URL commençant par `#` est renvoyée sans modification.\n\nExample: Normaliser des URL\n```js\nconsole.log(NAV.path('/products'));\nconsole.log(NAV.path('/products?page=2'));\nconsole.log(NAV.path('#inbox'));\n\n// Output:\n// /products/\n// /products/?page=2\n// #inbox\n```\n\n### NAV.prev()\n\nType: `method`\n\nRenvoie l'URL qu'ouvre NAV.back().\n\nReturns: `String` L'URL précédente, ou `undefined` s'il n'y en a pas.\n\nExample: Lire l'URL précédente\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nconsole.log(NAV.prev());\n\n// Output:\n// /a/\n```\n\n### NAV.redirect([url])\n\nType: `method`\n\nLa même fonction que REDIRECT().\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | L'URL cible. La valeur par défaut est l'URL actuelle. |\n\nConsulte [REDIRECT()](#redirect).\n\nExample: Naviguer\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.redirect('/a/');\n\n// Output:\n// a\n```\n\n### NAV.refresh()\n\nType: `method`\n\nExécute de nouveau la route de l'URL actuelle.\n\nL'historique ne change pas.\n\nExample: Exécuter de nouveau la route\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.refresh();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// a\n// a\n// []\n```\n\n### NAV.reload()\n\nType: `method`\n\nIdentique à NAV.refresh().\n\nConsulte [NAV.refresh()](#nav-refresh).\n\nExample: Exécuter de nouveau la route\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.reload();\n\n// Output:\n// a\n// a\n```\n\n### NAV.remember(name, [value])\n\nType: `method`\n\nAjoute un paramètre de requête à chaque REDIRECT() suivant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom du paramètre de requête. |\n| `value` | `String` | no |  | La valeur, ou `null` pour arrêter. |\n\nSans valeur, la valeur actuelle du paramètre dans `NAV.query` est conservée. La valeur `null` arrête l'ajout du paramètre.\n\nExample: Conserver un paramètre\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\n// Output:\n// /list/?lang=de\n// /list/\n```\n\n### NAV.remove(url)\n\nType: `method`\n\nSupprime une route.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL utilisée dans `ROUTE()`. |\n\nReturns: `Object` L'objet `NAV`, pour pouvoir enchaîner les appels.\n\nExample: Supprimer une route\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.remove('/a/');\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n```\n\n### NAV.save()\n\nType: `method`\n\nStocke l'historique une seule fois dans le stockage du navigateur.\n\nLes URL précédentes et suivantes sont écrites dans `localStorage` sous la clé `DEF.localstorage + '.nav'`.\n\nExample: Stocker l'historique\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nvar data = JSON.parse(localStorage.getItem(DEF.localstorage + '.nav'));\nconsole.log(JSON.stringify(data.prev));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.status(code, [data])\n\nType: `method`\n\nÉmet un événement qui porte le nom d'un code.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `Number or String` | yes |  | Le nom de l'événement. |\n| `data` | `Object` | no |  | L'argument de l'événement. |\n\nReturns: `Object` L'objet `NAV`, pour pouvoir enchaîner les appels.\n\nCela donne à une application un seul endroit où gérer les erreurs.\n\nExample: Signaler une erreur\n```js\nON('500', function(error) {\n\tconsole.log('failed:', error);\n});\n\nNAV.status(500, 'Database is down');\n\n// Output:\n// failed: Database is down\n```\n\n### NAV.hashtags\n\nType: `property`\n\nPilote les routes avec la partie hash de l'URL.\n\nReturns: `Boolean` La valeur par défaut est `false`.\n\nDéfinis-la à `true` au démarrage de l'application. Écris les routes avec un `#` au début, et navigue avec des liens ou `location.hash`.\n\nExample: Routes sur le hash\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nsetTimeout(function() {\n\tlocation.hash = '#inbox';\n}, 100);\n\n// Output:\n// inbox #inbox\n```\n\n### NAV.href\n\nType: `property`\n\nL'URL passée à la dernière navigation.\n\nReturns: `String` L'URL avec sa chaîne de requête.\n\nExample: Lire l'URL\n```js\nREDIRECT('/search/?q=lamp');\nconsole.log(NAV.href);\n\n// Output:\n// /search/?q=lamp\n```\n\n### NAV.history\n\nType: `property`\n\nLes URL précédentes.\n\nReturns: `Array` Un tableau de chaînes.\n\nLes éléments sont des paths sans la chaîne de requête. Le dernier élément est le plus récent.\n\nExample: Lister les URL précédentes\n```js\nREDIRECT('/a/?page=2');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.is404\n\nType: `property`\n\nIndique si aucune route ne correspond à l'URL actuelle.\n\nReturns: `Boolean` `true` quand aucune route ne correspond.\n\nExample: Vérifier l'état\n```js\nROUTE('/a/', function() {});\n\nREDIRECT('/missing/');\nconsole.log(NAV.is404);\n\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n// false\n```\n\n### NAV.isback\n\nType: `property`\n\nLe nombre d'URL vers lesquelles tu peux revenir.\n\nReturns: `Number` Le nombre d'URL précédentes.\n\nC'est un path : le balisage peut donc s'y lier.\n\nExample: Compter les URL précédentes\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(NAV.isback);\n\n// Output:\n// 2\n```\n\n### NAV.isforward\n\nType: `property`\n\nLe nombre d'URL vers lesquelles tu peux avancer.\n\nReturns: `Number` Le nombre d'URL suivantes.\n\nC'est un path : le balisage peut donc s'y lier.\n\nExample: Compter les URL suivantes\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.isforward);\n\n// Output:\n// 1\n```\n\n### NAV.middlewares\n\nType: `property`\n\nLes middleware enregistrés.\n\nReturns: `Object` Les fonctions, avec les noms des middleware comme clés.\n\nExample: Lister les noms\n```js\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nconsole.log(Object.keys(NAV.middlewares).join());\n\n// Output:\n// auth\n```\n\n### NAV.params\n\nType: `property`\n\nLes valeurs des segments dynamiques de la route actuelle.\n\nReturns: `Array` Un tableau de chaînes.\n\nC'est un path : le balisage peut donc s'y lier.\n\nExample: Lire les valeurs\n```js\nROUTE('/items/{id}/{tab}/', function() {\n\tconsole.log(JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/15/photos/');\n\n// Output:\n// [\"15\",\"photos\"]\n```\n\n### NAV.query\n\nType: `property`\n\nLa chaîne de requête analysée de l'URL actuelle.\n\nReturns: `Object` Les paramètres. Toutes les valeurs sont des chaînes.\n\nLes noms et les valeurs sont décodés, et un `+` devient une espace. C'est un path : le balisage peut donc s'y lier.\n\nExample: Lire la chaîne de requête\n```js\nREDIRECT('/search/?q=desk+lamp&page=2');\nconsole.log(JSON.stringify(NAV.query));\n\n// Output:\n// {\"q\":\"desk lamp\",\"page\":\"2\"}\n```\n\n### NAV.queryraw\n\nType: `property`\n\nLa chaîne de requête sous forme de texte.\n\nReturns: `String` La chaîne de requête sans le `?` initial.\n\nExample: Lire le texte\n```js\nREDIRECT('/search/?q=lamp&page=2');\nconsole.log(NAV.queryraw);\n\n// Output:\n// q=lamp&page=2\n```\n\n### NAV.routes\n\nType: `property`\n\nLes routes enregistrées.\n\nReturns: `Array` Un tableau d'objets route.\n\nLe tableau est trié dans l'ordre de correspondance. Chaque élément est un [objet route](#route-object).\n\nExample: Lister les routes\n```js\nROUTE('/items/{id}/', function() {});\nROUTE('/items/new/', function() {});\n\nconsole.log(NAV.routes.map(route => route.id).join());\n\n// Output:\n// /items/new/,/items/{id}/\n```\n\n### NAV.ua\n\nType: `property`\n\nInformations sur le navigateur.\n\nReturns: `Object` L'objet de `MAIN.ua`.\n\nC'est le même objet que `MAIN.ua`, disponible une fois l'application démarrée. Consulte [MAIN](../main/).\n\nExample: Comparer avec MAIN\n```js\nROUTE('/', function() {\n\tconsole.log(NAV.ua === MAIN.ua);\n});\n\n// Output:\n// true\n```\n\n### NAV.url\n\nType: `property`\n\nLe path actuel sans la chaîne de requête.\n\nReturns: `String` Le path avec une barre oblique finale.\n\nC'est un path : le balisage peut donc s'y lier avec `<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>`.\n\nExample: Lire le path\n```js\nREDIRECT('/search?q=lamp');\nconsole.log(NAV.url);\n\n// Output:\n// /search/\n```\n\n### ON('location', function(url) {})\n\nType: `event`\n\nÉmis quand l'URL change, avant le callback de la route.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Le path sans la chaîne de requête. |\n\nExample: Observer la navigation\n```js\nON('location', function(url) {\n\tconsole.log('location', url);\n});\n\nROUTE('/a/', function() {\n\tconsole.log('route');\n});\n\nREDIRECT('/a/?page=2');\n\n// Output:\n// location /a/\n// route\n```\n\n### ON('404', function() {})\n\nType: `event`\n\nÉmis quand aucune route ne correspond à l'URL.\n\nExample: Gérer une URL inconnue\n```js\nON('404', function() {\n\tconsole.log('not found', NAV.url);\n});\n\nREDIRECT('/missing/');\n\n// Output:\n// not found /missing/\n```\n\n### ON('route', function(url) {})\n\nType: `event`\n\nÉmis quand une route est enregistrée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL de la route. |\n\nExample: Observer l'enregistrement\n```js\nON('route', function(url) {\n\tconsole.log('registered', url);\n});\n\nROUTE('/a/', function() {});\n\n// Output:\n// registered /a/\n```\n","entries":[{"type":"method","name":"ROUTE()","signature":"ROUTE(url, callback, [middleware], [init])","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT([url])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, callback)","since":"","deprecated":false},{"type":"config","name":"{name}","signature":"ROUTE('/items/{name}/', callback)","since":"","deprecated":false},{"type":"config","name":"Middleware name","signature":"ROUTE(url, callback, 'name')","since":"","deprecated":false},{"type":"config","name":"@role","signature":"ROUTE(url, callback, ['name', '@role'])","since":"","deprecated":false},{"type":"config","name":"#codelist","signature":"ROUTE(url, callback, '#name')","since":"","deprecated":false},{"type":"config","name":"Options object","signature":"ROUTE(url, callback, ['name', { key: value }])","since":"","deprecated":false},{"type":"config","name":"@flag","signature":"REDIRECT('/url/ @name')","since":"","deprecated":false},{"type":"type","name":"Route object","signature":"NAV.routes[index]","since":"","deprecated":false},{"type":"method","name":"NAV.autosave()","signature":"NAV.autosave()","since":"","deprecated":false},{"type":"method","name":"NAV.back()","signature":"NAV.back()","since":"","deprecated":false},{"type":"method","name":"NAV.clientside()","signature":"NAV.clientside(selector)","since":"","deprecated":false},{"type":"method","name":"NAV.custom()","signature":"NAV.custom()","since":"","deprecated":false},{"type":"method","name":"NAV.forward()","signature":"NAV.forward()","since":"","deprecated":false},{"type":"method","name":"NAV.load()","signature":"NAV.load()","since":"","deprecated":false},{"type":"method","name":"NAV.location()","signature":"NAV.location(url, [skiphistory])","since":"","deprecated":false},{"type":"method","name":"NAV.next()","signature":"NAV.next()","since":"","deprecated":false},{"type":"method","name":"NAV.path()","signature":"NAV.path(url, [delimiter])","since":"","deprecated":false},{"type":"method","name":"NAV.prev()","signature":"NAV.prev()","since":"","deprecated":false},{"type":"method","name":"NAV.redirect()","signature":"NAV.redirect([url])","since":"","deprecated":false},{"type":"method","name":"NAV.refresh()","signature":"NAV.refresh()","since":"","deprecated":false},{"type":"method","name":"NAV.reload()","signature":"NAV.reload()","since":"","deprecated":false},{"type":"method","name":"NAV.remember()","signature":"NAV.remember(name, [value])","since":"","deprecated":false},{"type":"method","name":"NAV.remove()","signature":"NAV.remove(url)","since":"","deprecated":false},{"type":"method","name":"NAV.save()","signature":"NAV.save()","since":"","deprecated":false},{"type":"method","name":"NAV.status()","signature":"NAV.status(code, [data])","since":"","deprecated":false},{"type":"property","name":"NAV.hashtags","signature":"NAV.hashtags","since":"","deprecated":false},{"type":"property","name":"NAV.href","signature":"NAV.href","since":"","deprecated":false},{"type":"property","name":"NAV.history","signature":"NAV.history","since":"","deprecated":false},{"type":"property","name":"NAV.is404","signature":"NAV.is404","since":"","deprecated":false},{"type":"property","name":"NAV.isback","signature":"NAV.isback","since":"","deprecated":false},{"type":"property","name":"NAV.isforward","signature":"NAV.isforward","since":"","deprecated":false},{"type":"property","name":"NAV.middlewares","signature":"NAV.middlewares","since":"","deprecated":false},{"type":"property","name":"NAV.params","signature":"NAV.params","since":"","deprecated":false},{"type":"property","name":"NAV.query","signature":"NAV.query","since":"","deprecated":false},{"type":"property","name":"NAV.queryraw","signature":"NAV.queryraw","since":"","deprecated":false},{"type":"property","name":"NAV.routes","signature":"NAV.routes","since":"","deprecated":false},{"type":"property","name":"NAV.ua","signature":"NAV.ua","since":"","deprecated":false},{"type":"property","name":"NAV.url","signature":"NAV.url","since":"","deprecated":false},{"type":"event","name":"location","signature":"ON('location', function(url) {})","since":"","deprecated":false},{"type":"event","name":"404","signature":"ON('404', function() {})","since":"","deprecated":false},{"type":"event","name":"route","signature":"ON('route', function(url) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T17:06:08.115Z"}
{"id":"JanH6T1cG61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/routing/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Routing","summary":"L'API di routing lato client: ROUTE(), REDIRECT(), MIDDLEWARE(), l'oggetto NAV e le opzioni e gli eventi delle route.","markdown":"---\ntitle: Routing\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/routing/\nupdated: 2026-11-18T17:06:08.115Z\n---\n\n# Routing\n\n> L'API di routing lato client: ROUTE(), REDIRECT(), MIDDLEWARE(), l'oggetto NAV e le opzioni e gli eventi delle route.\n\nQueste funzioni collegano gli URL a delle funzioni in un'applicazione single-page, e `NAV` contiene lo stato corrente della navigazione. Per un'introduzione con esempi completi, leggi [Routing](../../guides/routing/).\n\n## API\n\n### ROUTE(url, callback, [middleware], [init])\n\nType: `method`\n\nRegistra una funzione per un URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL della route. Può contenere segmenti dinamici come `{id}` e variabili d'ambiente come `[name]`. Il valore di `DEF.root` viene aggiunto all'inizio. |\n| `callback` | `Function` | yes |  | La funzione da eseguire. Riceve i valori dei segmenti dinamici. |\n| `middleware` | `String or Array` | no |  | Una stringa separata da virgole o un array di [nomi di middleware](#middleware-name), [ruoli](#role), [elenchi di codici](#code-list) e un [oggetto delle opzioni](#options-object). L'oggetto delle opzioni è accettato solo in un array. |\n| `init` | `Function` | no |  | Una funzione eseguita una sola volta, alla prima visita, prima dei middleware. Riceve `next`, che devi chiamare per continuare. |\n\nReturns: `Object` L'oggetto `NAV`, così puoi concatenare le chiamate.\n\nLa route dell'URL corrente viene eseguita all'avvio dell'applicazione. Dentro la callback, `this` è `NAV` e gli argomenti sono i valori dei [segmenti dinamici](#dynamic-segment).\n\nL'URL viene confrontato in minuscolo, quindi scrivi i segmenti fissi in minuscolo. Se all'indirizzo manca lo slash finale, viene aggiunto. A parità di numero di segmenti, una route statica ha la precedenza su una dinamica, e registrando di nuovo lo stesso URL sostituisci la route.\n\nPuoi passare gli argomenti anche in questi ordini:\n\n- `ROUTE(url, middleware, callback, [init])`, con `middleware` come array\n- `ROUTE(url, callback, init, [middleware])`\n\nQuando l'URL corrente è nello stato 404, una route registrata per quell'URL viene eseguita subito.\n\nExample: Route statiche e dinamiche\n```js\nROUTE('/products/new/', function() {\n\tconsole.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n\tconsole.log('detail', id, this.url);\n});\n\nREDIRECT('/products/new/');\nREDIRECT('/products/AB-15');\n\n// Output:\n// form\n// detail AB-15 /products/AB-15/\n```\n\nExample: Prepara una route una sola volta\n```js\nROUTE('/reports/', function() {\n\tconsole.log('reports');\n}, function(next) {\n\tconsole.log('prepare once');\n\tnext();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n\n// Output:\n// prepare once\n// reports\n// reports\n```\n\n### REDIRECT([url])\n\nType: `method`\n\nNaviga verso un URL senza ricaricare la pagina.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | L'URL di destinazione con una stringa di query facoltativa. Può contenere variabili d'ambiente come `[name]` e il valore di `DEF.root` viene aggiunto all'inizio. Il valore predefinito è l'URL corrente. |\n\nSenza un URL, la route corrente viene eseguita di nuovo. `REDIRECT('./')` fa lo stesso, `REDIRECT('../')` sale di un segmento e `REDIRECT('../../')` sale di due segmenti. Dopo i punti può seguire una stringa di query, ad esempio `REDIRECT('../?page=2')`.\n\nUna parola che inizia con `@` alla fine dell'URL è un [flag personalizzato](#custom-flag).\n\nExample: Naviga\n```js\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id, NAV.query.tab);\n});\n\nREDIRECT('/users/15/?tab=orders');\n\n// Output:\n// user 15 orders\n```\n\nExample: Sali di un livello\n```js\nROUTE('/users/', function() {\n\tconsole.log('list');\n});\n\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id);\n});\n\nREDIRECT('/users/15/');\nREDIRECT('../');\nconsole.log(NAV.url);\n\n// Output:\n// user 15\n// list\n// /users/\n```\n\n### MIDDLEWARE(name, callback)\n\nType: `method`\n\nRegistra un middleware con nome oppure esegue un elenco di middleware.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String or Array` | yes |  | Il nome del middleware o un array di nomi da eseguire. |\n| `callback` | `Function` | yes |  | Il middleware. Con un array di nomi, la funzione da chiamare alla fine. |\n\nReturns: `Object` L'oggetto `NAV`, così puoi concatenare le chiamate.\n\nUn middleware viene eseguito prima della callback della route e decide se la route continua. Dentro la callback, `this` è `NAV`. La callback riceve:\n\n| Argomento | Tipo | Descrizione |\n| --- | --- | --- |\n| `next` | Function | `next()` continua. `next(false)` e `next(new Error())` interrompono la route. |\n| `options` | Object | L'[oggetto delle opzioni](#options-object) della route. |\n| `roles` | Array | I [ruoli](#role) della route. |\n| `route` | Object | L'[oggetto route](#route-object). |\n\nLa catena si interrompe anche quando l'URL cambia mentre un middleware è al lavoro.\n\nCon un array di nomi, `MIDDLEWARE(names, callback)` esegue quei middleware uno dopo l'altro e poi chiama `callback`. Ogni middleware riceve solo `next` e i nomi sconosciuti vengono ignorati.\n\nExample: Proteggi una route\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n\tconsole.log('auth', route.id);\n\tnext(user ? undefined : false);\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, 'auth');\n\nREDIRECT('/admin/');\n\nsetTimeout(function() {\n\tuser = { name: 'Ann' };\n\tREDIRECT('/admin/');\n}, 100);\n\n// Output:\n// auth /admin/\n// auth /admin/\n// admin page\n```\n\nExample: Esegui un elenco di middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nMIDDLEWARE(['first', 'second'], function() {\n\tconsole.log('done');\n});\n\n// Output:\n// first\n// second\n// done\n```\n\n### ROUTE('/items/{name}/', callback)\n\nType: `config`\n\nUn segmento dinamico dell'URL di una route.\n\nUn segmento tra parentesi graffe corrisponde a qualsiasi valore di quel segmento. I valori vengono passati alla callback in ordine e sono disponibili in `NAV.params`. Mantengono le maiuscole e le minuscole originali. L'indirizzo deve avere lo stesso numero di segmenti della route.\n\nExample: Leggi due segmenti\n```js\nROUTE('/items/{id}/{tab}/', function(id, tab) {\n\tconsole.log(id, tab, JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/AB-1/Photos/');\n\n// Output:\n// AB-1 Photos [\"AB-1\",\"Photos\"]\n```\n\n### ROUTE(url, callback, 'name')\n\nType: `config`\n\nEsegue un middleware registrato per la route.\n\nUn nome semplice nell'argomento `middleware` di `ROUTE()` seleziona un middleware registrato con [MIDDLEWARE()](#middleware). I middleware vengono eseguiti nell'ordine indicato e un nome non registrato viene ignorato.\n\nExample: Due middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders');\n}, 'first,second');\n\nREDIRECT('/orders/');\n\n// Output:\n// first\n// second\n// orders\n```\n\n### ROUTE(url, callback, ['name', '@role'])\n\nType: `config`\n\nAggiunge un ruolo che i middleware ricevono nell'array dei ruoli.\n\nUn elemento che inizia con `@` viene passato a ogni middleware della route nell'array `roles`, senza la `@`. I ruoli non hanno alcun effetto proprio: è il middleware a decidere cosa significano.\n\nExample: Leggi i ruoli\n```js\nMIDDLEWARE('auth', function(next, options, roles) {\n\tconsole.log(roles.join());\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['auth', '@admin', '@editor']);\n\nREDIRECT('/admin/');\n\n// Output:\n// admin,editor\n// admin page\n```\n\n### ROUTE(url, callback, '#name')\n\nType: `config`\n\nCarica un elenco di codici prima della callback della route.\n\nUn elemento che inizia con `#` carica tramite `CL()` l'elenco di codici con quel nome, nella sua posizione all'interno della catena dei middleware. Vedi [Funzioni globali](../globals/).\n\nExample: Carica un elenco di codici\n```js\nCLINIT('countries', function(next) {\n\tconsole.log('loading countries');\n\tnext([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders', DEF.cl.countries.length);\n}, '#countries');\n\nREDIRECT('/orders/');\n\n// Output:\n// loading countries\n// orders 1\n```\n\n### ROUTE(url, callback, ['name', { key: value }])\n\nType: `config`\n\nPassa le opzioni ai middleware della route.\n\nUn oggetto nell'array dei middleware viene passato a ogni middleware della route come `options`. È disponibile anche in `options` dell'[oggetto route](#route-object).\n\nExample: Leggi le opzioni\n```js\nMIDDLEWARE('layout', function(next, options) {\n\tconsole.log(options.title);\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['layout', { title: 'Administration' }]);\n\nREDIRECT('/admin/');\n\n// Output:\n// Administration\n// admin page\n```\n\n### REDIRECT('/url/ @name')\n\nType: `config`\n\nEmette un evento flag durante la navigazione.\n\nUna parola che inizia con `@` viene rimossa dall'URL e l'evento `@flag name` viene emesso prima della navigazione. Vedi [Eventi](../events/).\n\nExample: Reagisci a un flag\n```js\nON('@flag audit', function() {\n\tconsole.log('audit');\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// audit\n// /orders/\n```\n\n### NAV.routes[index]\n\nType: `type`\n\nDescrive una route registrata.\n\nI middleware ricevono questo oggetto come argomento `route` e `NAV.routes` ne contiene uno per ogni route.\n\n| Proprietà | Tipo | Descrizione |\n| --- | --- | --- |\n| `id` | String | L'URL della route. |\n| `url` | Array | I segmenti dell'URL. |\n| `fn` | Function | La callback della route. |\n| `priority` | Number | La posizione nell'ordine di corrispondenza. Un numero più alto viene provato per primo. |\n| `params` | Array | Gli indici dei segmenti dinamici. |\n| `middleware` | Array | I nomi dei middleware e gli elenchi di codici, oppure `null`. |\n| `init` | Function | La funzione `init`. Diventa `null` dopo l'esecuzione. |\n| `count` | Number | Quante volte la route ha trovato corrispondenza. |\n| `pending` | Boolean | `true` mentre i middleware o `init` sono al lavoro. |\n| `options` | Object | L'[oggetto delle opzioni](#options-object). |\n| `roles` | Array | I [ruoli](#role). |\n\nExample: Ispeziona una route\n```js\nROUTE('/items/{id}/', function() {}, ['auth', '@admin', { title: 'Items' }]);\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nvar route = NAV.routes[0];\nconsole.log(route.id, JSON.stringify(route.url), JSON.stringify(route.params));\nconsole.log(JSON.stringify(route.middleware), JSON.stringify(route.roles), route.options.title);\n\n// Output:\n// /items/{id}/ [\"items\",\"{id}\"] [1]\n// [\"auth\"] [\"admin\"] Items\n```\n\n### NAV.autosave()\n\nType: `method`\n\nSalva la cronologia nello storage del browser a ogni navigazione.\n\nDopo questa chiamata, la cronologia viene memorizzata come con [NAV.save()](#nav-save) ogni volta che cambia. [NAV.load()](#nav-load) la rilegge.\n\nExample: Conserva la cronologia\n```js\nNAV.autosave();\n\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.back()\n\nType: `method`\n\nVa all'URL precedente.\n\nReturns: `Object` L'oggetto `NAV`, così puoi concatenare le chiamate.\n\nCon una cronologia vuota, va a `/`.\n\nExample: Torna indietro\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.url, NAV.next());\n\n// Output:\n// /a/ /b/\n```\n\n### NAV.clientside(selector)\n\nType: `method`\n\nTrasforma gli elementi corrispondenti in link lato client.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Un selettore jQuery dei link. |\n\nReturns: `Object` L'oggetto `NAV`, così puoi concatenare le chiamate.\n\nUn clic su un elemento corrispondente naviga con `REDIRECT()`. L'URL viene letto da `href`, `data-href` o `data-url`. I valori `#` e `javascript:void(0)` vengono ignorati. Funzionano anche gli elementi aggiunti in seguito.\n\nExample: Link\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<span class=\"link\" data-href=\"/contact/\">Contact</span>\n\n<script>\nNAV.clientside('.link');\n\nROUTE('/about/', function() {\n\tconsole.log('about');\n});\n\nROUTE('/contact/', function() {\n\tconsole.log('contact');\n});\n</script>\n\n<!-- Output:\nabout\ncontact\n-->\n```\n\n### NAV.custom()\n\nType: `method`\n\nMantiene la navigazione all'interno dell'applicazione.\n\nLe route e `REDIRECT()` funzionano come al solito e la barra degli indirizzi resta invariata. È adatto a un'applicazione incorporata in un'altra pagina. Chiamalo all'avvio dell'applicazione.\n\nExample: Naviga all'interno dell'applicazione\n```js\nNAV.custom();\n\nROUTE('/inbox/', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nREDIRECT('/inbox/');\n\n// Output:\n// inbox /inbox/\n```\n\n### NAV.forward()\n\nType: `method`\n\nVa all'URL successivo dopo essere tornato indietro.\n\nReturns: `Object` L'oggetto `NAV`, così puoi concatenare le chiamate.\n\nQuando non c'è un URL successivo, va a `/`.\n\nExample: Vai avanti\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nNAV.forward();\nconsole.log(NAV.url);\n\n// Output:\n// /b/\n```\n\n### NAV.load()\n\nType: `method`\n\nRipristina la cronologia dallo storage del browser.\n\nLegge ciò che hanno memorizzato [NAV.save()](#nav-save) o [NAV.autosave()](#nav-autosave). La navigazione successiva non aggiunge l'URL corrente alla cronologia ripristinata.\n\nExample: Ripristina la cronologia\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.location(url, [skiphistory])\n\nType: `method`\n\nEsegue la route di un URL senza cambiare la barra degli indirizzi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL da elaborare. |\n| `skiphistory` | `Boolean` | no | `false` | `true` non aggiunge l'URL corrente alla cronologia. |\n\n`NAV` viene aggiornato, gli eventi vengono emessi e la route viene eseguita, come in `REDIRECT()`. L'indirizzo nel browser non cambia.\n\nExample: Elabora gli URL\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.location('/a/');\nNAV.location('/b/');\nNAV.location('/c/', true);\n\nconsole.log(NAV.url, JSON.stringify(NAV.history));\n\n// Output:\n// a\n// /c/ [\"/a/\"]\n```\n\n### NAV.next()\n\nType: `method`\n\nRestituisce l'URL aperto da NAV.forward().\n\nReturns: `String` L'URL successivo, oppure `undefined` quando non c'è.\n\nExample: Leggi l'URL successivo\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.next());\n\n// Output:\n// /b/\n```\n\n### NAV.path(url, [delimiter])\n\nType: `method`\n\nAggiunge il delimitatore finale a un URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL. |\n| `delimiter` | `String` | no | `'/'` | Il carattere da aggiungere. |\n\nReturns: `String` L'URL con il delimitatore.\n\nUna stringa di query viene mantenuta dopo il delimitatore. Un URL che inizia con `#` viene restituito senza modifiche.\n\nExample: Normalizza gli URL\n```js\nconsole.log(NAV.path('/products'));\nconsole.log(NAV.path('/products?page=2'));\nconsole.log(NAV.path('#inbox'));\n\n// Output:\n// /products/\n// /products/?page=2\n// #inbox\n```\n\n### NAV.prev()\n\nType: `method`\n\nRestituisce l'URL aperto da NAV.back().\n\nReturns: `String` L'URL precedente, oppure `undefined` quando non c'è.\n\nExample: Leggi l'URL precedente\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nconsole.log(NAV.prev());\n\n// Output:\n// /a/\n```\n\n### NAV.redirect([url])\n\nType: `method`\n\nLa stessa funzione di REDIRECT().\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | L'URL di destinazione. Il valore predefinito è l'URL corrente. |\n\nVedi [REDIRECT()](#redirect).\n\nExample: Naviga\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.redirect('/a/');\n\n// Output:\n// a\n```\n\n### NAV.refresh()\n\nType: `method`\n\nEsegue di nuovo la route dell'URL corrente.\n\nLa cronologia non cambia.\n\nExample: Esegui di nuovo la route\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.refresh();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// a\n// a\n// []\n```\n\n### NAV.reload()\n\nType: `method`\n\nUguale a NAV.refresh().\n\nVedi [NAV.refresh()](#nav-refresh).\n\nExample: Esegui di nuovo la route\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.reload();\n\n// Output:\n// a\n// a\n```\n\n### NAV.remember(name, [value])\n\nType: `method`\n\nAggiunge un parametro di query a ogni REDIRECT() successivo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome del parametro di query. |\n| `value` | `String` | no |  | Il valore, oppure `null` per smettere. |\n\nSenza un valore, viene mantenuto il valore corrente del parametro in `NAV.query`. Il valore `null` smette di aggiungere il parametro.\n\nExample: Mantieni un parametro\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\n// Output:\n// /list/?lang=de\n// /list/\n```\n\n### NAV.remove(url)\n\nType: `method`\n\nRimuove una route.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL usato in `ROUTE()`. |\n\nReturns: `Object` L'oggetto `NAV`, così puoi concatenare le chiamate.\n\nExample: Rimuovi una route\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.remove('/a/');\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n```\n\n### NAV.save()\n\nType: `method`\n\nMemorizza la cronologia nello storage del browser una sola volta.\n\nGli URL precedenti e successivi vengono scritti in `localStorage` con la chiave `DEF.localstorage + '.nav'`.\n\nExample: Memorizza la cronologia\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nvar data = JSON.parse(localStorage.getItem(DEF.localstorage + '.nav'));\nconsole.log(JSON.stringify(data.prev));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.status(code, [data])\n\nType: `method`\n\nEmette un evento che prende il nome da un codice.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `Number or String` | yes |  | Il nome dell'evento. |\n| `data` | `Object` | no |  | L'argomento dell'evento. |\n\nReturns: `Object` L'oggetto `NAV`, così puoi concatenare le chiamate.\n\nIn questo modo un'applicazione ha un unico punto in cui gestire gli errori.\n\nExample: Segnala un errore\n```js\nON('500', function(error) {\n\tconsole.log('failed:', error);\n});\n\nNAV.status(500, 'Database is down');\n\n// Output:\n// failed: Database is down\n```\n\n### NAV.hashtags\n\nType: `property`\n\nGestisce le route con la parte hash dell'URL.\n\nReturns: `Boolean` Il valore predefinito è `false`.\n\nImpostalo su `true` all'avvio dell'applicazione. Scrivi le route con un `#` iniziale e naviga con i link o con `location.hash`.\n\nExample: Route sull'hash\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nsetTimeout(function() {\n\tlocation.hash = '#inbox';\n}, 100);\n\n// Output:\n// inbox #inbox\n```\n\n### NAV.href\n\nType: `property`\n\nL'URL passato all'ultima navigazione.\n\nReturns: `String` L'URL con la sua stringa di query.\n\nExample: Leggi l'URL\n```js\nREDIRECT('/search/?q=lamp');\nconsole.log(NAV.href);\n\n// Output:\n// /search/?q=lamp\n```\n\n### NAV.history\n\nType: `property`\n\nGli URL precedenti.\n\nReturns: `Array` Un array di stringhe.\n\nGli elementi sono path senza la stringa di query. L'ultimo elemento è il più recente.\n\nExample: Elenca gli URL precedenti\n```js\nREDIRECT('/a/?page=2');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.is404\n\nType: `property`\n\nIndica se nessuna route corrisponde all'URL corrente.\n\nReturns: `Boolean` `true` quando nessuna route corrisponde.\n\nExample: Controlla lo stato\n```js\nROUTE('/a/', function() {});\n\nREDIRECT('/missing/');\nconsole.log(NAV.is404);\n\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n// false\n```\n\n### NAV.isback\n\nType: `property`\n\nIl numero di URL a cui puoi tornare indietro.\n\nReturns: `Number` Il numero di URL precedenti.\n\nÈ un path, quindi il markup può associarsi a esso.\n\nExample: Conta gli URL precedenti\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(NAV.isback);\n\n// Output:\n// 2\n```\n\n### NAV.isforward\n\nType: `property`\n\nIl numero di URL verso cui puoi andare avanti.\n\nReturns: `Number` Il numero di URL successivi.\n\nÈ un path, quindi il markup può associarsi a esso.\n\nExample: Conta gli URL successivi\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.isforward);\n\n// Output:\n// 1\n```\n\n### NAV.middlewares\n\nType: `property`\n\nI middleware registrati.\n\nReturns: `Object` Le funzioni, con i nomi dei middleware come chiavi.\n\nExample: Elenca i nomi\n```js\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nconsole.log(Object.keys(NAV.middlewares).join());\n\n// Output:\n// auth\n```\n\n### NAV.params\n\nType: `property`\n\nI valori dei segmenti dinamici della route corrente.\n\nReturns: `Array` Un array di stringhe.\n\nÈ un path, quindi il markup può associarsi a esso.\n\nExample: Leggi i valori\n```js\nROUTE('/items/{id}/{tab}/', function() {\n\tconsole.log(JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/15/photos/');\n\n// Output:\n// [\"15\",\"photos\"]\n```\n\n### NAV.query\n\nType: `property`\n\nLa stringa di query analizzata dell'URL corrente.\n\nReturns: `Object` I parametri. Tutti i valori sono stringhe.\n\nI nomi e i valori vengono decodificati e un `+` diventa uno spazio. È un path, quindi il markup può associarsi a esso.\n\nExample: Leggi la stringa di query\n```js\nREDIRECT('/search/?q=desk+lamp&page=2');\nconsole.log(JSON.stringify(NAV.query));\n\n// Output:\n// {\"q\":\"desk lamp\",\"page\":\"2\"}\n```\n\n### NAV.queryraw\n\nType: `property`\n\nLa stringa di query come testo.\n\nReturns: `String` La stringa di query senza il `?` iniziale.\n\nExample: Leggi il testo\n```js\nREDIRECT('/search/?q=lamp&page=2');\nconsole.log(NAV.queryraw);\n\n// Output:\n// q=lamp&page=2\n```\n\n### NAV.routes\n\nType: `property`\n\nLe route registrate.\n\nReturns: `Array` Un array di oggetti route.\n\nL'array è ordinato secondo l'ordine di corrispondenza. Ogni elemento è un [oggetto route](#route-object).\n\nExample: Elenca le route\n```js\nROUTE('/items/{id}/', function() {});\nROUTE('/items/new/', function() {});\n\nconsole.log(NAV.routes.map(route => route.id).join());\n\n// Output:\n// /items/new/,/items/{id}/\n```\n\n### NAV.ua\n\nType: `property`\n\nInformazioni sul browser.\n\nReturns: `Object` L'oggetto di `MAIN.ua`.\n\nÈ lo stesso oggetto di `MAIN.ua` ed è disponibile dopo l'avvio dell'applicazione. Vedi [MAIN](../main/).\n\nExample: Confronta con MAIN\n```js\nROUTE('/', function() {\n\tconsole.log(NAV.ua === MAIN.ua);\n});\n\n// Output:\n// true\n```\n\n### NAV.url\n\nType: `property`\n\nIl path corrente senza la stringa di query.\n\nReturns: `String` Il path con uno slash finale.\n\nÈ un path, quindi il markup può associarsi a esso con `<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>`.\n\nExample: Leggi il path\n```js\nREDIRECT('/search?q=lamp');\nconsole.log(NAV.url);\n\n// Output:\n// /search/\n```\n\n### ON('location', function(url) {})\n\nType: `event`\n\nEmesso quando l'URL cambia, prima della callback della route.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Il path senza la stringa di query. |\n\nExample: Osserva la navigazione\n```js\nON('location', function(url) {\n\tconsole.log('location', url);\n});\n\nROUTE('/a/', function() {\n\tconsole.log('route');\n});\n\nREDIRECT('/a/?page=2');\n\n// Output:\n// location /a/\n// route\n```\n\n### ON('404', function() {})\n\nType: `event`\n\nEmesso quando nessuna route corrisponde all'URL.\n\nExample: Gestisci un URL sconosciuto\n```js\nON('404', function() {\n\tconsole.log('not found', NAV.url);\n});\n\nREDIRECT('/missing/');\n\n// Output:\n// not found /missing/\n```\n\n### ON('route', function(url) {})\n\nType: `event`\n\nEmesso quando viene registrata una route.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | L'URL della route. |\n\nExample: Osserva la registrazione\n```js\nON('route', function(url) {\n\tconsole.log('registered', url);\n});\n\nROUTE('/a/', function() {});\n\n// Output:\n// registered /a/\n```\n","entries":[{"type":"method","name":"ROUTE()","signature":"ROUTE(url, callback, [middleware], [init])","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT([url])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, callback)","since":"","deprecated":false},{"type":"config","name":"{name}","signature":"ROUTE('/items/{name}/', callback)","since":"","deprecated":false},{"type":"config","name":"Middleware name","signature":"ROUTE(url, callback, 'name')","since":"","deprecated":false},{"type":"config","name":"@role","signature":"ROUTE(url, callback, ['name', '@role'])","since":"","deprecated":false},{"type":"config","name":"#codelist","signature":"ROUTE(url, callback, '#name')","since":"","deprecated":false},{"type":"config","name":"Options object","signature":"ROUTE(url, callback, ['name', { key: value }])","since":"","deprecated":false},{"type":"config","name":"@flag","signature":"REDIRECT('/url/ @name')","since":"","deprecated":false},{"type":"type","name":"Route object","signature":"NAV.routes[index]","since":"","deprecated":false},{"type":"method","name":"NAV.autosave()","signature":"NAV.autosave()","since":"","deprecated":false},{"type":"method","name":"NAV.back()","signature":"NAV.back()","since":"","deprecated":false},{"type":"method","name":"NAV.clientside()","signature":"NAV.clientside(selector)","since":"","deprecated":false},{"type":"method","name":"NAV.custom()","signature":"NAV.custom()","since":"","deprecated":false},{"type":"method","name":"NAV.forward()","signature":"NAV.forward()","since":"","deprecated":false},{"type":"method","name":"NAV.load()","signature":"NAV.load()","since":"","deprecated":false},{"type":"method","name":"NAV.location()","signature":"NAV.location(url, [skiphistory])","since":"","deprecated":false},{"type":"method","name":"NAV.next()","signature":"NAV.next()","since":"","deprecated":false},{"type":"method","name":"NAV.path()","signature":"NAV.path(url, [delimiter])","since":"","deprecated":false},{"type":"method","name":"NAV.prev()","signature":"NAV.prev()","since":"","deprecated":false},{"type":"method","name":"NAV.redirect()","signature":"NAV.redirect([url])","since":"","deprecated":false},{"type":"method","name":"NAV.refresh()","signature":"NAV.refresh()","since":"","deprecated":false},{"type":"method","name":"NAV.reload()","signature":"NAV.reload()","since":"","deprecated":false},{"type":"method","name":"NAV.remember()","signature":"NAV.remember(name, [value])","since":"","deprecated":false},{"type":"method","name":"NAV.remove()","signature":"NAV.remove(url)","since":"","deprecated":false},{"type":"method","name":"NAV.save()","signature":"NAV.save()","since":"","deprecated":false},{"type":"method","name":"NAV.status()","signature":"NAV.status(code, [data])","since":"","deprecated":false},{"type":"property","name":"NAV.hashtags","signature":"NAV.hashtags","since":"","deprecated":false},{"type":"property","name":"NAV.href","signature":"NAV.href","since":"","deprecated":false},{"type":"property","name":"NAV.history","signature":"NAV.history","since":"","deprecated":false},{"type":"property","name":"NAV.is404","signature":"NAV.is404","since":"","deprecated":false},{"type":"property","name":"NAV.isback","signature":"NAV.isback","since":"","deprecated":false},{"type":"property","name":"NAV.isforward","signature":"NAV.isforward","since":"","deprecated":false},{"type":"property","name":"NAV.middlewares","signature":"NAV.middlewares","since":"","deprecated":false},{"type":"property","name":"NAV.params","signature":"NAV.params","since":"","deprecated":false},{"type":"property","name":"NAV.query","signature":"NAV.query","since":"","deprecated":false},{"type":"property","name":"NAV.queryraw","signature":"NAV.queryraw","since":"","deprecated":false},{"type":"property","name":"NAV.routes","signature":"NAV.routes","since":"","deprecated":false},{"type":"property","name":"NAV.ua","signature":"NAV.ua","since":"","deprecated":false},{"type":"property","name":"NAV.url","signature":"NAV.url","since":"","deprecated":false},{"type":"event","name":"location","signature":"ON('location', function(url) {})","since":"","deprecated":false},{"type":"event","name":"404","signature":"ON('404', function() {})","since":"","deprecated":false},{"type":"event","name":"route","signature":"ON('route', function(url) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T17:06:08.115Z"}
{"id":"JanH6T1cG61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/routing/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Smerovanie","summary":"API smerovania na strane klienta: ROUTE(), REDIRECT(), MIDDLEWARE(), objekt NAV a možnosti a udalosti rout.","markdown":"---\ntitle: Smerovanie\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/routing/\nupdated: 2026-11-18T17:06:08.115Z\n---\n\n# Smerovanie\n\n> API smerovania na strane klienta: ROUTE(), REDIRECT(), MIDDLEWARE(), objekt NAV a možnosti a udalosti rout.\n\nTieto funkcie priraďujú URL k funkciám v jednostránkovej aplikácii a `NAV` uchováva aktuálny stav navigácie. Úvod s kompletnými príkladmi nájdeš v časti [Smerovanie](../../guides/routing/).\n\n## API\n\n### ROUTE(url, callback, [middleware], [init])\n\nType: `method`\n\nZaregistruje funkciu pre URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | URL routy. Môže obsahovať dynamické segmenty ako `{id}` a premenné prostredia ako `[name]`. Pred ňu sa pridá hodnota `DEF.root`. |\n| `callback` | `Function` | yes |  | Funkcia, ktorá sa má spustiť. Dostane hodnoty dynamických segmentov. |\n| `middleware` | `String or Array` | no |  | Reťazec oddelený čiarkami alebo pole [názvov middleware](#middleware-name), [rolí](#role), [zoznamov kódov](#code-list) a [objektu možností](#options-object). Objekt možností sa prijíma iba v poli. |\n| `init` | `Function` | no |  | Funkcia, ktorá sa spustí raz, pri prvej návšteve, ešte pred middleware. Dostane `next`, ktorý musíš zavolať, aby sa pokračovalo. |\n\nReturns: `Object` Objekt `NAV`, takže volania môžeš reťaziť.\n\nRouta pre aktuálnu URL sa spustí pri štarte aplikácie. V callbacku je `this` objekt `NAV` a argumenty sú hodnoty [dynamických segmentov](#dynamic-segment).\n\nURL sa porovnáva malými písmenami, preto píš pevné segmenty malými písmenami. Chýbajúca koncová lomka sa k adrese doplní. Statická routa má prednosť pred dynamickou s rovnakým počtom segmentov a opätovná registrácia tej istej URL routu nahradí.\n\nArgumenty môžeš odovzdať aj v tomto poradí:\n\n- `ROUTE(url, middleware, callback, [init])`, pričom `middleware` je pole\n- `ROUTE(url, callback, init, [middleware])`\n\nKeď je aktuálna URL v stave 404, routa zaregistrovaná pre ňu sa spustí okamžite.\n\nExample: Statické a dynamické routy\n```js\nROUTE('/products/new/', function() {\n\tconsole.log('form');\n});\n\nROUTE('/products/{id}/', function(id) {\n\tconsole.log('detail', id, this.url);\n});\n\nREDIRECT('/products/new/');\nREDIRECT('/products/AB-15');\n\n// Output:\n// form\n// detail AB-15 /products/AB-15/\n```\n\nExample: Priprav routu raz\n```js\nROUTE('/reports/', function() {\n\tconsole.log('reports');\n}, function(next) {\n\tconsole.log('prepare once');\n\tnext();\n});\n\nREDIRECT('/reports/');\nREDIRECT('/');\nREDIRECT('/reports/');\n\n// Output:\n// prepare once\n// reports\n// reports\n```\n\n### REDIRECT([url])\n\nType: `method`\n\nPrejde na URL bez opätovného načítania stránky.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | Cieľová URL s voliteľným reťazcom dotazu. Môže obsahovať premenné prostredia ako `[name]` a pred ňu sa pridá hodnota `DEF.root`. Predvolená hodnota je aktuálna URL. |\n\nBez URL sa znova spustí aktuálna routa. `REDIRECT('./')` robí to isté, `REDIRECT('../')` prejde o jeden segment vyššie a `REDIRECT('../../')` o dva segmenty vyššie. Za bodkami môže nasledovať reťazec dotazu, napríklad `REDIRECT('../?page=2')`.\n\nSlovo začínajúce znakom `@` na konci URL je [vlastný flag](#custom-flag).\n\nExample: Naviguj\n```js\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id, NAV.query.tab);\n});\n\nREDIRECT('/users/15/?tab=orders');\n\n// Output:\n// user 15 orders\n```\n\nExample: Prejdi o úroveň vyššie\n```js\nROUTE('/users/', function() {\n\tconsole.log('list');\n});\n\nROUTE('/users/{id}/', function(id) {\n\tconsole.log('user', id);\n});\n\nREDIRECT('/users/15/');\nREDIRECT('../');\nconsole.log(NAV.url);\n\n// Output:\n// user 15\n// list\n// /users/\n```\n\n### MIDDLEWARE(name, callback)\n\nType: `method`\n\nZaregistruje pomenovaný middleware alebo spustí zoznam middleware.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String or Array` | yes |  | Názov middleware alebo pole názvov, ktoré sa majú spustiť. |\n| `callback` | `Function` | yes |  | Middleware. Pri poli názvov funkcia, ktorá sa zavolá na konci. |\n\nReturns: `Object` Objekt `NAV`, takže volania môžeš reťaziť.\n\nMiddleware sa spustí pred callbackom routy a rozhodne, či routa pokračuje. V callbacku je `this` objekt `NAV`. Callback dostane:\n\n| Argument | Typ | Popis |\n| --- | --- | --- |\n| `next` | Function | `next()` pokračuje. `next(false)` a `next(new Error())` routu zastavia. |\n| `options` | Object | [Objekt možností](#options-object) routy. |\n| `roles` | Array | [Roly](#role) routy. |\n| `route` | Object | [Objekt routy](#route-object). |\n\nReťazec sa zastaví aj vtedy, keď sa URL zmení počas práce middleware.\n\nS poľom názvov spustí `MIDDLEWARE(names, callback)` tieto middleware jeden po druhom a potom zavolá `callback`. Každý middleware dostane iba `next` a neznáme názvy sa preskočia.\n\nExample: Ochráň routu\n```js\nvar user = null;\n\nMIDDLEWARE('auth', function(next, options, roles, route) {\n\tconsole.log('auth', route.id);\n\tnext(user ? undefined : false);\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, 'auth');\n\nREDIRECT('/admin/');\n\nsetTimeout(function() {\n\tuser = { name: 'Ann' };\n\tREDIRECT('/admin/');\n}, 100);\n\n// Output:\n// auth /admin/\n// auth /admin/\n// admin page\n```\n\nExample: Spusti zoznam middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nMIDDLEWARE(['first', 'second'], function() {\n\tconsole.log('done');\n});\n\n// Output:\n// first\n// second\n// done\n```\n\n### ROUTE('/items/{name}/', callback)\n\nType: `config`\n\nDynamický segment URL routy.\n\nSegment v zložených zátvorkách zodpovedá ľubovoľnej hodnote daného segmentu. Hodnoty sa odovzdávajú callbacku v poradí a sú dostupné v `NAV.params`. Zachovávajú si pôvodnú veľkosť písmen. Adresa musí mať rovnaký počet segmentov ako routa.\n\nExample: Prečítaj dva segmenty\n```js\nROUTE('/items/{id}/{tab}/', function(id, tab) {\n\tconsole.log(id, tab, JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/AB-1/Photos/');\n\n// Output:\n// AB-1 Photos [\"AB-1\",\"Photos\"]\n```\n\n### ROUTE(url, callback, 'name')\n\nType: `config`\n\nSpustí pre routu zaregistrovaný middleware.\n\nObyčajný názov v argumente `middleware` funkcie `ROUTE()` vyberie middleware zaregistrovaný pomocou [MIDDLEWARE()](#middleware). Middleware sa spúšťajú v uvedenom poradí a názov, ktorý nie je zaregistrovaný, sa preskočí.\n\nExample: Dva middleware\n```js\nMIDDLEWARE('first', function(next) {\n\tconsole.log('first');\n\tnext();\n});\n\nMIDDLEWARE('second', function(next) {\n\tconsole.log('second');\n\tnext();\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders');\n}, 'first,second');\n\nREDIRECT('/orders/');\n\n// Output:\n// first\n// second\n// orders\n```\n\n### ROUTE(url, callback, ['name', '@role'])\n\nType: `config`\n\nPridá rolu, ktorú middleware dostanú v poli rolí.\n\nPoložka začínajúca znakom `@` sa odovzdá každému middleware routy v poli `roles`, a to bez `@`. Roly samy osebe nič nerobia: o ich význame rozhoduje middleware.\n\nExample: Prečítaj roly\n```js\nMIDDLEWARE('auth', function(next, options, roles) {\n\tconsole.log(roles.join());\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['auth', '@admin', '@editor']);\n\nREDIRECT('/admin/');\n\n// Output:\n// admin,editor\n// admin page\n```\n\n### ROUTE(url, callback, '#name')\n\nType: `config`\n\nNačíta zoznam kódov pred callbackom routy.\n\nPoložka začínajúca znakom `#` načíta zoznam kódov s týmto názvom pomocou `CL()`, a to na svojom mieste v reťazci middleware. Pozri [Globálne funkcie](../globals/).\n\nExample: Načítaj zoznam kódov\n```js\nCLINIT('countries', function(next) {\n\tconsole.log('loading countries');\n\tnext([{ id: 'sk', name: 'Slovakia' }]);\n});\n\nROUTE('/orders/', function() {\n\tconsole.log('orders', DEF.cl.countries.length);\n}, '#countries');\n\nREDIRECT('/orders/');\n\n// Output:\n// loading countries\n// orders 1\n```\n\n### ROUTE(url, callback, ['name', { key: value }])\n\nType: `config`\n\nOdovzdá možnosti middleware routy.\n\nObjekt v poli middleware sa odovzdá každému middleware routy ako `options`. Je dostupný aj v `options` [objektu routy](#route-object).\n\nExample: Prečítaj možnosti\n```js\nMIDDLEWARE('layout', function(next, options) {\n\tconsole.log(options.title);\n\tnext();\n});\n\nROUTE('/admin/', function() {\n\tconsole.log('admin page');\n}, ['layout', { title: 'Administration' }]);\n\nREDIRECT('/admin/');\n\n// Output:\n// Administration\n// admin page\n```\n\n### REDIRECT('/url/ @name')\n\nType: `config`\n\nPri navigácii vyvolá udalosť flagu.\n\nSlovo začínajúce znakom `@` sa z URL odstráni a pred navigáciou sa vyvolá udalosť `@flag name`. Pozri [Udalosti](../events/).\n\nExample: Zareaguj na flag\n```js\nON('@flag audit', function() {\n\tconsole.log('audit');\n});\n\nROUTE('/orders/', function() {\n\tconsole.log(NAV.url);\n});\n\nREDIRECT('/orders/ @audit');\n\n// Output:\n// audit\n// /orders/\n```\n\n### NAV.routes[index]\n\nType: `type`\n\nPopisuje jednu zaregistrovanú routu.\n\nMiddleware dostanú tento objekt ako argument `route` a `NAV.routes` obsahuje jeden pre každú routu.\n\n| Vlastnosť | Typ | Popis |\n| --- | --- | --- |\n| `id` | String | URL routy. |\n| `url` | Array | Segmenty URL. |\n| `fn` | Function | Callback routy. |\n| `priority` | Number | Pozícia v poradí porovnávania. Vyššie číslo sa skúša ako prvé. |\n| `params` | Array | Indexy dynamických segmentov. |\n| `middleware` | Array | Názvy middleware a zoznamy kódov alebo `null`. |\n| `init` | Function | Funkcia `init`. Po spustení je `null`. |\n| `count` | Number | Koľkokrát sa routa zhodovala. |\n| `pending` | Boolean | `true`, kým pracujú middleware alebo `init`. |\n| `options` | Object | [Objekt možností](#options-object). |\n| `roles` | Array | [Roly](#role). |\n\nExample: Preskúmaj routu\n```js\nROUTE('/items/{id}/', function() {}, ['auth', '@admin', { title: 'Items' }]);\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nvar route = NAV.routes[0];\nconsole.log(route.id, JSON.stringify(route.url), JSON.stringify(route.params));\nconsole.log(JSON.stringify(route.middleware), JSON.stringify(route.roles), route.options.title);\n\n// Output:\n// /items/{id}/ [\"items\",\"{id}\"] [1]\n// [\"auth\"] [\"admin\"] Items\n```\n\n### NAV.autosave()\n\nType: `method`\n\nPri každej navigácii uloží históriu do úložiska prehliadača.\n\nPo tomto volaní sa história pri každej zmene ukladá rovnakým spôsobom ako pri [NAV.save()](#nav-save). [NAV.load()](#nav-load) ju načíta späť.\n\nExample: Zachovaj históriu\n```js\nNAV.autosave();\n\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.back()\n\nType: `method`\n\nPrejde na predchádzajúcu URL.\n\nReturns: `Object` Objekt `NAV`, takže volania môžeš reťaziť.\n\nPri prázdnej histórii prejde na `/`.\n\nExample: Vráť sa späť\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.url, NAV.next());\n\n// Output:\n// /a/ /b/\n```\n\n### NAV.clientside(selector)\n\nType: `method`\n\nZmení zodpovedajúce prvky na odkazy na strane klienta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | yes |  | Selektor jQuery pre odkazy. |\n\nReturns: `Object` Objekt `NAV`, takže volania môžeš reťaziť.\n\nKliknutie na zodpovedajúci prvok spustí navigáciu pomocou `REDIRECT()`. URL sa číta z `href`, `data-href` alebo `data-url`. Hodnoty `#` a `javascript:void(0)` sa ignorujú. Fungujú aj prvky pridané neskôr.\n\nExample: Odkazy\n```html\n<a class=\"link\" href=\"/about/\">About</a>\n<span class=\"link\" data-href=\"/contact/\">Contact</span>\n\n<script>\nNAV.clientside('.link');\n\nROUTE('/about/', function() {\n\tconsole.log('about');\n});\n\nROUTE('/contact/', function() {\n\tconsole.log('contact');\n});\n</script>\n\n<!-- Output:\nabout\ncontact\n-->\n```\n\n### NAV.custom()\n\nType: `method`\n\nUdržiava navigáciu vnútri aplikácie.\n\nRouty a `REDIRECT()` fungujú ako obvykle a panel s adresou zostáva bez zmeny. Hodí sa to pre aplikáciu vloženú do inej stránky. Zavolaj to pri štarte aplikácie.\n\nExample: Naviguj vnútri aplikácie\n```js\nNAV.custom();\n\nROUTE('/inbox/', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nREDIRECT('/inbox/');\n\n// Output:\n// inbox /inbox/\n```\n\n### NAV.forward()\n\nType: `method`\n\nPo návrate späť prejde na nasledujúcu URL.\n\nReturns: `Object` Objekt `NAV`, takže volania môžeš reťaziť.\n\nKeď nasledujúca URL neexistuje, prejde na `/`.\n\nExample: Prejdi dopredu\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nNAV.forward();\nconsole.log(NAV.url);\n\n// Output:\n// /b/\n```\n\n### NAV.load()\n\nType: `method`\n\nObnoví históriu z úložiska prehliadača.\n\nNačíta to, čo uložili [NAV.save()](#nav-save) alebo [NAV.autosave()](#nav-autosave). Ďalšia navigácia nepridá aktuálnu URL do obnovenej histórie.\n\nExample: Obnov históriu\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nNAV.history.length = 0;\nNAV.load();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.location(url, [skiphistory])\n\nType: `method`\n\nSpustí routu pre URL bez zmeny panela s adresou.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | URL na spracovanie. |\n| `skiphistory` | `Boolean` | no | `false` | `true` nepridá aktuálnu URL do histórie. |\n\n`NAV` sa aktualizuje, vyvolajú sa udalosti a routa sa spustí rovnako ako pri `REDIRECT()`. Adresa v prehliadači sa nezmení.\n\nExample: Spracuj URL\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.location('/a/');\nNAV.location('/b/');\nNAV.location('/c/', true);\n\nconsole.log(NAV.url, JSON.stringify(NAV.history));\n\n// Output:\n// a\n// /c/ [\"/a/\"]\n```\n\n### NAV.next()\n\nType: `method`\n\nVráti URL, ktorú otvorí NAV.forward().\n\nReturns: `String` Nasledujúca URL alebo `undefined`, ak žiadna neexistuje.\n\nExample: Prečítaj nasledujúcu URL\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.next());\n\n// Output:\n// /b/\n```\n\n### NAV.path(url, [delimiter])\n\nType: `method`\n\nPridá k URL koncový oddeľovač.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | URL. |\n| `delimiter` | `String` | no | `'/'` | Znak, ktorý sa má pridať. |\n\nReturns: `String` URL s oddeľovačom.\n\nReťazec dotazu sa zachová za oddeľovačom. URL začínajúca znakom `#` sa vráti nezmenená.\n\nExample: Normalizuj URL\n```js\nconsole.log(NAV.path('/products'));\nconsole.log(NAV.path('/products?page=2'));\nconsole.log(NAV.path('#inbox'));\n\n// Output:\n// /products/\n// /products/?page=2\n// #inbox\n```\n\n### NAV.prev()\n\nType: `method`\n\nVráti URL, ktorú otvorí NAV.back().\n\nReturns: `String` Predchádzajúca URL alebo `undefined`, ak žiadna neexistuje.\n\nExample: Prečítaj predchádzajúcu URL\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nconsole.log(NAV.prev());\n\n// Output:\n// /a/\n```\n\n### NAV.redirect([url])\n\nType: `method`\n\nRovnaká funkcia ako REDIRECT().\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | no |  | Cieľová URL. Predvolená hodnota je aktuálna URL. |\n\nPozri [REDIRECT()](#redirect).\n\nExample: Naviguj\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.redirect('/a/');\n\n// Output:\n// a\n```\n\n### NAV.refresh()\n\nType: `method`\n\nZnova spustí routu aktuálnej URL.\n\nHistória sa nezmení.\n\nExample: Spusti routu znova\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.refresh();\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// a\n// a\n// []\n```\n\n### NAV.reload()\n\nType: `method`\n\nTo isté ako NAV.refresh().\n\nPozri [NAV.refresh()](#nav-refresh).\n\nExample: Spusti routu znova\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nREDIRECT('/a/');\nNAV.reload();\n\n// Output:\n// a\n// a\n```\n\n### NAV.remember(name, [value])\n\nType: `method`\n\nPridá parameter dotazu ku každému ďalšiemu REDIRECT().\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov parametra dotazu. |\n| `value` | `String` | no |  | Hodnota alebo `null` na ukončenie. |\n\nBez hodnoty sa zachová aktuálna hodnota parametra v `NAV.query`. Hodnota `null` pridávanie parametra ukončí.\n\nExample: Zachovaj parameter\n```js\nNAV.remember('lang', 'de');\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\nNAV.remember('lang', null);\nREDIRECT('/list/');\nconsole.log(NAV.href);\n\n// Output:\n// /list/?lang=de\n// /list/\n```\n\n### NAV.remove(url)\n\nType: `method`\n\nOdstráni routu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | URL použitá v `ROUTE()`. |\n\nReturns: `Object` Objekt `NAV`, takže volania môžeš reťaziť.\n\nExample: Odstráň routu\n```js\nROUTE('/a/', function() {\n\tconsole.log('a');\n});\n\nNAV.remove('/a/');\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n```\n\n### NAV.save()\n\nType: `method`\n\nJednorazovo uloží históriu do úložiska prehliadača.\n\nPredchádzajúce a nasledujúce URL sa zapíšu do `localStorage` pod kľúčom `DEF.localstorage + '.nav'`.\n\nExample: Ulož históriu\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nNAV.save();\n\nvar data = JSON.parse(localStorage.getItem(DEF.localstorage + '.nav'));\nconsole.log(JSON.stringify(data.prev));\n\n// Output:\n// [\"/a/\"]\n```\n\n### NAV.status(code, [data])\n\nType: `method`\n\nVyvolá udalosť pomenovanú podľa kódu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `code` | `Number or String` | yes |  | Názov udalosti. |\n| `data` | `Object` | no |  | Argument udalosti. |\n\nReturns: `Object` Objekt `NAV`, takže volania môžeš reťaziť.\n\nAplikácia tak má jedno miesto na spracovanie chýb.\n\nExample: Nahlás chybu\n```js\nON('500', function(error) {\n\tconsole.log('failed:', error);\n});\n\nNAV.status(500, 'Database is down');\n\n// Output:\n// failed: Database is down\n```\n\n### NAV.hashtags\n\nType: `property`\n\nRiadi routy pomocou hash časti URL.\n\nReturns: `Boolean` Predvolená hodnota je `false`.\n\nNastav to na `true` pri štarte aplikácie. Routy píš s úvodným `#` a naviguj pomocou odkazov alebo `location.hash`.\n\nExample: Routy na hashi\n```js\nNAV.hashtags = true;\n\nROUTE('#inbox', function() {\n\tconsole.log('inbox', NAV.url);\n});\n\nsetTimeout(function() {\n\tlocation.hash = '#inbox';\n}, 100);\n\n// Output:\n// inbox #inbox\n```\n\n### NAV.href\n\nType: `property`\n\nURL odovzdaná pri poslednej navigácii.\n\nReturns: `String` URL s reťazcom dotazu.\n\nExample: Prečítaj URL\n```js\nREDIRECT('/search/?q=lamp');\nconsole.log(NAV.href);\n\n// Output:\n// /search/?q=lamp\n```\n\n### NAV.history\n\nType: `property`\n\nPredchádzajúce URL.\n\nReturns: `Array` Pole reťazcov.\n\nPoložky sú path bez reťazca dotazu. Posledná položka je najnovšia.\n\nExample: Vypíš predchádzajúce URL\n```js\nREDIRECT('/a/?page=2');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(JSON.stringify(NAV.history));\n\n// Output:\n// [\"/a/\",\"/b/\"]\n```\n\n### NAV.is404\n\nType: `property`\n\nUdáva, či aktuálnej URL nezodpovedá žiadna routa.\n\nReturns: `Boolean` `true`, keď nezodpovedá žiadna routa.\n\nExample: Skontroluj stav\n```js\nROUTE('/a/', function() {});\n\nREDIRECT('/missing/');\nconsole.log(NAV.is404);\n\nREDIRECT('/a/');\nconsole.log(NAV.is404);\n\n// Output:\n// true\n// false\n```\n\n### NAV.isback\n\nType: `property`\n\nPočet URL, na ktoré sa dá vrátiť späť.\n\nReturns: `Number` Počet predchádzajúcich URL.\n\nJe to path, takže sa naň môže značkovanie naviazať.\n\nExample: Spočítaj predchádzajúce URL\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\nREDIRECT('/c/');\n\nconsole.log(NAV.isback);\n\n// Output:\n// 2\n```\n\n### NAV.isforward\n\nType: `property`\n\nPočet URL, na ktoré sa dá prejsť dopredu.\n\nReturns: `Number` Počet nasledujúcich URL.\n\nJe to path, takže sa naň môže značkovanie naviazať.\n\nExample: Spočítaj nasledujúce URL\n```js\nREDIRECT('/a/');\nREDIRECT('/b/');\n\nNAV.back();\nconsole.log(NAV.isforward);\n\n// Output:\n// 1\n```\n\n### NAV.middlewares\n\nType: `property`\n\nZaregistrované middleware.\n\nReturns: `Object` Funkcie, pričom kľúče sú názvy middleware.\n\nExample: Vypíš názvy\n```js\nMIDDLEWARE('auth', function(next) {\n\tnext();\n});\n\nconsole.log(Object.keys(NAV.middlewares).join());\n\n// Output:\n// auth\n```\n\n### NAV.params\n\nType: `property`\n\nHodnoty dynamických segmentov aktuálnej routy.\n\nReturns: `Array` Pole reťazcov.\n\nJe to path, takže sa naň môže značkovanie naviazať.\n\nExample: Prečítaj hodnoty\n```js\nROUTE('/items/{id}/{tab}/', function() {\n\tconsole.log(JSON.stringify(NAV.params));\n});\n\nREDIRECT('/items/15/photos/');\n\n// Output:\n// [\"15\",\"photos\"]\n```\n\n### NAV.query\n\nType: `property`\n\nSpracovaný reťazec dotazu aktuálnej URL.\n\nReturns: `Object` Parametre. Všetky hodnoty sú reťazce.\n\nNázvy a hodnoty sú dekódované a `+` sa zmení na medzeru. Je to path, takže sa naň môže značkovanie naviazať.\n\nExample: Prečítaj reťazec dotazu\n```js\nREDIRECT('/search/?q=desk+lamp&page=2');\nconsole.log(JSON.stringify(NAV.query));\n\n// Output:\n// {\"q\":\"desk lamp\",\"page\":\"2\"}\n```\n\n### NAV.queryraw\n\nType: `property`\n\nReťazec dotazu ako text.\n\nReturns: `String` Reťazec dotazu bez úvodného `?`.\n\nExample: Prečítaj text\n```js\nREDIRECT('/search/?q=lamp&page=2');\nconsole.log(NAV.queryraw);\n\n// Output:\n// q=lamp&page=2\n```\n\n### NAV.routes\n\nType: `property`\n\nZaregistrované routy.\n\nReturns: `Array` Pole objektov rout.\n\nPole je zoradené v poradí porovnávania. Každá položka je [objekt routy](#route-object).\n\nExample: Vypíš routy\n```js\nROUTE('/items/{id}/', function() {});\nROUTE('/items/new/', function() {});\n\nconsole.log(NAV.routes.map(route => route.id).join());\n\n// Output:\n// /items/new/,/items/{id}/\n```\n\n### NAV.ua\n\nType: `property`\n\nInformácie o prehliadači.\n\nReturns: `Object` Objekt `MAIN.ua`.\n\nJe to ten istý objekt ako `MAIN.ua` a je dostupný po spustení aplikácie. Pozri [MAIN](../main/).\n\nExample: Porovnaj s MAIN\n```js\nROUTE('/', function() {\n\tconsole.log(NAV.ua === MAIN.ua);\n});\n\n// Output:\n// true\n```\n\n### NAV.url\n\nType: `property`\n\nAktuálny path bez reťazca dotazu.\n\nReturns: `String` Path s koncovou lomkou.\n\nJe to path, takže sa naň môže značkovanie naviazať pomocou `<ui-bind path=\"NAV.url\" config=\"text\"></ui-bind>`.\n\nExample: Prečítaj path\n```js\nREDIRECT('/search?q=lamp');\nconsole.log(NAV.url);\n\n// Output:\n// /search/\n```\n\n### ON('location', function(url) {})\n\nType: `event`\n\nVyvolá sa pri zmene URL, pred callbackom routy.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | Path bez reťazca dotazu. |\n\nExample: Sleduj navigáciu\n```js\nON('location', function(url) {\n\tconsole.log('location', url);\n});\n\nROUTE('/a/', function() {\n\tconsole.log('route');\n});\n\nREDIRECT('/a/?page=2');\n\n// Output:\n// location /a/\n// route\n```\n\n### ON('404', function() {})\n\nType: `event`\n\nVyvolá sa, keď URL nezodpovedá žiadna routa.\n\nExample: Spracuj neznámu URL\n```js\nON('404', function() {\n\tconsole.log('not found', NAV.url);\n});\n\nREDIRECT('/missing/');\n\n// Output:\n// not found /missing/\n```\n\n### ON('route', function(url) {})\n\nType: `event`\n\nVyvolá sa pri registrácii routy.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `url` | `String` | yes |  | URL routy. |\n\nExample: Sleduj registráciu\n```js\nON('route', function(url) {\n\tconsole.log('registered', url);\n});\n\nROUTE('/a/', function() {});\n\n// Output:\n// registered /a/\n```\n","entries":[{"type":"method","name":"ROUTE()","signature":"ROUTE(url, callback, [middleware], [init])","since":"","deprecated":false},{"type":"method","name":"REDIRECT()","signature":"REDIRECT([url])","since":"","deprecated":false},{"type":"method","name":"MIDDLEWARE()","signature":"MIDDLEWARE(name, callback)","since":"","deprecated":false},{"type":"config","name":"{name}","signature":"ROUTE('/items/{name}/', callback)","since":"","deprecated":false},{"type":"config","name":"Middleware name","signature":"ROUTE(url, callback, 'name')","since":"","deprecated":false},{"type":"config","name":"@role","signature":"ROUTE(url, callback, ['name', '@role'])","since":"","deprecated":false},{"type":"config","name":"#codelist","signature":"ROUTE(url, callback, '#name')","since":"","deprecated":false},{"type":"config","name":"Options object","signature":"ROUTE(url, callback, ['name', { key: value }])","since":"","deprecated":false},{"type":"config","name":"@flag","signature":"REDIRECT('/url/ @name')","since":"","deprecated":false},{"type":"type","name":"Route object","signature":"NAV.routes[index]","since":"","deprecated":false},{"type":"method","name":"NAV.autosave()","signature":"NAV.autosave()","since":"","deprecated":false},{"type":"method","name":"NAV.back()","signature":"NAV.back()","since":"","deprecated":false},{"type":"method","name":"NAV.clientside()","signature":"NAV.clientside(selector)","since":"","deprecated":false},{"type":"method","name":"NAV.custom()","signature":"NAV.custom()","since":"","deprecated":false},{"type":"method","name":"NAV.forward()","signature":"NAV.forward()","since":"","deprecated":false},{"type":"method","name":"NAV.load()","signature":"NAV.load()","since":"","deprecated":false},{"type":"method","name":"NAV.location()","signature":"NAV.location(url, [skiphistory])","since":"","deprecated":false},{"type":"method","name":"NAV.next()","signature":"NAV.next()","since":"","deprecated":false},{"type":"method","name":"NAV.path()","signature":"NAV.path(url, [delimiter])","since":"","deprecated":false},{"type":"method","name":"NAV.prev()","signature":"NAV.prev()","since":"","deprecated":false},{"type":"method","name":"NAV.redirect()","signature":"NAV.redirect([url])","since":"","deprecated":false},{"type":"method","name":"NAV.refresh()","signature":"NAV.refresh()","since":"","deprecated":false},{"type":"method","name":"NAV.reload()","signature":"NAV.reload()","since":"","deprecated":false},{"type":"method","name":"NAV.remember()","signature":"NAV.remember(name, [value])","since":"","deprecated":false},{"type":"method","name":"NAV.remove()","signature":"NAV.remove(url)","since":"","deprecated":false},{"type":"method","name":"NAV.save()","signature":"NAV.save()","since":"","deprecated":false},{"type":"method","name":"NAV.status()","signature":"NAV.status(code, [data])","since":"","deprecated":false},{"type":"property","name":"NAV.hashtags","signature":"NAV.hashtags","since":"","deprecated":false},{"type":"property","name":"NAV.href","signature":"NAV.href","since":"","deprecated":false},{"type":"property","name":"NAV.history","signature":"NAV.history","since":"","deprecated":false},{"type":"property","name":"NAV.is404","signature":"NAV.is404","since":"","deprecated":false},{"type":"property","name":"NAV.isback","signature":"NAV.isback","since":"","deprecated":false},{"type":"property","name":"NAV.isforward","signature":"NAV.isforward","since":"","deprecated":false},{"type":"property","name":"NAV.middlewares","signature":"NAV.middlewares","since":"","deprecated":false},{"type":"property","name":"NAV.params","signature":"NAV.params","since":"","deprecated":false},{"type":"property","name":"NAV.query","signature":"NAV.query","since":"","deprecated":false},{"type":"property","name":"NAV.queryraw","signature":"NAV.queryraw","since":"","deprecated":false},{"type":"property","name":"NAV.routes","signature":"NAV.routes","since":"","deprecated":false},{"type":"property","name":"NAV.ua","signature":"NAV.ua","since":"","deprecated":false},{"type":"property","name":"NAV.url","signature":"NAV.url","since":"","deprecated":false},{"type":"event","name":"location","signature":"ON('location', function(url) {})","since":"","deprecated":false},{"type":"event","name":"404","signature":"ON('404', function() {})","since":"","deprecated":false},{"type":"event","name":"route","signature":"ON('route', function(url) {})","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T17:06:08.115Z"}
{"id":"JamcYF9Mo61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/string/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"String","summary":"Methods that jComponent adds to String.prototype for formatting, parsing, validating and cleaning text.","markdown":"---\ntitle: String\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/string/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# String\n\n> Methods that jComponent adds to String.prototype for formatting, parsing, validating and cleaning text.\n\njComponent adds these methods to every string. Number and date output follows the settings in [DEF](../def/), values in `[key]` form come from [ENV()](../globals/), and the methods that read component configuration are used in [Creating components](../../guides/creating-components/).\n\n## API\n\n### String.args(obj, [encode])\n\nType: `method`\n\nReplaces `{key}` and `{{ key }}` placeholders with values from an object.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | The values for the placeholders. |\n| `encode` | `String or Function` | no |  | How to write each value: `json` for `JSON.stringify()`, `encode` for `encodeURIComponent()`, `escape` for HTML entities, or a function `(value, key)` that returns the text. |\n\nReturns: `String` The string with the placeholders replaced.\n\nA key can be a nested path such as `user.age`. Without `encode`, a key that is not in the object keeps its placeholder and a `null` value becomes an empty string.\n\nExample: Placeholders\n```js\nconsole.log('Hello {name}, age {{ user.age }}, {unknown}'.args({ name: 'Ana', user: { age: 30 } })); // Hello Ana, age 30, {unknown}\n```\n\nExample: Encoding the values\n```js\nconsole.log('{a}'.args({ a: '<b>' }, 'escape')); // &lt;b&gt;\nconsole.log('{a}'.args({ a: 'x y' }, 'encode')); // x%20y\nconsole.log('{a}'.args({ a: 'x' }, 'json')); // \"x\"\nconsole.log('{a}|{b}'.args({ a: 1, b: 2 }, (value, key) => key + '=' + value)); // a=1|b=2\n```\n\n### String.encode()\n\nType: `method`\n\nEscapes the characters `<`, `>`, `&` and `\"` as HTML entities.\n\nReturns: `String` The escaped text.\n\nExample: Escaping HTML\n```js\nconsole.log('<a href=\"x\">T&C</a>'.encode()); // &lt;a href=&quot;x&quot;&gt;T&amp;C&lt;/a&gt;\n```\n\n### String.env()\n\nType: `method`\n\nReplaces `[key]` phrases with values from the environment.\n\nReturns: `String` The string with the known phrases replaced.\n\nA `[key]` phrase reads the value set with [ENV()](../globals/). A phrase that starts with a dot, such as `[.app.name]`, reads a path from `window`. A phrase with no value stays in the text.\n\nExample: Environment values\n```js\nENV('name', 'Peter');\nwindow.app = { version: 5 };\nconsole.log('[name] [.app.version] [missing]'.env()); // Peter 5 [missing]\n```\n\n### String.flags([path])\n\nType: `method`\n\nRemoves `@name` flags from the text and emits an event for each flag that has a listener.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | The value passed to the event listeners. |\n\nReturns: `String` The trimmed text without the flags.\n\nEach flag emits the event `@flag name` with `path` as its argument. See [Flags and path modifiers](../../guides/flags/).\n\nExample: Reading flags\n```js\nvar seen = [];\nON('@flag reset', path => seen.push(path));\nconsole.log('form.name @reset @other'.flags('form.name')); // form.name\nconsole.log(seen); // [\"form.name\"]\n```\n\n### String.format([value0], [value1], [...])\n\nType: `method`\n\nReplaces the indexes `{0}`, `{1}` and so on with the arguments.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value0` | `Object` | no |  | The value for `{0}`. Each further argument fills the next index. |\n\nReturns: `String` The formatted text.\n\nAn array argument is joined without a separator. A missing or `null` argument becomes an empty string.\n\nExample: Indexed values\n```js\nconsole.log('Hello {0}, you have {1} items{2}'.format('Ana', 3)); // Hello Ana, you have 3 items\nconsole.log('{0}'.format(['a', 'b'])); // ab\n```\n\n### String.isEmail()\n\nType: `method`\n\nChecks that the string is an email address.\n\nReturns: `Boolean` `true` for a valid address.\n\nThe test uses the pattern in `DEF.regexp.email`.\n\nExample: Checking addresses\n```js\nconsole.log('peter+news@total-js.com'.isEmail()); // true\nconsole.log('a@b'.isEmail()); // false\n```\n\n### String.isJSONDate()\n\nType: `method`\n\nChecks that the string is a date serialized to JSON.\n\nReturns: `Boolean` `true` for a value in the form `2026-11-18T10:00:00.000Z`.\n\nExample: Checking dates\n```js\nconsole.log('2026-11-18T10:00:00.000Z'.isJSONDate()); // true\nconsole.log('2026-11-18'.isJSONDate()); // false\n```\n\n### String.isPhone()\n\nType: `method`\n\nChecks that the string is a phone number.\n\nReturns: `Boolean` `true` for a valid number.\n\nThe test uses the pattern in `DEF.regexp.phone`: an optional `+`, then groups of three, three and four to eight digits. The groups can be separated by a space, a dash or a dot, and the first can be in parentheses.\n\nExample: Checking numbers\n```js\nconsole.log('+421903123456'.isPhone()); // true\nconsole.log('(421) 903-1234'.isPhone()); // true\nconsole.log('12345'.isPhone()); // false\n```\n\n### String.isURL()\n\nType: `method`\n\nChecks that the string is an `http` or `https` address.\n\nReturns: `Boolean` `true` for a valid address.\n\nThe test uses the pattern in `DEF.regexp.url`.\n\nExample: Checking addresses\n```js\nconsole.log('https://www.totaljs.com/'.isURL()); // true\nconsole.log('ftp://totaljs.com/file'.isURL()); // false\nconsole.log('totaljs.com'.isURL()); // false\n```\n\n### String.padLeft(length, [char])\n\nType: `method`\n\nFills the start of the string up to a length.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | The final length. |\n| `char` | `String` | no | `a space` | The fill character. |\n\nReturns: `String` The padded text.\n\nA string that is already long enough is returned unchanged.\n\nExample: Padding\n```js\nconsole.log('7'.padLeft(3, '0')); // 007\nconsole.log('abcd'.padLeft(2, '0')); // abcd\n```\n\n### String.padRight(length, [char])\n\nType: `method`\n\nFills the end of the string up to a length.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | The final length. |\n| `char` | `String` | no | `a space` | The fill character. |\n\nReturns: `String` The padded text.\n\nA string that is already long enough is returned unchanged.\n\nExample: Padding\n```js\nconsole.log('7'.padRight(3, '-')); // 7--\n```\n\n### String.parseComponent(tags)\n\nType: `method`\n\nExtracts the content of HTML tags from a string.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tags` | `Object` | yes |  | The result keys and their opening tags. |\n\nReturns: `Object` The content found for each key.\n\nEach key of `tags` holds the exact opening tag to look for. Nested tags of the same name stay in the content. A tag that is not found is left out of the result.\n\nExample: Splitting a template\n```js\nvar html = '<style>b { color: red }</style><div>One<div>Two</div></div>';\nconsole.log(html.parseComponent({ css: '<style>', body: '<div>', none: '<nav>' })); // {\"css\":\"b { color: red }\",\"body\":\"One<div>Two</div>\"}\n```\n\n### String.parseConfig([def], [noconvert])\n\nType: `method`\n\nParses configuration text in the form `key1:value;key2:value`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String or Object` | no |  | Default configuration that the parsed values extend. |\n| `noconvert` | `Boolean` | no | `false` | `true` keeps every value as a string. |\n\nReturns: `Object` The parsed configuration.\n\nValues `true` and `false` become booleans and numeric values become numbers. A key without a value gets an empty string. Write `\\;` to keep a semicolon inside a value. Keys and values can contain `[key]` phrases, which are replaced as in `env()`.\n\nExample: Parsing\n```js\nconsole.log('size:12;visible:true;title:Hello'.parseConfig()); // {\"size\":12,\"visible\":true,\"title\":\"Hello\"}\nconsole.log('size:12'.parseConfig('size:5;color:red')); // {\"size\":12,\"color\":\"red\"}\nconsole.log('size:12;visible:true'.parseConfig(null, true)); // {\"size\":\"12\",\"visible\":\"true\"}\nconsole.log('title:a\\\\;b;size:1'.parseConfig()); // {\"title\":\"a;b\",\"size\":1}\n```\n\n### String.parseDate([format])\n\nType: `method`\n\nConverts a string to a `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | The layout of the date. |\n\nReturns: `Date` The parsed date. An empty string without `format` returns `null`, and text that is not a date returns an invalid `Date`.\n\nWithout `format` the method reads `yyyy-MM-dd`, `dd.MM.yyyy`, each of them with an optional time `HH:mm:ss` or `HH:mm:ss.SSS` and an optional `am` or `pm`, a time alone (which uses the current day) and JSON dates. `[key]` phrases are replaced first, as in `env()`.\n\nWith `format` the method takes the digits of the string in order and assigns them to the tokens `yyyy`, `yy`, `MM`, `dd`, `HH`, `hh`, `mm` and `ss`, so each value must have as many digits as its token. When the string contains `am` or `pm`, the hours are read on a 12-hour clock.\n\nExample: Common forms\n```js\nconsole.log('2026-11-18 14:30:15'.parseDate().format('dd.MM.yyyy HH:mm:ss')); // 18.11.2026 14:30:15\nconsole.log('18.11.2026 14:30'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18T10:00:00.000Z'.parseDate().toISOString()); // 2026-11-18T10:00:00.000Z\nconsole.log(''.parseDate()); // null\n```\n\nExample: Custom layout\n```js\nconsole.log('18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd')); // 2026-11-18\nconsole.log('11-18-26 14:05'.parseDate('MM-dd-yy HH:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:05\n```\n\nExample: 12-hour times\n```js\nconsole.log('2026-11-18 12:30 pm'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 12:30\nconsole.log('2026-11-18 12:30 am'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 00:30\nconsole.log('18/11/2026 02:30 pm'.parseDate('dd/MM/yyyy hh:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18 14:30:15.250'.parseDate().getMilliseconds()); // 250\n```\n\n### String.parseExpire()\n\nType: `method`\n\nConverts a duration such as `5 minutes` to milliseconds.\n\nReturns: `Number` The duration in milliseconds.\n\nThe string is a number, a space and a unit. A dot in the unit is ignored.\n\n| Unit | Accepted names |\n| --- | --- |\n| Seconds | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minutes | `minutes`, `minute`, `min`, `mm`, `m` |\n| Hours | `hours`, `hour`, `HH`, `hh`, `H`, `h` |\n| Days | `days`, `day`, `DD`, `dd`, `d` |\n| Weeks | `weeks`, `week`, `W`, `w` |\n| Months (28 days) | `months`, `month`, `MM`, `M` |\n| Years (365 days) | `years`, `year`, `yyyy`, `yy`, `y` |\n\nAn empty string, a number without a unit, text that does not start with a number and an unknown unit return `0`.\n\nExample: Durations\n```js\nconsole.log('5 minutes'.parseExpire()); // 300000\nconsole.log('1 hour'.parseExpire()); // 3600000\nconsole.log('2 days'.parseExpire()); // 172800000\nconsole.log('none'.parseExpire()); // 0\n```\n\n### String.parseFloat([def])\n\nType: `method`\n\nReads a decimal number from the string.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | The value returned when the string holds no valid number. |\n\nReturns: `Number` The parsed number.\n\nThe method takes the first number in the text and accepts a dot or a comma as the decimal separator.\n\nExample: Reading numbers\n```js\nconsole.log('12,5 kg'.parseFloat()); // 12.5\nconsole.log('-3.25'.parseFloat()); // -3.25\nconsole.log('abc'.parseFloat(1.5)); // 1.5\n```\n\n### String.parseInt([def])\n\nType: `method`\n\nReads a whole number from the string.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | The value returned when the string holds no digits. |\n\nReturns: `Number` The parsed number.\n\nThe method takes the first group of digits in the text, with its sign.\n\nExample: Reading numbers\n```js\nconsole.log('12px'.parseInt()); // 12\nconsole.log('-3.9'.parseInt()); // -3\nconsole.log('abc'.parseInt(5)); // 5\n```\n\n### String.parseSource([type])\n\nType: `method`\n\nConverts text in the form `id|name|icon,id|name` to a list of items.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Function or String` | no |  | Pass `Number` or `'number'` to convert the identifiers to numbers. |\n\nReturns: `Array` Objects with the fields `id`, `name` and `icon`.\n\nA missing name uses the identifier and a missing icon is an empty string.\n\nExample: Building a list\n```js\nconsole.log('1|One|ti-star,2'.parseSource()); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti-star\"},{\"id\":\"2\",\"name\":\"2\",\"icon\":\"\"}]\nconsole.log('1|One'.parseSource(Number)); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"}]\n```\n\n### String.ROOT([noBase])\n\nType: `method`\n\nAdds the application root or base URL to an address.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noBase` | `Boolean` | no | `false` | `true` ignores `DEF.baseurl`. |\n\nReturns: `String` The final address.\n\n`DEF.root` is used first and `DEF.baseurl` when it is empty. Each of them can be a string or a function that receives the address and returns the result. A string prefix is not added to an absolute address.\n\nExample: Base URL\n```js\nDEF.baseurl = '/app/';\nconsole.log('/api/users/'.ROOT()); // /app/api/users/\nconsole.log('/api/users/'.ROOT(true)); // /api/users/\nconsole.log('https://www.totaljs.com/'.ROOT()); // https://www.totaljs.com/\n```\n\n### String.slug([max])\n\nType: `method`\n\nConverts text to a lowercase form for use in an address.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `max` | `Number` | no | `60` | The maximum length. |\n\nReturns: `String` The slug.\n\nDiacritics are converted with `toASCII()`. Spaces and most punctuation become a single dash. Letters, digits and underscores stay, and other characters are removed.\n\nExample: Creating slugs\n```js\nconsole.log('Hello World! 2026'.slug()); // hello-world-2026\nconsole.log('Hello wonderful world'.slug(8)); // hello-wo\n```\n\n### String.toASCII()\n\nType: `method`\n\nReplaces accented letters with plain ones.\n\nReturns: `String` The converted text.\n\nThe method converts the letters á ä ć č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž and their uppercase forms. Letters keep their case, and other characters stay as they are.\n\nExample: Removing diacritics\n```js\nconsole.log('Príliš žluťoučký kůň'.toASCII()); // Prilis zlutoucky kun\nconsole.log('Ťažký ñ'.toASCII()); // Tazky ñ\n```\n\n### String.toSearch()\n\nType: `method`\n\nNormalizes text for full-text comparison.\n\nReturns: `String` The normalized text.\n\nThe method removes punctuation, converts the text to lowercase ASCII, replaces `y` with `i` and reduces repeated characters to one.\n\nExample: Normalizing\n```js\nconsole.log('Hello Yellow!'.toSearch()); // helo ielow\nconsole.log('Príliš žlté'.toSearch()); // prilis zlte\n```\n\n### String.VARIABLES([args])\n\nType: `method`\n\nReplaces `--key--` variables in the string.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | The values of the variables. |\n\nReturns: `String` The string with the variables replaced.\n\nA definition in the form `--key=value--` is removed from the text and sets the variable for the rest of the string. A variable with no value stays in the text.\n\nExample: Using variables\n```js\nconsole.log('--color-- and --size--'.VARIABLES({ color: 'red' })); // red and --size--\nconsole.log('--color=blue--Color: --color--'.VARIABLES()); // Color: blue\n```\n","entries":[{"type":"method","name":"args()","signature":"String.args(obj, [encode])","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"String.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"String.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"String.flags([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"String.format([value0], [value1], [...])","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"String.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"String.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"String.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"String.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"String.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"String.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseComponent()","signature":"String.parseComponent(tags)","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"String.parseConfig([def], [noconvert])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"String.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"String.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"String.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"String.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"String.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"String.ROOT([noBase])","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"String.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"String.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"String.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"String.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYF9Mo61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/string/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"String","summary":"Methoden, die jComponent zu String.prototype hinzufügt, um Text zu formatieren, zu parsen, zu validieren und zu bereinigen.","markdown":"---\ntitle: String\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/string/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# String\n\n> Methoden, die jComponent zu String.prototype hinzufügt, um Text zu formatieren, zu parsen, zu validieren und zu bereinigen.\n\njComponent fügt diese Methoden jedem String hinzu. Die Ausgabe von Zahlen und Datumswerten richtet sich nach den Einstellungen in [DEF](../def/), Werte in der Form `[key]` stammen aus [ENV()](../globals/), und die Methoden, die die Konfiguration von Komponenten lesen, werden in [Komponenten erstellen](../../guides/creating-components/) verwendet.\n\n## API\n\n### String.args(obj, [encode])\n\nType: `method`\n\nErsetzt die Platzhalter `{key}` und `{{ key }}` durch Werte aus einem Objekt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | Die Werte für die Platzhalter. |\n| `encode` | `String or Function` | no |  | Wie jeder Wert geschrieben wird: `json` für `JSON.stringify()`, `encode` für `encodeURIComponent()`, `escape` für HTML-Entitäten oder eine Funktion `(value, key)`, die den Text zurückgibt. |\n\nReturns: `String` Der String mit den ersetzten Platzhaltern.\n\nEin Schlüssel kann ein verschachtelter Path wie `user.age` sein. Ohne `encode` behält ein Schlüssel, der nicht im Objekt vorkommt, seinen Platzhalter, und ein `null`-Wert wird zu einem leeren String.\n\nExample: Platzhalter\n```js\nconsole.log('Hello {name}, age {{ user.age }}, {unknown}'.args({ name: 'Ana', user: { age: 30 } })); // Hello Ana, age 30, {unknown}\n```\n\nExample: Werte kodieren\n```js\nconsole.log('{a}'.args({ a: '<b>' }, 'escape')); // &lt;b&gt;\nconsole.log('{a}'.args({ a: 'x y' }, 'encode')); // x%20y\nconsole.log('{a}'.args({ a: 'x' }, 'json')); // \"x\"\nconsole.log('{a}|{b}'.args({ a: 1, b: 2 }, (value, key) => key + '=' + value)); // a=1|b=2\n```\n\n### String.encode()\n\nType: `method`\n\nMaskiert die Zeichen `<`, `>`, `&` und `\"` als HTML-Entitäten.\n\nReturns: `String` Der maskierte Text.\n\nExample: HTML maskieren\n```js\nconsole.log('<a href=\"x\">T&C</a>'.encode()); // &lt;a href=&quot;x&quot;&gt;T&amp;C&lt;/a&gt;\n```\n\n### String.env()\n\nType: `method`\n\nErsetzt `[key]`-Ausdrücke durch Werte aus der Umgebung.\n\nReturns: `String` Der String mit den ersetzten bekannten Ausdrücken.\n\nEin `[key]`-Ausdruck liest den mit [ENV()](../globals/) gesetzten Wert. Ein Ausdruck, der mit einem Punkt beginnt, etwa `[.app.name]`, liest einen Path aus `window`. Ein Ausdruck ohne Wert bleibt im Text stehen.\n\nExample: Umgebungswerte\n```js\nENV('name', 'Peter');\nwindow.app = { version: 5 };\nconsole.log('[name] [.app.version] [missing]'.env()); // Peter 5 [missing]\n```\n\n### String.flags([path])\n\nType: `method`\n\nEntfernt `@name`-Flags aus dem Text und löst für jedes Flag, das einen Listener hat, ein Event aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Der Wert, der an die Event-Listener übergeben wird. |\n\nReturns: `String` Der getrimmte Text ohne die Flags.\n\nJedes Flag löst das Event `@flag name` mit `path` als Argument aus. Siehe [Flags und Path-Modifikatoren](../../guides/flags/).\n\nExample: Flags lesen\n```js\nvar seen = [];\nON('@flag reset', path => seen.push(path));\nconsole.log('form.name @reset @other'.flags('form.name')); // form.name\nconsole.log(seen); // [\"form.name\"]\n```\n\n### String.format([value0], [value1], [...])\n\nType: `method`\n\nErsetzt die Indizes `{0}`, `{1}` und so weiter durch die Argumente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value0` | `Object` | no |  | Der Wert für `{0}`. Jedes weitere Argument füllt den nächsten Index. |\n\nReturns: `String` Der formatierte Text.\n\nEin Array als Argument wird ohne Trennzeichen zusammengefügt. Ein fehlendes Argument oder `null` wird zu einem leeren String.\n\nExample: Indizierte Werte\n```js\nconsole.log('Hello {0}, you have {1} items{2}'.format('Ana', 3)); // Hello Ana, you have 3 items\nconsole.log('{0}'.format(['a', 'b'])); // ab\n```\n\n### String.isEmail()\n\nType: `method`\n\nPrüft, ob der String eine E-Mail-Adresse ist.\n\nReturns: `Boolean` `true` bei einer gültigen Adresse.\n\nDie Prüfung verwendet das Muster in `DEF.regexp.email`.\n\nExample: Adressen prüfen\n```js\nconsole.log('peter+news@total-js.com'.isEmail()); // true\nconsole.log('a@b'.isEmail()); // false\n```\n\n### String.isJSONDate()\n\nType: `method`\n\nPrüft, ob der String ein nach JSON serialisiertes Datum ist.\n\nReturns: `Boolean` `true` bei einem Wert in der Form `2026-11-18T10:00:00.000Z`.\n\nExample: Datumswerte prüfen\n```js\nconsole.log('2026-11-18T10:00:00.000Z'.isJSONDate()); // true\nconsole.log('2026-11-18'.isJSONDate()); // false\n```\n\n### String.isPhone()\n\nType: `method`\n\nPrüft, ob der String eine Telefonnummer ist.\n\nReturns: `Boolean` `true` bei einer gültigen Nummer.\n\nDie Prüfung verwendet das Muster in `DEF.regexp.phone`: ein optionales `+`, dann Gruppen aus drei, drei und vier bis acht Ziffern. Die Gruppen können durch ein Leerzeichen, einen Bindestrich oder einen Punkt getrennt sein, und die erste kann in Klammern stehen.\n\nExample: Nummern prüfen\n```js\nconsole.log('+421903123456'.isPhone()); // true\nconsole.log('(421) 903-1234'.isPhone()); // true\nconsole.log('12345'.isPhone()); // false\n```\n\n### String.isURL()\n\nType: `method`\n\nPrüft, ob der String eine `http`- oder `https`-Adresse ist.\n\nReturns: `Boolean` `true` bei einer gültigen Adresse.\n\nDie Prüfung verwendet das Muster in `DEF.regexp.url`.\n\nExample: Adressen prüfen\n```js\nconsole.log('https://www.totaljs.com/'.isURL()); // true\nconsole.log('ftp://totaljs.com/file'.isURL()); // false\nconsole.log('totaljs.com'.isURL()); // false\n```\n\n### String.padLeft(length, [char])\n\nType: `method`\n\nFüllt den Anfang des Strings bis zu einer bestimmten Länge auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Die endgültige Länge. |\n| `char` | `String` | no | `a space` | Das Füllzeichen. |\n\nReturns: `String` Der aufgefüllte Text.\n\nEin String, der bereits lang genug ist, wird unverändert zurückgegeben.\n\nExample: Auffüllen\n```js\nconsole.log('7'.padLeft(3, '0')); // 007\nconsole.log('abcd'.padLeft(2, '0')); // abcd\n```\n\n### String.padRight(length, [char])\n\nType: `method`\n\nFüllt das Ende des Strings bis zu einer bestimmten Länge auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Die endgültige Länge. |\n| `char` | `String` | no | `a space` | Das Füllzeichen. |\n\nReturns: `String` Der aufgefüllte Text.\n\nEin String, der bereits lang genug ist, wird unverändert zurückgegeben.\n\nExample: Auffüllen\n```js\nconsole.log('7'.padRight(3, '-')); // 7--\n```\n\n### String.parseComponent(tags)\n\nType: `method`\n\nExtrahiert den Inhalt von HTML-Tags aus einem String.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tags` | `Object` | yes |  | Die Ergebnisschlüssel und ihre öffnenden Tags. |\n\nReturns: `Object` Der für jeden Schlüssel gefundene Inhalt.\n\nJeder Schlüssel von `tags` enthält das exakte öffnende Tag, nach dem gesucht wird. Verschachtelte Tags mit demselben Namen bleiben im Inhalt. Ein nicht gefundenes Tag fehlt im Ergebnis.\n\nExample: Template aufteilen\n```js\nvar html = '<style>b { color: red }</style><div>One<div>Two</div></div>';\nconsole.log(html.parseComponent({ css: '<style>', body: '<div>', none: '<nav>' })); // {\"css\":\"b { color: red }\",\"body\":\"One<div>Two</div>\"}\n```\n\n### String.parseConfig([def], [noconvert])\n\nType: `method`\n\nParst Konfigurationstext in der Form `key1:value;key2:value`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String or Object` | no |  | Die Standardkonfiguration, die die geparsten Werte erweitern. |\n| `noconvert` | `Boolean` | no | `false` | `true` behält jeden Wert als String. |\n\nReturns: `Object` Die geparste Konfiguration.\n\nDie Werte `true` und `false` werden zu Booleans und numerische Werte zu Zahlen. Ein Schlüssel ohne Wert erhält einen leeren String. Schreibe `\\;`, um ein Semikolon innerhalb eines Werts zu behalten. Schlüssel und Werte können `[key]`-Ausdrücke enthalten, die wie bei `env()` ersetzt werden.\n\nExample: Parsen\n```js\nconsole.log('size:12;visible:true;title:Hello'.parseConfig()); // {\"size\":12,\"visible\":true,\"title\":\"Hello\"}\nconsole.log('size:12'.parseConfig('size:5;color:red')); // {\"size\":12,\"color\":\"red\"}\nconsole.log('size:12;visible:true'.parseConfig(null, true)); // {\"size\":\"12\",\"visible\":\"true\"}\nconsole.log('title:a\\\\;b;size:1'.parseConfig()); // {\"title\":\"a;b\",\"size\":1}\n```\n\n### String.parseDate([format])\n\nType: `method`\n\nWandelt einen String in ein `Date` um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | Das Layout des Datums. |\n\nReturns: `Date` Das geparste Datum. Ein leerer String ohne `format` ergibt `null`, und Text, der kein Datum ist, ergibt ein ungültiges `Date`.\n\nOhne `format` liest die Methode `yyyy-MM-dd` und `dd.MM.yyyy`, jeweils mit optionaler Uhrzeit `HH:mm:ss` oder `HH:mm:ss.SSS` und optionalem `am` oder `pm`, außerdem eine Uhrzeit allein (die den aktuellen Tag verwendet) und JSON-Datumswerte. `[key]`-Ausdrücke werden zuerst ersetzt, wie bei `env()`.\n\nMit `format` nimmt die Methode die Ziffern des Strings der Reihe nach und ordnet sie den Tokens `yyyy`, `yy`, `MM`, `dd`, `HH`, `hh`, `mm` und `ss` zu. Jeder Wert muss also so viele Ziffern haben wie sein Token. Enthält der String `am` oder `pm`, werden die Stunden im 12-Stunden-Format gelesen.\n\nExample: Gängige Formen\n```js\nconsole.log('2026-11-18 14:30:15'.parseDate().format('dd.MM.yyyy HH:mm:ss')); // 18.11.2026 14:30:15\nconsole.log('18.11.2026 14:30'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18T10:00:00.000Z'.parseDate().toISOString()); // 2026-11-18T10:00:00.000Z\nconsole.log(''.parseDate()); // null\n```\n\nExample: Eigenes Layout\n```js\nconsole.log('18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd')); // 2026-11-18\nconsole.log('11-18-26 14:05'.parseDate('MM-dd-yy HH:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:05\n```\n\nExample: Uhrzeiten im 12-Stunden-Format\n```js\nconsole.log('2026-11-18 12:30 pm'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 12:30\nconsole.log('2026-11-18 12:30 am'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 00:30\nconsole.log('18/11/2026 02:30 pm'.parseDate('dd/MM/yyyy hh:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18 14:30:15.250'.parseDate().getMilliseconds()); // 250\n```\n\n### String.parseExpire()\n\nType: `method`\n\nWandelt eine Dauer wie `5 minutes` in Millisekunden um.\n\nReturns: `Number` Die Dauer in Millisekunden.\n\nDer String besteht aus einer Zahl, einem Leerzeichen und einer Einheit. Ein Punkt in der Einheit wird ignoriert.\n\n| Einheit | Akzeptierte Namen |\n| --- | --- |\n| Sekunden | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minuten | `minutes`, `minute`, `min`, `mm`, `m` |\n| Stunden | `hours`, `hour`, `HH`, `hh`, `H`, `h` |\n| Tage | `days`, `day`, `DD`, `dd`, `d` |\n| Wochen | `weeks`, `week`, `W`, `w` |\n| Monate (28 Tage) | `months`, `month`, `MM`, `M` |\n| Jahre (365 Tage) | `years`, `year`, `yyyy`, `yy`, `y` |\n\nEin leerer String, eine Zahl ohne Einheit, Text, der nicht mit einer Zahl beginnt, und eine unbekannte Einheit ergeben `0`.\n\nExample: Zeitdauern\n```js\nconsole.log('5 minutes'.parseExpire()); // 300000\nconsole.log('1 hour'.parseExpire()); // 3600000\nconsole.log('2 days'.parseExpire()); // 172800000\nconsole.log('none'.parseExpire()); // 0\n```\n\n### String.parseFloat([def])\n\nType: `method`\n\nLiest eine Dezimalzahl aus dem String.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Der Rückgabewert, wenn der String keine gültige Zahl enthält. |\n\nReturns: `Number` Die geparste Zahl.\n\nDie Methode nimmt die erste Zahl im Text und akzeptiert einen Punkt oder ein Komma als Dezimaltrennzeichen.\n\nExample: Zahlen lesen\n```js\nconsole.log('12,5 kg'.parseFloat()); // 12.5\nconsole.log('-3.25'.parseFloat()); // -3.25\nconsole.log('abc'.parseFloat(1.5)); // 1.5\n```\n\n### String.parseInt([def])\n\nType: `method`\n\nLiest eine ganze Zahl aus dem String.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Der Rückgabewert, wenn der String keine Ziffern enthält. |\n\nReturns: `Number` Die geparste Zahl.\n\nDie Methode nimmt die erste Zifferngruppe im Text, samt Vorzeichen.\n\nExample: Zahlen lesen\n```js\nconsole.log('12px'.parseInt()); // 12\nconsole.log('-3.9'.parseInt()); // -3\nconsole.log('abc'.parseInt(5)); // 5\n```\n\n### String.parseSource([type])\n\nType: `method`\n\nWandelt Text in der Form `id|name|icon,id|name` in eine Liste von Einträgen um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Function or String` | no |  | Übergib `Number` oder `'number'`, um die Bezeichner in Zahlen umzuwandeln. |\n\nReturns: `Array` Objekte mit den Feldern `id`, `name` und `icon`.\n\nFehlt der Name, wird der Bezeichner verwendet, und ein fehlendes Icon ist ein leerer String.\n\nExample: Liste erstellen\n```js\nconsole.log('1|One|ti-star,2'.parseSource()); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti-star\"},{\"id\":\"2\",\"name\":\"2\",\"icon\":\"\"}]\nconsole.log('1|One'.parseSource(Number)); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"}]\n```\n\n### String.ROOT([noBase])\n\nType: `method`\n\nFügt einer Adresse das Root-Verzeichnis oder die Basis-URL der Anwendung hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noBase` | `Boolean` | no | `false` | `true` ignoriert `DEF.baseurl`. |\n\nReturns: `String` Die endgültige Adresse.\n\nZuerst wird `DEF.root` verwendet und, wenn das leer ist, `DEF.baseurl`. Beide können ein String oder eine Funktion sein, die die Adresse erhält und das Ergebnis zurückgibt. Ein String-Präfix wird einer absoluten Adresse nicht hinzugefügt.\n\nExample: Basis-URL\n```js\nDEF.baseurl = '/app/';\nconsole.log('/api/users/'.ROOT()); // /app/api/users/\nconsole.log('/api/users/'.ROOT(true)); // /api/users/\nconsole.log('https://www.totaljs.com/'.ROOT()); // https://www.totaljs.com/\n```\n\n### String.slug([max])\n\nType: `method`\n\nWandelt Text in eine kleingeschriebene Form für die Verwendung in einer Adresse um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `max` | `Number` | no | `60` | Die maximale Länge. |\n\nReturns: `String` Der Slug.\n\nDiakritische Zeichen werden mit `toASCII()` umgewandelt. Leerzeichen und die meisten Satzzeichen werden zu einem einzelnen Bindestrich. Buchstaben, Ziffern und Unterstriche bleiben erhalten, andere Zeichen werden entfernt.\n\nExample: Slugs erstellen\n```js\nconsole.log('Hello World! 2026'.slug()); // hello-world-2026\nconsole.log('Hello wonderful world'.slug(8)); // hello-wo\n```\n\n### String.toASCII()\n\nType: `method`\n\nErsetzt Buchstaben mit Akzent durch einfache Buchstaben.\n\nReturns: `String` Der umgewandelte Text.\n\nDie Methode wandelt die Buchstaben á ä ć č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž und ihre Großbuchstaben um. Buchstaben behalten ihre Schreibweise, und andere Zeichen bleiben unverändert.\n\nExample: Diakritische Zeichen entfernen\n```js\nconsole.log('Príliš žluťoučký kůň'.toASCII()); // Prilis zlutoucky kun\nconsole.log('Ťažký ñ'.toASCII()); // Tazky ñ\n```\n\n### String.toSearch()\n\nType: `method`\n\nNormalisiert Text für den Volltextvergleich.\n\nReturns: `String` Der normalisierte Text.\n\nDie Methode entfernt Satzzeichen, wandelt den Text in kleingeschriebenes ASCII um, ersetzt `y` durch `i` und reduziert wiederholte Zeichen auf eines.\n\nExample: Normalisieren\n```js\nconsole.log('Hello Yellow!'.toSearch()); // helo ielow\nconsole.log('Príliš žlté'.toSearch()); // prilis zlte\n```\n\n### String.VARIABLES([args])\n\nType: `method`\n\nErsetzt `--key--`-Variablen im String.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | Die Werte der Variablen. |\n\nReturns: `String` Der String mit den ersetzten Variablen.\n\nEine Definition in der Form `--key=value--` wird aus dem Text entfernt und setzt die Variable für den Rest des Strings. Eine Variable ohne Wert bleibt im Text stehen.\n\nExample: Variablen verwenden\n```js\nconsole.log('--color-- and --size--'.VARIABLES({ color: 'red' })); // red and --size--\nconsole.log('--color=blue--Color: --color--'.VARIABLES()); // Color: blue\n```\n","entries":[{"type":"method","name":"args()","signature":"String.args(obj, [encode])","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"String.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"String.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"String.flags([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"String.format([value0], [value1], [...])","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"String.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"String.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"String.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"String.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"String.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"String.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseComponent()","signature":"String.parseComponent(tags)","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"String.parseConfig([def], [noconvert])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"String.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"String.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"String.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"String.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"String.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"String.ROOT([noBase])","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"String.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"String.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"String.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"String.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYF9Mo61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/string/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"String","summary":"Métodos que jComponent añade a String.prototype para dar formato, analizar, validar y limpiar texto.","markdown":"---\ntitle: String\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/string/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# String\n\n> Métodos que jComponent añade a String.prototype para dar formato, analizar, validar y limpiar texto.\n\njComponent añade estos métodos a todas las cadenas. La salida de números y fechas sigue los ajustes de [DEF](../def/), los valores con la forma `[key]` proceden de [ENV()](../globals/), y los métodos que leen la configuración de los componentes se usan en [Crear componentes](../../guides/creating-components/).\n\n## API\n\n### String.args(obj, [encode])\n\nType: `method`\n\nSustituye los marcadores `{key}` y `{{ key }}` por valores de un objeto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | Los valores de los marcadores. |\n| `encode` | `String or Function` | no |  | Cómo escribir cada valor: `json` para `JSON.stringify()`, `encode` para `encodeURIComponent()`, `escape` para entidades HTML, o una función `(value, key)` que devuelve el texto. |\n\nReturns: `String` La cadena con los marcadores sustituidos.\n\nUna clave puede ser un path anidado, como `user.age`. Sin `encode`, una clave que no está en el objeto conserva su marcador y un valor `null` se convierte en una cadena vacía.\n\nExample: Marcadores\n```js\nconsole.log('Hello {name}, age {{ user.age }}, {unknown}'.args({ name: 'Ana', user: { age: 30 } })); // Hello Ana, age 30, {unknown}\n```\n\nExample: Codificar los valores\n```js\nconsole.log('{a}'.args({ a: '<b>' }, 'escape')); // &lt;b&gt;\nconsole.log('{a}'.args({ a: 'x y' }, 'encode')); // x%20y\nconsole.log('{a}'.args({ a: 'x' }, 'json')); // \"x\"\nconsole.log('{a}|{b}'.args({ a: 1, b: 2 }, (value, key) => key + '=' + value)); // a=1|b=2\n```\n\n### String.encode()\n\nType: `method`\n\nEscapa los caracteres `<`, `>`, `&` y `\"` como entidades HTML.\n\nReturns: `String` El texto escapado.\n\nExample: Escapar HTML\n```js\nconsole.log('<a href=\"x\">T&C</a>'.encode()); // &lt;a href=&quot;x&quot;&gt;T&amp;C&lt;/a&gt;\n```\n\n### String.env()\n\nType: `method`\n\nSustituye las frases `[key]` por valores del entorno.\n\nReturns: `String` La cadena con las frases conocidas sustituidas.\n\nUna frase `[key]` lee el valor establecido con [ENV()](../globals/). Una frase que empieza por un punto, como `[.app.name]`, lee un path de `window`. Una frase sin valor se queda en el texto.\n\nExample: Valores del entorno\n```js\nENV('name', 'Peter');\nwindow.app = { version: 5 };\nconsole.log('[name] [.app.version] [missing]'.env()); // Peter 5 [missing]\n```\n\n### String.flags([path])\n\nType: `method`\n\nElimina los flags `@name` del texto y emite un evento por cada flag que tiene un listener.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | El valor que se pasa a los listeners del evento. |\n\nReturns: `String` El texto recortado y sin los flags.\n\nCada flag emite el evento `@flag name` con `path` como argumento. Consulta [Flags y modificadores de path](../../guides/flags/).\n\nExample: Leer los flags\n```js\nvar seen = [];\nON('@flag reset', path => seen.push(path));\nconsole.log('form.name @reset @other'.flags('form.name')); // form.name\nconsole.log(seen); // [\"form.name\"]\n```\n\n### String.format([value0], [value1], [...])\n\nType: `method`\n\nSustituye los índices `{0}`, `{1}` y siguientes por los argumentos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value0` | `Object` | no |  | El valor de `{0}`. Cada argumento adicional rellena el índice siguiente. |\n\nReturns: `String` El texto con formato.\n\nUn argumento de tipo array se une sin separador. Un argumento que falta o es `null` se convierte en una cadena vacía.\n\nExample: Valores indexados\n```js\nconsole.log('Hello {0}, you have {1} items{2}'.format('Ana', 3)); // Hello Ana, you have 3 items\nconsole.log('{0}'.format(['a', 'b'])); // ab\n```\n\n### String.isEmail()\n\nType: `method`\n\nComprueba que la cadena sea una dirección de correo electrónico.\n\nReturns: `Boolean` `true` para una dirección válida.\n\nLa comprobación usa el patrón de `DEF.regexp.email`.\n\nExample: Comprobar direcciones\n```js\nconsole.log('peter+news@total-js.com'.isEmail()); // true\nconsole.log('a@b'.isEmail()); // false\n```\n\n### String.isJSONDate()\n\nType: `method`\n\nComprueba que la cadena sea una fecha serializada en JSON.\n\nReturns: `Boolean` `true` para un valor con la forma `2026-11-18T10:00:00.000Z`.\n\nExample: Comprobar fechas\n```js\nconsole.log('2026-11-18T10:00:00.000Z'.isJSONDate()); // true\nconsole.log('2026-11-18'.isJSONDate()); // false\n```\n\n### String.isPhone()\n\nType: `method`\n\nComprueba que la cadena sea un número de teléfono.\n\nReturns: `Boolean` `true` para un número válido.\n\nLa comprobación usa el patrón de `DEF.regexp.phone`: un `+` opcional y, a continuación, grupos de tres, tres y de cuatro a ocho dígitos. Los grupos se pueden separar con un espacio, un guion o un punto, y el primero puede ir entre paréntesis.\n\nExample: Comprobar números\n```js\nconsole.log('+421903123456'.isPhone()); // true\nconsole.log('(421) 903-1234'.isPhone()); // true\nconsole.log('12345'.isPhone()); // false\n```\n\n### String.isURL()\n\nType: `method`\n\nComprueba que la cadena sea una dirección `http` o `https`.\n\nReturns: `Boolean` `true` para una dirección válida.\n\nLa comprobación usa el patrón de `DEF.regexp.url`.\n\nExample: Comprobar direcciones\n```js\nconsole.log('https://www.totaljs.com/'.isURL()); // true\nconsole.log('ftp://totaljs.com/file'.isURL()); // false\nconsole.log('totaljs.com'.isURL()); // false\n```\n\n### String.padLeft(length, [char])\n\nType: `method`\n\nRellena el inicio de la cadena hasta una longitud.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longitud final. |\n| `char` | `String` | no | `a space` | El carácter de relleno. |\n\nReturns: `String` El texto rellenado.\n\nUna cadena que ya es lo bastante larga se devuelve sin cambios.\n\nExample: Relleno\n```js\nconsole.log('7'.padLeft(3, '0')); // 007\nconsole.log('abcd'.padLeft(2, '0')); // abcd\n```\n\n### String.padRight(length, [char])\n\nType: `method`\n\nRellena el final de la cadena hasta una longitud.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longitud final. |\n| `char` | `String` | no | `a space` | El carácter de relleno. |\n\nReturns: `String` El texto rellenado.\n\nUna cadena que ya es lo bastante larga se devuelve sin cambios.\n\nExample: Relleno\n```js\nconsole.log('7'.padRight(3, '-')); // 7--\n```\n\n### String.parseComponent(tags)\n\nType: `method`\n\nExtrae de una cadena el contenido de las etiquetas HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tags` | `Object` | yes |  | Las claves del resultado y sus etiquetas de apertura. |\n\nReturns: `Object` El contenido encontrado para cada clave.\n\nCada clave de `tags` contiene la etiqueta de apertura exacta que se busca. Las etiquetas anidadas con el mismo nombre se quedan en el contenido. Una etiqueta que no se encuentra queda fuera del resultado.\n\nExample: Dividir una plantilla\n```js\nvar html = '<style>b { color: red }</style><div>One<div>Two</div></div>';\nconsole.log(html.parseComponent({ css: '<style>', body: '<div>', none: '<nav>' })); // {\"css\":\"b { color: red }\",\"body\":\"One<div>Two</div>\"}\n```\n\n### String.parseConfig([def], [noconvert])\n\nType: `method`\n\nAnaliza un texto de configuración con la forma `key1:value;key2:value`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String or Object` | no |  | La configuración predeterminada que amplían los valores analizados. |\n| `noconvert` | `Boolean` | no | `false` | `true` conserva todos los valores como cadenas. |\n\nReturns: `Object` La configuración analizada.\n\nLos valores `true` y `false` se convierten en booleanos y los valores numéricos en números. Una clave sin valor recibe una cadena vacía. Escribe `\\;` para conservar un punto y coma dentro de un valor. Las claves y los valores pueden contener frases `[key]`, que se sustituyen como en `env()`.\n\nExample: Análisis\n```js\nconsole.log('size:12;visible:true;title:Hello'.parseConfig()); // {\"size\":12,\"visible\":true,\"title\":\"Hello\"}\nconsole.log('size:12'.parseConfig('size:5;color:red')); // {\"size\":12,\"color\":\"red\"}\nconsole.log('size:12;visible:true'.parseConfig(null, true)); // {\"size\":\"12\",\"visible\":\"true\"}\nconsole.log('title:a\\\\;b;size:1'.parseConfig()); // {\"title\":\"a;b\",\"size\":1}\n```\n\n### String.parseDate([format])\n\nType: `method`\n\nConvierte una cadena en un `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | El patrón de la fecha. |\n\nReturns: `Date` La fecha analizada. Una cadena vacía sin `format` devuelve `null`, y un texto que no es una fecha devuelve un `Date` no válido.\n\nSin `format`, el método lee `yyyy-MM-dd` y `dd.MM.yyyy`, ambos con una hora `HH:mm:ss` o `HH:mm:ss.SSS` opcional y un `am` o `pm` opcional, una hora sola (que usa el día actual) y fechas JSON. Las frases `[key]` se sustituyen primero, como en `env()`.\n\nCon `format`, el método toma en orden los dígitos de la cadena y los asigna a los tokens `yyyy`, `yy`, `MM`, `dd`, `HH`, `hh`, `mm` y `ss`, así que cada valor debe tener tantos dígitos como su token. Si la cadena contiene `am` o `pm`, las horas se leen en formato de 12 horas.\n\nExample: Formas habituales\n```js\nconsole.log('2026-11-18 14:30:15'.parseDate().format('dd.MM.yyyy HH:mm:ss')); // 18.11.2026 14:30:15\nconsole.log('18.11.2026 14:30'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18T10:00:00.000Z'.parseDate().toISOString()); // 2026-11-18T10:00:00.000Z\nconsole.log(''.parseDate()); // null\n```\n\nExample: Patrón personalizado\n```js\nconsole.log('18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd')); // 2026-11-18\nconsole.log('11-18-26 14:05'.parseDate('MM-dd-yy HH:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:05\n```\n\nExample: Horas en formato de 12 horas\n```js\nconsole.log('2026-11-18 12:30 pm'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 12:30\nconsole.log('2026-11-18 12:30 am'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 00:30\nconsole.log('18/11/2026 02:30 pm'.parseDate('dd/MM/yyyy hh:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18 14:30:15.250'.parseDate().getMilliseconds()); // 250\n```\n\n### String.parseExpire()\n\nType: `method`\n\nConvierte una duración como `5 minutes` en milisegundos.\n\nReturns: `Number` La duración en milisegundos.\n\nLa cadena es un número, un espacio y una unidad. Un punto en la unidad se ignora.\n\n| Unidad | Nombres aceptados |\n| --- | --- |\n| Segundos | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minutos | `minutes`, `minute`, `min`, `mm`, `m` |\n| Horas | `hours`, `hour`, `HH`, `hh`, `H`, `h` |\n| Días | `days`, `day`, `DD`, `dd`, `d` |\n| Semanas | `weeks`, `week`, `W`, `w` |\n| Meses (28 días) | `months`, `month`, `MM`, `M` |\n| Años (365 días) | `years`, `year`, `yyyy`, `yy`, `y` |\n\nUna cadena vacía, un número sin unidad, un texto que no empieza por un número y una unidad desconocida devuelven `0`.\n\nExample: Duraciones\n```js\nconsole.log('5 minutes'.parseExpire()); // 300000\nconsole.log('1 hour'.parseExpire()); // 3600000\nconsole.log('2 days'.parseExpire()); // 172800000\nconsole.log('none'.parseExpire()); // 0\n```\n\n### String.parseFloat([def])\n\nType: `method`\n\nLee un número decimal de la cadena.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | El valor que se devuelve cuando la cadena no contiene ningún número válido. |\n\nReturns: `Number` El número analizado.\n\nEl método toma el primer número del texto y acepta un punto o una coma como separador decimal.\n\nExample: Leer números\n```js\nconsole.log('12,5 kg'.parseFloat()); // 12.5\nconsole.log('-3.25'.parseFloat()); // -3.25\nconsole.log('abc'.parseFloat(1.5)); // 1.5\n```\n\n### String.parseInt([def])\n\nType: `method`\n\nLee un número entero de la cadena.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | El valor que se devuelve cuando la cadena no contiene dígitos. |\n\nReturns: `Number` El número analizado.\n\nEl método toma el primer grupo de dígitos del texto, con su signo.\n\nExample: Leer números\n```js\nconsole.log('12px'.parseInt()); // 12\nconsole.log('-3.9'.parseInt()); // -3\nconsole.log('abc'.parseInt(5)); // 5\n```\n\n### String.parseSource([type])\n\nType: `method`\n\nConvierte un texto con la forma `id|name|icon,id|name` en una lista de elementos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Function or String` | no |  | Pasa `Number` o `'number'` para convertir los identificadores en números. |\n\nReturns: `Array` Objetos con los campos `id`, `name` e `icon`.\n\nSi falta el nombre, se usa el identificador, y si falta el icono, queda una cadena vacía.\n\nExample: Construir una lista\n```js\nconsole.log('1|One|ti-star,2'.parseSource()); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti-star\"},{\"id\":\"2\",\"name\":\"2\",\"icon\":\"\"}]\nconsole.log('1|One'.parseSource(Number)); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"}]\n```\n\n### String.ROOT([noBase])\n\nType: `method`\n\nAñade a una dirección la raíz de la aplicación o la URL base.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noBase` | `Boolean` | no | `false` | `true` ignora `DEF.baseurl`. |\n\nReturns: `String` La dirección final.\n\nSe usa primero `DEF.root` y, cuando está vacío, `DEF.baseurl`. Cada uno puede ser una cadena o una función que recibe la dirección y devuelve el resultado. Un prefijo de tipo cadena no se añade a una dirección absoluta.\n\nExample: URL base\n```js\nDEF.baseurl = '/app/';\nconsole.log('/api/users/'.ROOT()); // /app/api/users/\nconsole.log('/api/users/'.ROOT(true)); // /api/users/\nconsole.log('https://www.totaljs.com/'.ROOT()); // https://www.totaljs.com/\n```\n\n### String.slug([max])\n\nType: `method`\n\nConvierte un texto a una forma en minúsculas para usarlo en una dirección.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `max` | `Number` | no | `60` | La longitud máxima. |\n\nReturns: `String` El slug.\n\nLos diacríticos se convierten con `toASCII()`. Los espacios y la mayoría de los signos de puntuación se convierten en un solo guion. Las letras, los dígitos y los guiones bajos se conservan, y los demás caracteres se eliminan.\n\nExample: Crear slugs\n```js\nconsole.log('Hello World! 2026'.slug()); // hello-world-2026\nconsole.log('Hello wonderful world'.slug(8)); // hello-wo\n```\n\n### String.toASCII()\n\nType: `method`\n\nSustituye las letras acentuadas por letras sin acento.\n\nReturns: `String` El texto convertido.\n\nEl método convierte las letras á ä ć č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž y sus formas en mayúscula. Las letras conservan su caja, y los demás caracteres se quedan como están.\n\nExample: Eliminar diacríticos\n```js\nconsole.log('Príliš žluťoučký kůň'.toASCII()); // Prilis zlutoucky kun\nconsole.log('Ťažký ñ'.toASCII()); // Tazky ñ\n```\n\n### String.toSearch()\n\nType: `method`\n\nNormaliza un texto para la comparación de texto completo.\n\nReturns: `String` El texto normalizado.\n\nEl método elimina la puntuación, convierte el texto a ASCII en minúsculas, sustituye `y` por `i` y reduce a uno los caracteres repetidos.\n\nExample: Normalizar\n```js\nconsole.log('Hello Yellow!'.toSearch()); // helo ielow\nconsole.log('Príliš žlté'.toSearch()); // prilis zlte\n```\n\n### String.VARIABLES([args])\n\nType: `method`\n\nSustituye las variables `--key--` de la cadena.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | Los valores de las variables. |\n\nReturns: `String` La cadena con las variables sustituidas.\n\nUna definición con la forma `--key=value--` se elimina del texto y establece la variable para el resto de la cadena. Una variable sin valor se queda en el texto.\n\nExample: Usar variables\n```js\nconsole.log('--color-- and --size--'.VARIABLES({ color: 'red' })); // red and --size--\nconsole.log('--color=blue--Color: --color--'.VARIABLES()); // Color: blue\n```\n","entries":[{"type":"method","name":"args()","signature":"String.args(obj, [encode])","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"String.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"String.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"String.flags([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"String.format([value0], [value1], [...])","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"String.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"String.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"String.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"String.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"String.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"String.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseComponent()","signature":"String.parseComponent(tags)","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"String.parseConfig([def], [noconvert])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"String.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"String.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"String.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"String.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"String.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"String.ROOT([noBase])","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"String.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"String.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"String.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"String.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYF9Mo61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/string/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"String","summary":"Les méthodes que jComponent ajoute à String.prototype pour formater, analyser, valider et nettoyer du texte.","markdown":"---\ntitle: String\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/string/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# String\n\n> Les méthodes que jComponent ajoute à String.prototype pour formater, analyser, valider et nettoyer du texte.\n\njComponent ajoute ces méthodes à chaque chaîne. L'affichage des nombres et des dates suit les réglages de [DEF](../def/), les valeurs de la forme `[key]` proviennent de [ENV()](../globals/), et les méthodes qui lisent la configuration des composants sont utilisées dans [Créer des composants](../../guides/creating-components/).\n\n## API\n\n### String.args(obj, [encode])\n\nType: `method`\n\nRemplace les emplacements `{key}` et `{{ key }}` par les valeurs d'un objet.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | Les valeurs des emplacements. |\n| `encode` | `String or Function` | no |  | La façon d'écrire chaque valeur : `json` pour `JSON.stringify()`, `encode` pour `encodeURIComponent()`, `escape` pour les entités HTML, ou une fonction `(value, key)` qui renvoie le texte. |\n\nReturns: `String` La chaîne avec les emplacements remplacés.\n\nUne clé peut être un path imbriqué comme `user.age`. Sans `encode`, une clé absente de l'objet conserve son emplacement et une valeur `null` devient une chaîne vide.\n\nExample: Emplacements\n```js\nconsole.log('Hello {name}, age {{ user.age }}, {unknown}'.args({ name: 'Ana', user: { age: 30 } })); // Hello Ana, age 30, {unknown}\n```\n\nExample: Encoder les valeurs\n```js\nconsole.log('{a}'.args({ a: '<b>' }, 'escape')); // &lt;b&gt;\nconsole.log('{a}'.args({ a: 'x y' }, 'encode')); // x%20y\nconsole.log('{a}'.args({ a: 'x' }, 'json')); // \"x\"\nconsole.log('{a}|{b}'.args({ a: 1, b: 2 }, (value, key) => key + '=' + value)); // a=1|b=2\n```\n\n### String.encode()\n\nType: `method`\n\nÉchappe les caractères `<`, `>`, `&` et `\"` en entités HTML.\n\nReturns: `String` Le texte échappé.\n\nExample: Échapper le HTML\n```js\nconsole.log('<a href=\"x\">T&C</a>'.encode()); // &lt;a href=&quot;x&quot;&gt;T&amp;C&lt;/a&gt;\n```\n\n### String.env()\n\nType: `method`\n\nRemplace les expressions `[key]` par des valeurs de l'environnement.\n\nReturns: `String` La chaîne avec les expressions connues remplacées.\n\nUne expression `[key]` lit la valeur définie avec [ENV()](../globals/). Une expression qui commence par un point, comme `[.app.name]`, lit un path depuis `window`. Une expression sans valeur reste dans le texte.\n\nExample: Valeurs de l'environnement\n```js\nENV('name', 'Peter');\nwindow.app = { version: 5 };\nconsole.log('[name] [.app.version] [missing]'.env()); // Peter 5 [missing]\n```\n\n### String.flags([path])\n\nType: `method`\n\nRetire les flags `@name` du texte et émet un événement pour chaque flag qui a un écouteur.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | La valeur transmise aux écouteurs de l'événement. |\n\nReturns: `String` Le texte sans espaces superflues et sans les flags.\n\nChaque flag émet l'événement `@flag name` avec `path` comme argument. Voir [Flags et modificateurs de path](../../guides/flags/).\n\nExample: Lire les flags\n```js\nvar seen = [];\nON('@flag reset', path => seen.push(path));\nconsole.log('form.name @reset @other'.flags('form.name')); // form.name\nconsole.log(seen); // [\"form.name\"]\n```\n\n### String.format([value0], [value1], [...])\n\nType: `method`\n\nRemplace les index `{0}`, `{1}` et ainsi de suite par les arguments.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value0` | `Object` | no |  | La valeur de `{0}`. Chaque argument suivant remplit l'index suivant. |\n\nReturns: `String` Le texte formaté.\n\nUn argument de type tableau est joint sans séparateur. Un argument manquant ou `null` devient une chaîne vide.\n\nExample: Valeurs indexées\n```js\nconsole.log('Hello {0}, you have {1} items{2}'.format('Ana', 3)); // Hello Ana, you have 3 items\nconsole.log('{0}'.format(['a', 'b'])); // ab\n```\n\n### String.isEmail()\n\nType: `method`\n\nVérifie que la chaîne est une adresse e-mail.\n\nReturns: `Boolean` `true` pour une adresse valide.\n\nLe test utilise le motif de `DEF.regexp.email`.\n\nExample: Vérifier des adresses\n```js\nconsole.log('peter+news@total-js.com'.isEmail()); // true\nconsole.log('a@b'.isEmail()); // false\n```\n\n### String.isJSONDate()\n\nType: `method`\n\nVérifie que la chaîne est une date sérialisée en JSON.\n\nReturns: `Boolean` `true` pour une valeur de la forme `2026-11-18T10:00:00.000Z`.\n\nExample: Vérifier des dates\n```js\nconsole.log('2026-11-18T10:00:00.000Z'.isJSONDate()); // true\nconsole.log('2026-11-18'.isJSONDate()); // false\n```\n\n### String.isPhone()\n\nType: `method`\n\nVérifie que la chaîne est un numéro de téléphone.\n\nReturns: `Boolean` `true` pour un numéro valide.\n\nLe test utilise le motif de `DEF.regexp.phone` : un `+` facultatif, puis des groupes de trois, trois et quatre à huit chiffres. Les groupes peuvent être séparés par une espace, un tiret ou un point, et le premier peut être entre parenthèses.\n\nExample: Vérifier des numéros\n```js\nconsole.log('+421903123456'.isPhone()); // true\nconsole.log('(421) 903-1234'.isPhone()); // true\nconsole.log('12345'.isPhone()); // false\n```\n\n### String.isURL()\n\nType: `method`\n\nVérifie que la chaîne est une adresse `http` ou `https`.\n\nReturns: `Boolean` `true` pour une adresse valide.\n\nLe test utilise le motif de `DEF.regexp.url`.\n\nExample: Vérifier des adresses\n```js\nconsole.log('https://www.totaljs.com/'.isURL()); // true\nconsole.log('ftp://totaljs.com/file'.isURL()); // false\nconsole.log('totaljs.com'.isURL()); // false\n```\n\n### String.padLeft(length, [char])\n\nType: `method`\n\nComplète le début de la chaîne jusqu'à une longueur donnée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longueur finale. |\n| `char` | `String` | no | `a space` | Le caractère de remplissage. |\n\nReturns: `String` Le texte complété.\n\nUne chaîne déjà assez longue est renvoyée sans modification.\n\nExample: Remplissage\n```js\nconsole.log('7'.padLeft(3, '0')); // 007\nconsole.log('abcd'.padLeft(2, '0')); // abcd\n```\n\n### String.padRight(length, [char])\n\nType: `method`\n\nComplète la fin de la chaîne jusqu'à une longueur donnée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longueur finale. |\n| `char` | `String` | no | `a space` | Le caractère de remplissage. |\n\nReturns: `String` Le texte complété.\n\nUne chaîne déjà assez longue est renvoyée sans modification.\n\nExample: Remplissage\n```js\nconsole.log('7'.padRight(3, '-')); // 7--\n```\n\n### String.parseComponent(tags)\n\nType: `method`\n\nExtrait le contenu de balises HTML d'une chaîne.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tags` | `Object` | yes |  | Les clés du résultat et leurs balises ouvrantes. |\n\nReturns: `Object` Le contenu trouvé pour chaque clé.\n\nChaque clé de `tags` contient la balise ouvrante exacte à rechercher. Les balises imbriquées de même nom restent dans le contenu. Une balise introuvable ne figure pas dans le résultat.\n\nExample: Découper un modèle\n```js\nvar html = '<style>b { color: red }</style><div>One<div>Two</div></div>';\nconsole.log(html.parseComponent({ css: '<style>', body: '<div>', none: '<nav>' })); // {\"css\":\"b { color: red }\",\"body\":\"One<div>Two</div>\"}\n```\n\n### String.parseConfig([def], [noconvert])\n\nType: `method`\n\nAnalyse un texte de configuration de la forme `key1:value;key2:value`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String or Object` | no |  | La configuration par défaut que les valeurs analysées complètent. |\n| `noconvert` | `Boolean` | no | `false` | `true` conserve chaque valeur sous forme de chaîne. |\n\nReturns: `Object` La configuration analysée.\n\nLes valeurs `true` et `false` deviennent des booléens et les valeurs numériques des nombres. Une clé sans valeur reçoit une chaîne vide. Écris `\\;` pour conserver un point-virgule dans une valeur. Les clés et les valeurs peuvent contenir des expressions `[key]`, remplacées comme dans `env()`.\n\nExample: Analyse\n```js\nconsole.log('size:12;visible:true;title:Hello'.parseConfig()); // {\"size\":12,\"visible\":true,\"title\":\"Hello\"}\nconsole.log('size:12'.parseConfig('size:5;color:red')); // {\"size\":12,\"color\":\"red\"}\nconsole.log('size:12;visible:true'.parseConfig(null, true)); // {\"size\":\"12\",\"visible\":\"true\"}\nconsole.log('title:a\\\\;b;size:1'.parseConfig()); // {\"title\":\"a;b\",\"size\":1}\n```\n\n### String.parseDate([format])\n\nType: `method`\n\nConvertit une chaîne en `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | La disposition de la date. |\n\nReturns: `Date` La date analysée. Une chaîne vide sans `format` renvoie `null`, et un texte qui n'est pas une date renvoie une `Date` invalide.\n\nSans `format`, la méthode lit `yyyy-MM-dd` et `dd.MM.yyyy`, chacun avec une heure `HH:mm:ss` ou `HH:mm:ss.SSS` facultative et un `am` ou `pm` facultatif, une heure seule (qui utilise le jour actuel) et les dates JSON. Les expressions `[key]` sont d'abord remplacées, comme dans `env()`.\n\nAvec `format`, la méthode prend les chiffres de la chaîne dans l'ordre et les attribue aux jetons `yyyy`, `yy`, `MM`, `dd`, `HH`, `hh`, `mm` et `ss` : chaque valeur doit donc avoir autant de chiffres que son jeton. Quand la chaîne contient `am` ou `pm`, les heures sont lues sur 12 heures.\n\nExample: Formes courantes\n```js\nconsole.log('2026-11-18 14:30:15'.parseDate().format('dd.MM.yyyy HH:mm:ss')); // 18.11.2026 14:30:15\nconsole.log('18.11.2026 14:30'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18T10:00:00.000Z'.parseDate().toISOString()); // 2026-11-18T10:00:00.000Z\nconsole.log(''.parseDate()); // null\n```\n\nExample: Disposition personnalisée\n```js\nconsole.log('18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd')); // 2026-11-18\nconsole.log('11-18-26 14:05'.parseDate('MM-dd-yy HH:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:05\n```\n\nExample: Heures sur 12 heures\n```js\nconsole.log('2026-11-18 12:30 pm'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 12:30\nconsole.log('2026-11-18 12:30 am'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 00:30\nconsole.log('18/11/2026 02:30 pm'.parseDate('dd/MM/yyyy hh:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18 14:30:15.250'.parseDate().getMilliseconds()); // 250\n```\n\n### String.parseExpire()\n\nType: `method`\n\nConvertit une durée comme `5 minutes` en millisecondes.\n\nReturns: `Number` La durée en millisecondes.\n\nLa chaîne se compose d'un nombre, d'une espace et d'une unité. Un point dans l'unité est ignoré.\n\n| Unité | Noms acceptés |\n| --- | --- |\n| Secondes | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minutes | `minutes`, `minute`, `min`, `mm`, `m` |\n| Heures | `hours`, `hour`, `HH`, `hh`, `H`, `h` |\n| Jours | `days`, `day`, `DD`, `dd`, `d` |\n| Semaines | `weeks`, `week`, `W`, `w` |\n| Mois (28 jours) | `months`, `month`, `MM`, `M` |\n| Années (365 jours) | `years`, `year`, `yyyy`, `yy`, `y` |\n\nUne chaîne vide, un nombre sans unité, un texte qui ne commence pas par un nombre et une unité inconnue renvoient `0`.\n\nExample: Durées\n```js\nconsole.log('5 minutes'.parseExpire()); // 300000\nconsole.log('1 hour'.parseExpire()); // 3600000\nconsole.log('2 days'.parseExpire()); // 172800000\nconsole.log('none'.parseExpire()); // 0\n```\n\n### String.parseFloat([def])\n\nType: `method`\n\nLit un nombre décimal dans la chaîne.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | La valeur renvoyée quand la chaîne ne contient aucun nombre valide. |\n\nReturns: `Number` Le nombre analysé.\n\nLa méthode prend le premier nombre du texte et accepte un point ou une virgule comme séparateur décimal.\n\nExample: Lire des nombres\n```js\nconsole.log('12,5 kg'.parseFloat()); // 12.5\nconsole.log('-3.25'.parseFloat()); // -3.25\nconsole.log('abc'.parseFloat(1.5)); // 1.5\n```\n\n### String.parseInt([def])\n\nType: `method`\n\nLit un nombre entier dans la chaîne.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | La valeur renvoyée quand la chaîne ne contient aucun chiffre. |\n\nReturns: `Number` Le nombre analysé.\n\nLa méthode prend le premier groupe de chiffres du texte, avec son signe.\n\nExample: Lire des nombres\n```js\nconsole.log('12px'.parseInt()); // 12\nconsole.log('-3.9'.parseInt()); // -3\nconsole.log('abc'.parseInt(5)); // 5\n```\n\n### String.parseSource([type])\n\nType: `method`\n\nConvertit un texte de la forme `id|name|icon,id|name` en liste d'éléments.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Function or String` | no |  | Indique `Number` ou `'number'` pour convertir les identifiants en nombres. |\n\nReturns: `Array` Des objets avec les champs `id`, `name` et `icon`.\n\nUn nom manquant utilise l'identifiant et une icône manquante est une chaîne vide.\n\nExample: Construire une liste\n```js\nconsole.log('1|One|ti-star,2'.parseSource()); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti-star\"},{\"id\":\"2\",\"name\":\"2\",\"icon\":\"\"}]\nconsole.log('1|One'.parseSource(Number)); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"}]\n```\n\n### String.ROOT([noBase])\n\nType: `method`\n\nAjoute à une adresse la racine de l'application ou l'URL de base.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noBase` | `Boolean` | no | `false` | `true` ignore `DEF.baseurl`. |\n\nReturns: `String` L'adresse finale.\n\n`DEF.root` est utilisé en priorité, et `DEF.baseurl` quand il est vide. Chacun peut être une chaîne ou une fonction qui reçoit l'adresse et renvoie le résultat. Un préfixe de type chaîne n'est pas ajouté à une adresse absolue.\n\nExample: URL de base\n```js\nDEF.baseurl = '/app/';\nconsole.log('/api/users/'.ROOT()); // /app/api/users/\nconsole.log('/api/users/'.ROOT(true)); // /api/users/\nconsole.log('https://www.totaljs.com/'.ROOT()); // https://www.totaljs.com/\n```\n\n### String.slug([max])\n\nType: `method`\n\nConvertit un texte en minuscules pour l'utiliser dans une adresse.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `max` | `Number` | no | `60` | La longueur maximale. |\n\nReturns: `String` Le slug.\n\nLes signes diacritiques sont convertis avec `toASCII()`. Les espaces et la plupart des signes de ponctuation deviennent un seul tiret. Les lettres, les chiffres et les tirets bas sont conservés, et les autres caractères sont supprimés.\n\nExample: Créer des slugs\n```js\nconsole.log('Hello World! 2026'.slug()); // hello-world-2026\nconsole.log('Hello wonderful world'.slug(8)); // hello-wo\n```\n\n### String.toASCII()\n\nType: `method`\n\nRemplace les lettres accentuées par des lettres simples.\n\nReturns: `String` Le texte converti.\n\nLa méthode convertit les lettres á ä ć č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž et leurs formes majuscules. Les lettres conservent leur casse, et les autres caractères restent tels quels.\n\nExample: Supprimer les signes diacritiques\n```js\nconsole.log('Príliš žluťoučký kůň'.toASCII()); // Prilis zlutoucky kun\nconsole.log('Ťažký ñ'.toASCII()); // Tazky ñ\n```\n\n### String.toSearch()\n\nType: `method`\n\nNormalise un texte pour la comparaison en texte intégral.\n\nReturns: `String` Le texte normalisé.\n\nLa méthode supprime la ponctuation, convertit le texte en ASCII minuscule, remplace `y` par `i` et réduit les caractères répétés à un seul.\n\nExample: Normaliser\n```js\nconsole.log('Hello Yellow!'.toSearch()); // helo ielow\nconsole.log('Príliš žlté'.toSearch()); // prilis zlte\n```\n\n### String.VARIABLES([args])\n\nType: `method`\n\nRemplace les variables `--key--` dans la chaîne.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | Les valeurs des variables. |\n\nReturns: `String` La chaîne avec les variables remplacées.\n\nUne définition de la forme `--key=value--` est retirée du texte et définit la variable pour le reste de la chaîne. Une variable sans valeur reste dans le texte.\n\nExample: Utiliser des variables\n```js\nconsole.log('--color-- and --size--'.VARIABLES({ color: 'red' })); // red and --size--\nconsole.log('--color=blue--Color: --color--'.VARIABLES()); // Color: blue\n```\n","entries":[{"type":"method","name":"args()","signature":"String.args(obj, [encode])","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"String.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"String.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"String.flags([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"String.format([value0], [value1], [...])","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"String.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"String.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"String.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"String.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"String.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"String.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseComponent()","signature":"String.parseComponent(tags)","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"String.parseConfig([def], [noconvert])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"String.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"String.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"String.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"String.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"String.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"String.ROOT([noBase])","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"String.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"String.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"String.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"String.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYF9Mo61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/string/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"String","summary":"I metodi che jComponent aggiunge a String.prototype per formattare, analizzare, validare e pulire il testo.","markdown":"---\ntitle: String\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/string/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# String\n\n> I metodi che jComponent aggiunge a String.prototype per formattare, analizzare, validare e pulire il testo.\n\njComponent aggiunge questi metodi a ogni stringa. L'output di numeri e date segue le impostazioni di [DEF](../def/), i valori nella forma `[key]` provengono da [ENV()](../globals/) e i metodi che leggono la configurazione dei componenti vengono usati in [Creare componenti](../../guides/creating-components/).\n\n## API\n\n### String.args(obj, [encode])\n\nType: `method`\n\nSostituisce i segnaposto `{key}` e `{{ key }}` con i valori di un oggetto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | I valori per i segnaposto. |\n| `encode` | `String or Function` | no |  | Come scrivere ogni valore: `json` per `JSON.stringify()`, `encode` per `encodeURIComponent()`, `escape` per le entità HTML, oppure una funzione `(value, key)` che restituisce il testo. |\n\nReturns: `String` La stringa con i segnaposto sostituiti.\n\nUna chiave può essere un path annidato come `user.age`. Senza `encode`, una chiave assente dall'oggetto conserva il suo segnaposto e un valore `null` diventa una stringa vuota.\n\nExample: Segnaposto\n```js\nconsole.log('Hello {name}, age {{ user.age }}, {unknown}'.args({ name: 'Ana', user: { age: 30 } })); // Hello Ana, age 30, {unknown}\n```\n\nExample: Codificare i valori\n```js\nconsole.log('{a}'.args({ a: '<b>' }, 'escape')); // &lt;b&gt;\nconsole.log('{a}'.args({ a: 'x y' }, 'encode')); // x%20y\nconsole.log('{a}'.args({ a: 'x' }, 'json')); // \"x\"\nconsole.log('{a}|{b}'.args({ a: 1, b: 2 }, (value, key) => key + '=' + value)); // a=1|b=2\n```\n\n### String.encode()\n\nType: `method`\n\nConverte i caratteri `<`, `>`, `&` e `\"` in entità HTML.\n\nReturns: `String` Il testo con l'escape applicato.\n\nExample: Escape dell'HTML\n```js\nconsole.log('<a href=\"x\">T&C</a>'.encode()); // &lt;a href=&quot;x&quot;&gt;T&amp;C&lt;/a&gt;\n```\n\n### String.env()\n\nType: `method`\n\nSostituisce le espressioni `[key]` con i valori dell'ambiente.\n\nReturns: `String` La stringa con le espressioni note sostituite.\n\nUn'espressione `[key]` legge il valore impostato con [ENV()](../globals/). Un'espressione che inizia con un punto, come `[.app.name]`, legge un path da `window`. Un'espressione senza valore resta nel testo.\n\nExample: Valori dell'ambiente\n```js\nENV('name', 'Peter');\nwindow.app = { version: 5 };\nconsole.log('[name] [.app.version] [missing]'.env()); // Peter 5 [missing]\n```\n\n### String.flags([path])\n\nType: `method`\n\nRimuove i flag `@name` dal testo ed emette un evento per ogni flag che ha un listener.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Il valore passato ai listener dell'evento. |\n\nReturns: `String` Il testo senza spazi iniziali e finali e senza i flag.\n\nOgni flag emette l'evento `@flag name` con `path` come argomento. Vedi [Flag e modificatori di path](../../guides/flags/).\n\nExample: Leggere i flag\n```js\nvar seen = [];\nON('@flag reset', path => seen.push(path));\nconsole.log('form.name @reset @other'.flags('form.name')); // form.name\nconsole.log(seen); // [\"form.name\"]\n```\n\n### String.format([value0], [value1], [...])\n\nType: `method`\n\nSostituisce gli indici `{0}`, `{1}` e così via con gli argomenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value0` | `Object` | no |  | Il valore per `{0}`. Ogni argomento successivo riempie l'indice seguente. |\n\nReturns: `String` Il testo formattato.\n\nUn argomento di tipo array viene unito senza separatore. Un argomento mancante o `null` diventa una stringa vuota.\n\nExample: Valori indicizzati\n```js\nconsole.log('Hello {0}, you have {1} items{2}'.format('Ana', 3)); // Hello Ana, you have 3 items\nconsole.log('{0}'.format(['a', 'b'])); // ab\n```\n\n### String.isEmail()\n\nType: `method`\n\nControlla che la stringa sia un indirizzo email.\n\nReturns: `Boolean` `true` per un indirizzo valido.\n\nIl controllo usa il pattern in `DEF.regexp.email`.\n\nExample: Controllare gli indirizzi\n```js\nconsole.log('peter+news@total-js.com'.isEmail()); // true\nconsole.log('a@b'.isEmail()); // false\n```\n\n### String.isJSONDate()\n\nType: `method`\n\nControlla che la stringa sia una data serializzata in JSON.\n\nReturns: `Boolean` `true` per un valore nella forma `2026-11-18T10:00:00.000Z`.\n\nExample: Controllare le date\n```js\nconsole.log('2026-11-18T10:00:00.000Z'.isJSONDate()); // true\nconsole.log('2026-11-18'.isJSONDate()); // false\n```\n\n### String.isPhone()\n\nType: `method`\n\nControlla che la stringa sia un numero di telefono.\n\nReturns: `Boolean` `true` per un numero valido.\n\nIl controllo usa il pattern in `DEF.regexp.phone`: un `+` facoltativo, poi gruppi di tre, tre e da quattro a otto cifre. I gruppi possono essere separati da uno spazio, un trattino o un punto, e il primo può essere tra parentesi.\n\nExample: Controllare i numeri\n```js\nconsole.log('+421903123456'.isPhone()); // true\nconsole.log('(421) 903-1234'.isPhone()); // true\nconsole.log('12345'.isPhone()); // false\n```\n\n### String.isURL()\n\nType: `method`\n\nControlla che la stringa sia un indirizzo `http` o `https`.\n\nReturns: `Boolean` `true` per un indirizzo valido.\n\nIl controllo usa il pattern in `DEF.regexp.url`.\n\nExample: Controllare gli indirizzi\n```js\nconsole.log('https://www.totaljs.com/'.isURL()); // true\nconsole.log('ftp://totaljs.com/file'.isURL()); // false\nconsole.log('totaljs.com'.isURL()); // false\n```\n\n### String.padLeft(length, [char])\n\nType: `method`\n\nRiempie l'inizio della stringa fino a una determinata lunghezza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La lunghezza finale. |\n| `char` | `String` | no | `a space` | Il carattere di riempimento. |\n\nReturns: `String` Il testo riempito.\n\nUna stringa già abbastanza lunga viene restituita invariata.\n\nExample: Riempimento\n```js\nconsole.log('7'.padLeft(3, '0')); // 007\nconsole.log('abcd'.padLeft(2, '0')); // abcd\n```\n\n### String.padRight(length, [char])\n\nType: `method`\n\nRiempie la fine della stringa fino a una determinata lunghezza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La lunghezza finale. |\n| `char` | `String` | no | `a space` | Il carattere di riempimento. |\n\nReturns: `String` Il testo riempito.\n\nUna stringa già abbastanza lunga viene restituita invariata.\n\nExample: Riempimento\n```js\nconsole.log('7'.padRight(3, '-')); // 7--\n```\n\n### String.parseComponent(tags)\n\nType: `method`\n\nEstrae il contenuto dei tag HTML da una stringa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tags` | `Object` | yes |  | Le chiavi del risultato e i relativi tag di apertura. |\n\nReturns: `Object` Il contenuto trovato per ogni chiave.\n\nOgni chiave di `tags` contiene il tag di apertura esatto da cercare. I tag annidati con lo stesso nome restano nel contenuto. Un tag non trovato viene omesso dal risultato.\n\nExample: Suddividere un template\n```js\nvar html = '<style>b { color: red }</style><div>One<div>Two</div></div>';\nconsole.log(html.parseComponent({ css: '<style>', body: '<div>', none: '<nav>' })); // {\"css\":\"b { color: red }\",\"body\":\"One<div>Two</div>\"}\n```\n\n### String.parseConfig([def], [noconvert])\n\nType: `method`\n\nAnalizza un testo di configurazione nella forma `key1:value;key2:value`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String or Object` | no |  | La configurazione predefinita estesa dai valori analizzati. |\n| `noconvert` | `Boolean` | no | `false` | `true` mantiene ogni valore come stringa. |\n\nReturns: `Object` La configurazione analizzata.\n\nI valori `true` e `false` diventano booleani e i valori numerici diventano numeri. Una chiave senza valore riceve una stringa vuota. Scrivi `\\;` per mantenere un punto e virgola all'interno di un valore. Chiavi e valori possono contenere espressioni `[key]`, che vengono sostituite come in `env()`.\n\nExample: Analisi\n```js\nconsole.log('size:12;visible:true;title:Hello'.parseConfig()); // {\"size\":12,\"visible\":true,\"title\":\"Hello\"}\nconsole.log('size:12'.parseConfig('size:5;color:red')); // {\"size\":12,\"color\":\"red\"}\nconsole.log('size:12;visible:true'.parseConfig(null, true)); // {\"size\":\"12\",\"visible\":\"true\"}\nconsole.log('title:a\\\\;b;size:1'.parseConfig()); // {\"title\":\"a;b\",\"size\":1}\n```\n\n### String.parseDate([format])\n\nType: `method`\n\nConverte una stringa in un `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | Il layout della data. |\n\nReturns: `Date` La data analizzata. Una stringa vuota senza `format` restituisce `null`, mentre un testo che non è una data restituisce un `Date` non valido.\n\nSenza `format` il metodo legge `yyyy-MM-dd` e `dd.MM.yyyy`, entrambi con un orario `HH:mm:ss` o `HH:mm:ss.SSS` facoltativo e un `am` o `pm` facoltativo, un orario da solo (che usa il giorno corrente) e le date JSON. Le espressioni `[key]` vengono sostituite per prime, come in `env()`.\n\nCon `format` il metodo prende in ordine le cifre della stringa e le assegna ai token `yyyy`, `yy`, `MM`, `dd`, `HH`, `hh`, `mm` e `ss`, quindi ogni valore deve avere tante cifre quante ne ha il suo token. Quando la stringa contiene `am` o `pm`, le ore vengono lette nel formato a 12 ore.\n\nExample: Forme comuni\n```js\nconsole.log('2026-11-18 14:30:15'.parseDate().format('dd.MM.yyyy HH:mm:ss')); // 18.11.2026 14:30:15\nconsole.log('18.11.2026 14:30'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18T10:00:00.000Z'.parseDate().toISOString()); // 2026-11-18T10:00:00.000Z\nconsole.log(''.parseDate()); // null\n```\n\nExample: Layout personalizzato\n```js\nconsole.log('18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd')); // 2026-11-18\nconsole.log('11-18-26 14:05'.parseDate('MM-dd-yy HH:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:05\n```\n\nExample: Orari nel formato a 12 ore\n```js\nconsole.log('2026-11-18 12:30 pm'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 12:30\nconsole.log('2026-11-18 12:30 am'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 00:30\nconsole.log('18/11/2026 02:30 pm'.parseDate('dd/MM/yyyy hh:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18 14:30:15.250'.parseDate().getMilliseconds()); // 250\n```\n\n### String.parseExpire()\n\nType: `method`\n\nConverte una durata come `5 minutes` in millisecondi.\n\nReturns: `Number` La durata in millisecondi.\n\nLa stringa è composta da un numero, uno spazio e un'unità. Un punto nell'unità viene ignorato.\n\n| Unità | Nomi accettati |\n| --- | --- |\n| Secondi | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minuti | `minutes`, `minute`, `min`, `mm`, `m` |\n| Ore | `hours`, `hour`, `HH`, `hh`, `H`, `h` |\n| Giorni | `days`, `day`, `DD`, `dd`, `d` |\n| Settimane | `weeks`, `week`, `W`, `w` |\n| Mesi (28 giorni) | `months`, `month`, `MM`, `M` |\n| Anni (365 giorni) | `years`, `year`, `yyyy`, `yy`, `y` |\n\nUna stringa vuota, un numero senza unità, un testo che non inizia con un numero e un'unità sconosciuta restituiscono `0`.\n\nExample: Durate\n```js\nconsole.log('5 minutes'.parseExpire()); // 300000\nconsole.log('1 hour'.parseExpire()); // 3600000\nconsole.log('2 days'.parseExpire()); // 172800000\nconsole.log('none'.parseExpire()); // 0\n```\n\n### String.parseFloat([def])\n\nType: `method`\n\nLegge un numero decimale dalla stringa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Il valore restituito quando la stringa non contiene un numero valido. |\n\nReturns: `Number` Il numero analizzato.\n\nIl metodo prende il primo numero nel testo e accetta un punto o una virgola come separatore decimale.\n\nExample: Leggere i numeri\n```js\nconsole.log('12,5 kg'.parseFloat()); // 12.5\nconsole.log('-3.25'.parseFloat()); // -3.25\nconsole.log('abc'.parseFloat(1.5)); // 1.5\n```\n\n### String.parseInt([def])\n\nType: `method`\n\nLegge un numero intero dalla stringa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Il valore restituito quando la stringa non contiene cifre. |\n\nReturns: `Number` Il numero analizzato.\n\nIl metodo prende il primo gruppo di cifre nel testo, con il suo segno.\n\nExample: Leggere i numeri\n```js\nconsole.log('12px'.parseInt()); // 12\nconsole.log('-3.9'.parseInt()); // -3\nconsole.log('abc'.parseInt(5)); // 5\n```\n\n### String.parseSource([type])\n\nType: `method`\n\nConverte un testo nella forma `id|name|icon,id|name` in un elenco di elementi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Function or String` | no |  | Passa `Number` o `'number'` per convertire gli identificatori in numeri. |\n\nReturns: `Array` Oggetti con i campi `id`, `name` e `icon`.\n\nUn nome mancante usa l'identificatore e un'icona mancante è una stringa vuota.\n\nExample: Costruire un elenco\n```js\nconsole.log('1|One|ti-star,2'.parseSource()); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti-star\"},{\"id\":\"2\",\"name\":\"2\",\"icon\":\"\"}]\nconsole.log('1|One'.parseSource(Number)); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"}]\n```\n\n### String.ROOT([noBase])\n\nType: `method`\n\nAggiunge a un indirizzo la radice dell'applicazione o l'URL di base.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noBase` | `Boolean` | no | `false` | `true` ignora `DEF.baseurl`. |\n\nReturns: `String` L'indirizzo finale.\n\nViene usato prima `DEF.root` e, quando è vuoto, `DEF.baseurl`. Ognuno dei due può essere una stringa o una funzione che riceve l'indirizzo e restituisce il risultato. Un prefisso di tipo stringa non viene aggiunto a un indirizzo assoluto.\n\nExample: URL di base\n```js\nDEF.baseurl = '/app/';\nconsole.log('/api/users/'.ROOT()); // /app/api/users/\nconsole.log('/api/users/'.ROOT(true)); // /api/users/\nconsole.log('https://www.totaljs.com/'.ROOT()); // https://www.totaljs.com/\n```\n\n### String.slug([max])\n\nType: `method`\n\nConverte un testo in minuscolo per usarlo in un indirizzo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `max` | `Number` | no | `60` | La lunghezza massima. |\n\nReturns: `String` Lo slug.\n\nI segni diacritici vengono convertiti con `toASCII()`. Gli spazi e la maggior parte della punteggiatura diventano un singolo trattino. Lettere, cifre e trattini bassi restano, mentre gli altri caratteri vengono rimossi.\n\nExample: Creare slug\n```js\nconsole.log('Hello World! 2026'.slug()); // hello-world-2026\nconsole.log('Hello wonderful world'.slug(8)); // hello-wo\n```\n\n### String.toASCII()\n\nType: `method`\n\nSostituisce le lettere accentate con lettere semplici.\n\nReturns: `String` Il testo convertito.\n\nIl metodo converte le lettere á ä ć č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž e le relative forme maiuscole. Le lettere mantengono il maiuscolo o il minuscolo, e gli altri caratteri restano invariati.\n\nExample: Rimuovere i segni diacritici\n```js\nconsole.log('Príliš žluťoučký kůň'.toASCII()); // Prilis zlutoucky kun\nconsole.log('Ťažký ñ'.toASCII()); // Tazky ñ\n```\n\n### String.toSearch()\n\nType: `method`\n\nNormalizza il testo per il confronto full-text.\n\nReturns: `String` Il testo normalizzato.\n\nIl metodo rimuove la punteggiatura, converte il testo in ASCII minuscolo, sostituisce `y` con `i` e riduce a uno i caratteri ripetuti.\n\nExample: Normalizzazione\n```js\nconsole.log('Hello Yellow!'.toSearch()); // helo ielow\nconsole.log('Príliš žlté'.toSearch()); // prilis zlte\n```\n\n### String.VARIABLES([args])\n\nType: `method`\n\nSostituisce le variabili `--key--` nella stringa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | I valori delle variabili. |\n\nReturns: `String` La stringa con le variabili sostituite.\n\nUna definizione nella forma `--key=value--` viene rimossa dal testo e imposta la variabile per il resto della stringa. Una variabile senza valore resta nel testo.\n\nExample: Usare le variabili\n```js\nconsole.log('--color-- and --size--'.VARIABLES({ color: 'red' })); // red and --size--\nconsole.log('--color=blue--Color: --color--'.VARIABLES()); // Color: blue\n```\n","entries":[{"type":"method","name":"args()","signature":"String.args(obj, [encode])","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"String.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"String.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"String.flags([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"String.format([value0], [value1], [...])","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"String.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"String.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"String.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"String.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"String.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"String.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseComponent()","signature":"String.parseComponent(tags)","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"String.parseConfig([def], [noconvert])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"String.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"String.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"String.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"String.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"String.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"String.ROOT([noBase])","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"String.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"String.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"String.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"String.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcYF9Mo61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/string/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"String","summary":"Metódy, ktoré jComponent pridáva do String.prototype na formátovanie, analýzu, validáciu a čistenie textu.","markdown":"---\ntitle: String\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/string/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# String\n\n> Metódy, ktoré jComponent pridáva do String.prototype na formátovanie, analýzu, validáciu a čistenie textu.\n\njComponent pridáva tieto metódy každému reťazcu. Výstup čísel a dátumov sa riadi nastaveniami v [DEF](../def/), hodnoty v tvare `[key]` pochádzajú z [ENV()](../globals/) a metódy, ktoré čítajú konfiguráciu komponentu, sa používajú v časti [Vytváranie komponentov](../../guides/creating-components/).\n\n## API\n\n### String.args(obj, [encode])\n\nType: `method`\n\nNahradí zástupné symboly `{key}` a `{{ key }}` hodnotami z objektu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `obj` | `Object` | yes |  | Hodnoty pre zástupné symboly. |\n| `encode` | `String or Function` | no |  | Spôsob zápisu každej hodnoty: `json` pre `JSON.stringify()`, `encode` pre `encodeURIComponent()`, `escape` pre entity HTML alebo funkcia `(value, key)`, ktorá vracia text. |\n\nReturns: `String` Reťazec s nahradenými zástupnými symbolmi.\n\nKľúč môže byť vnorený path, napríklad `user.age`. Bez `encode` si kľúč, ktorý v objekte nie je, zachová zástupný symbol a hodnota `null` sa zmení na prázdny reťazec.\n\nExample: Zástupné symboly\n```js\nconsole.log('Hello {name}, age {{ user.age }}, {unknown}'.args({ name: 'Ana', user: { age: 30 } })); // Hello Ana, age 30, {unknown}\n```\n\nExample: Kódovanie hodnôt\n```js\nconsole.log('{a}'.args({ a: '<b>' }, 'escape')); // &lt;b&gt;\nconsole.log('{a}'.args({ a: 'x y' }, 'encode')); // x%20y\nconsole.log('{a}'.args({ a: 'x' }, 'json')); // \"x\"\nconsole.log('{a}|{b}'.args({ a: 1, b: 2 }, (value, key) => key + '=' + value)); // a=1|b=2\n```\n\n### String.encode()\n\nType: `method`\n\nEscapuje znaky `<`, `>`, `&` a `\"` ako entity HTML.\n\nReturns: `String` Escapovaný text.\n\nExample: Escapovanie HTML\n```js\nconsole.log('<a href=\"x\">T&C</a>'.encode()); // &lt;a href=&quot;x&quot;&gt;T&amp;C&lt;/a&gt;\n```\n\n### String.env()\n\nType: `method`\n\nNahradí frázy `[key]` hodnotami z prostredia.\n\nReturns: `String` Reťazec s nahradenými známymi frázami.\n\nFráza `[key]` prečíta hodnotu nastavenú pomocou [ENV()](../globals/). Fráza, ktorá sa začína bodkou, napríklad `[.app.name]`, prečíta path z `window`. Fráza bez hodnoty zostane v texte.\n\nExample: Hodnoty prostredia\n```js\nENV('name', 'Peter');\nwindow.app = { version: 5 };\nconsole.log('[name] [.app.version] [missing]'.env()); // Peter 5 [missing]\n```\n\n### String.flags([path])\n\nType: `method`\n\nOdstráni z textu flagy `@name` a pre každý flag, ktorý má poslucháča, vyšle udalosť.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `path` | `String` | no |  | Hodnota odovzdaná poslucháčom udalosti. |\n\nReturns: `String` Orezaný text bez flagov.\n\nKaždý flag vyšle udalosť `@flag name` s argumentom `path`. Pozri [Flagy a modifikátory path](../../guides/flags/).\n\nExample: Čítanie flagov\n```js\nvar seen = [];\nON('@flag reset', path => seen.push(path));\nconsole.log('form.name @reset @other'.flags('form.name')); // form.name\nconsole.log(seen); // [\"form.name\"]\n```\n\n### String.format([value0], [value1], [...])\n\nType: `method`\n\nNahradí indexy `{0}`, `{1}` a ďalšie argumentmi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value0` | `Object` | no |  | Hodnota pre `{0}`. Každý ďalší argument vyplní nasledujúci index. |\n\nReturns: `String` Naformátovaný text.\n\nArgument typu pole sa spojí bez oddeľovača. Chýbajúci argument alebo argument `null` sa zmení na prázdny reťazec.\n\nExample: Indexované hodnoty\n```js\nconsole.log('Hello {0}, you have {1} items{2}'.format('Ana', 3)); // Hello Ana, you have 3 items\nconsole.log('{0}'.format(['a', 'b'])); // ab\n```\n\n### String.isEmail()\n\nType: `method`\n\nOverí, či je reťazec e-mailová adresa.\n\nReturns: `Boolean` `true` pre platnú adresu.\n\nTest používa vzor v `DEF.regexp.email`.\n\nExample: Kontrola adries\n```js\nconsole.log('peter+news@total-js.com'.isEmail()); // true\nconsole.log('a@b'.isEmail()); // false\n```\n\n### String.isJSONDate()\n\nType: `method`\n\nOverí, či je reťazec dátum serializovaný do JSON.\n\nReturns: `Boolean` `true` pre hodnotu v tvare `2026-11-18T10:00:00.000Z`.\n\nExample: Kontrola dátumov\n```js\nconsole.log('2026-11-18T10:00:00.000Z'.isJSONDate()); // true\nconsole.log('2026-11-18'.isJSONDate()); // false\n```\n\n### String.isPhone()\n\nType: `method`\n\nOverí, či je reťazec telefónne číslo.\n\nReturns: `Boolean` `true` pre platné číslo.\n\nTest používa vzor v `DEF.regexp.phone`: voliteľné `+`, potom skupiny s tromi, tromi a štyrmi až ôsmimi číslicami. Skupiny môžu byť oddelené medzerou, pomlčkou alebo bodkou a prvá môže byť v zátvorkách.\n\nExample: Kontrola čísel\n```js\nconsole.log('+421903123456'.isPhone()); // true\nconsole.log('(421) 903-1234'.isPhone()); // true\nconsole.log('12345'.isPhone()); // false\n```\n\n### String.isURL()\n\nType: `method`\n\nOverí, či je reťazec adresa `http` alebo `https`.\n\nReturns: `Boolean` `true` pre platnú adresu.\n\nTest používa vzor v `DEF.regexp.url`.\n\nExample: Kontrola adries\n```js\nconsole.log('https://www.totaljs.com/'.isURL()); // true\nconsole.log('ftp://totaljs.com/file'.isURL()); // false\nconsole.log('totaljs.com'.isURL()); // false\n```\n\n### String.padLeft(length, [char])\n\nType: `method`\n\nDoplní začiatok reťazca na zadanú dĺžku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Výsledná dĺžka. |\n| `char` | `String` | no | `a space` | Výplňový znak. |\n\nReturns: `String` Doplnený text.\n\nReťazec, ktorý je už dostatočne dlhý, sa vráti nezmenený.\n\nExample: Dopĺňanie\n```js\nconsole.log('7'.padLeft(3, '0')); // 007\nconsole.log('abcd'.padLeft(2, '0')); // abcd\n```\n\n### String.padRight(length, [char])\n\nType: `method`\n\nDoplní koniec reťazca na zadanú dĺžku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Výsledná dĺžka. |\n| `char` | `String` | no | `a space` | Výplňový znak. |\n\nReturns: `String` Doplnený text.\n\nReťazec, ktorý je už dostatočne dlhý, sa vráti nezmenený.\n\nExample: Dopĺňanie\n```js\nconsole.log('7'.padRight(3, '-')); // 7--\n```\n\n### String.parseComponent(tags)\n\nType: `method`\n\nVyberie z reťazca obsah značiek HTML.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tags` | `Object` | yes |  | Kľúče výsledku a ich otváracie značky. |\n\nReturns: `Object` Obsah nájdený pre každý kľúč.\n\nKaždý kľúč v `tags` obsahuje presnú otváraciu značku, ktorá sa má hľadať. Vnorené značky s rovnakým názvom zostávajú v obsahu. Značka, ktorá sa nenájde, vo výsledku chýba.\n\nExample: Rozdelenie šablóny\n```js\nvar html = '<style>b { color: red }</style><div>One<div>Two</div></div>';\nconsole.log(html.parseComponent({ css: '<style>', body: '<div>', none: '<nav>' })); // {\"css\":\"b { color: red }\",\"body\":\"One<div>Two</div>\"}\n```\n\n### String.parseConfig([def], [noconvert])\n\nType: `method`\n\nAnalyzuje konfiguračný text v tvare `key1:value;key2:value`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `String or Object` | no |  | Predvolená konfigurácia, ktorú analyzované hodnoty rozširujú. |\n| `noconvert` | `Boolean` | no | `false` | `true` ponechá každú hodnotu ako reťazec. |\n\nReturns: `Object` Analyzovaná konfigurácia.\n\nHodnoty `true` a `false` sa zmenia na booleovské hodnoty a číselné hodnoty na čísla. Kľúč bez hodnoty dostane prázdny reťazec. Ak chceš zachovať bodkočiarku vnútri hodnoty, zapíš `\\;`. Kľúče a hodnoty môžu obsahovať frázy `[key]`, ktoré sa nahrádzajú ako v `env()`.\n\nExample: Analýza\n```js\nconsole.log('size:12;visible:true;title:Hello'.parseConfig()); // {\"size\":12,\"visible\":true,\"title\":\"Hello\"}\nconsole.log('size:12'.parseConfig('size:5;color:red')); // {\"size\":12,\"color\":\"red\"}\nconsole.log('size:12;visible:true'.parseConfig(null, true)); // {\"size\":\"12\",\"visible\":\"true\"}\nconsole.log('title:a\\\\;b;size:1'.parseConfig()); // {\"title\":\"a;b\",\"size\":1}\n```\n\n### String.parseDate([format])\n\nType: `method`\n\nPrevedie reťazec na `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no |  | Rozloženie dátumu. |\n\nReturns: `Date` Analyzovaný dátum. Prázdny reťazec bez `format` vráti `null` a text, ktorý nie je dátumom, vráti neplatný `Date`.\n\nBez `format` metóda číta `yyyy-MM-dd` a `dd.MM.yyyy`, oba s voliteľným časom `HH:mm:ss` alebo `HH:mm:ss.SSS` a voliteľným `am` alebo `pm`, samotný čas (použije aktuálny deň) a dátumy JSON. Frázy `[key]` sa najprv nahradia ako v `env()`.\n\nS `format` metóda berie číslice reťazca postupne a priraďuje ich tokenom `yyyy`, `yy`, `MM`, `dd`, `HH`, `hh`, `mm` a `ss`, takže každá hodnota musí mať toľko číslic ako jej token. Keď reťazec obsahuje `am` alebo `pm`, hodiny sa čítajú v 12-hodinovom formáte.\n\nExample: Bežné tvary\n```js\nconsole.log('2026-11-18 14:30:15'.parseDate().format('dd.MM.yyyy HH:mm:ss')); // 18.11.2026 14:30:15\nconsole.log('18.11.2026 14:30'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18T10:00:00.000Z'.parseDate().toISOString()); // 2026-11-18T10:00:00.000Z\nconsole.log(''.parseDate()); // null\n```\n\nExample: Vlastné rozloženie\n```js\nconsole.log('18/11/2026'.parseDate('dd/MM/yyyy').format('yyyy-MM-dd')); // 2026-11-18\nconsole.log('11-18-26 14:05'.parseDate('MM-dd-yy HH:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:05\n```\n\nExample: 12-hodinové časy\n```js\nconsole.log('2026-11-18 12:30 pm'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 12:30\nconsole.log('2026-11-18 12:30 am'.parseDate().format('yyyy-MM-dd HH:mm')); // 2026-11-18 00:30\nconsole.log('18/11/2026 02:30 pm'.parseDate('dd/MM/yyyy hh:mm').format('yyyy-MM-dd HH:mm')); // 2026-11-18 14:30\nconsole.log('2026-11-18 14:30:15.250'.parseDate().getMilliseconds()); // 250\n```\n\n### String.parseExpire()\n\nType: `method`\n\nPrevedie trvanie, napríklad `5 minutes`, na milisekundy.\n\nReturns: `Number` Trvanie v milisekundách.\n\nReťazec tvorí číslo, medzera a jednotka. Bodka v jednotke sa ignoruje.\n\n| Jednotka | Prijímané názvy |\n| --- | --- |\n| Sekundy | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minúty | `minutes`, `minute`, `min`, `mm`, `m` |\n| Hodiny | `hours`, `hour`, `HH`, `hh`, `H`, `h` |\n| Dni | `days`, `day`, `DD`, `dd`, `d` |\n| Týždne | `weeks`, `week`, `W`, `w` |\n| Mesiace (28 dní) | `months`, `month`, `MM`, `M` |\n| Roky (365 dní) | `years`, `year`, `yyyy`, `yy`, `y` |\n\nPrázdny reťazec, číslo bez jednotky, text, ktorý sa nezačína číslom, a neznáma jednotka vrátia `0`.\n\nExample: Trvania\n```js\nconsole.log('5 minutes'.parseExpire()); // 300000\nconsole.log('1 hour'.parseExpire()); // 3600000\nconsole.log('2 days'.parseExpire()); // 172800000\nconsole.log('none'.parseExpire()); // 0\n```\n\n### String.parseFloat([def])\n\nType: `method`\n\nPrečíta z reťazca desatinné číslo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Hodnota vrátená, keď reťazec neobsahuje platné číslo. |\n\nReturns: `Number` Analyzované číslo.\n\nMetóda vezme prvé číslo v texte a ako desatinný oddeľovač prijíma bodku alebo čiarku.\n\nExample: Čítanie čísel\n```js\nconsole.log('12,5 kg'.parseFloat()); // 12.5\nconsole.log('-3.25'.parseFloat()); // -3.25\nconsole.log('abc'.parseFloat(1.5)); // 1.5\n```\n\n### String.parseInt([def])\n\nType: `method`\n\nPrečíta z reťazca celé číslo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Number` | no | `0` | Hodnota vrátená, keď reťazec neobsahuje číslice. |\n\nReturns: `Number` Analyzované číslo.\n\nMetóda vezme prvú skupinu číslic v texte aj s jej znamienkom.\n\nExample: Čítanie čísel\n```js\nconsole.log('12px'.parseInt()); // 12\nconsole.log('-3.9'.parseInt()); // -3\nconsole.log('abc'.parseInt(5)); // 5\n```\n\n### String.parseSource([type])\n\nType: `method`\n\nPrevedie text v tvare `id|name|icon,id|name` na zoznam položiek.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `type` | `Function or String` | no |  | Ak chceš previesť identifikátory na čísla, odovzdaj `Number` alebo `'number'`. |\n\nReturns: `Array` Objekty s poľami `id`, `name` a `icon`.\n\nPri chýbajúcom názve sa použije identifikátor a chýbajúca ikona je prázdny reťazec.\n\nExample: Vytvorenie zoznamu\n```js\nconsole.log('1|One|ti-star,2'.parseSource()); // [{\"id\":\"1\",\"name\":\"One\",\"icon\":\"ti-star\"},{\"id\":\"2\",\"name\":\"2\",\"icon\":\"\"}]\nconsole.log('1|One'.parseSource(Number)); // [{\"id\":1,\"name\":\"One\",\"icon\":\"\"}]\n```\n\n### String.ROOT([noBase])\n\nType: `method`\n\nPridá k adrese koreň aplikácie alebo základnú URL.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `noBase` | `Boolean` | no | `false` | `true` ignoruje `DEF.baseurl`. |\n\nReturns: `String` Výsledná adresa.\n\nNajprv sa použije `DEF.root` a ak je prázdny, tak `DEF.baseurl`. Každý z nich môže byť reťazec alebo funkcia, ktorá dostane adresu a vráti výsledok. Reťazcový prefix sa k absolútnej adrese nepridáva.\n\nExample: Základná URL\n```js\nDEF.baseurl = '/app/';\nconsole.log('/api/users/'.ROOT()); // /app/api/users/\nconsole.log('/api/users/'.ROOT(true)); // /api/users/\nconsole.log('https://www.totaljs.com/'.ROOT()); // https://www.totaljs.com/\n```\n\n### String.slug([max])\n\nType: `method`\n\nPrevedie text na tvar s malými písmenami na použitie v adrese.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `max` | `Number` | no | `60` | Maximálna dĺžka. |\n\nReturns: `String` Slug.\n\nDiakritika sa prevedie pomocou `toASCII()`. Medzery a väčšina interpunkcie sa zmenia na jednu pomlčku. Písmená, číslice a podčiarkovníky zostávajú a ostatné znaky sa odstránia.\n\nExample: Vytváranie slugov\n```js\nconsole.log('Hello World! 2026'.slug()); // hello-world-2026\nconsole.log('Hello wonderful world'.slug(8)); // hello-wo\n```\n\n### String.toASCII()\n\nType: `method`\n\nNahradí písmená s diakritikou písmenami bez nej.\n\nReturns: `String` Prevedený text.\n\nMetóda prevádza písmená á ä ć č ď é ě í ï ĺ ľ ň ó ô ö ő ŕ ř š ť ú ů ü ű ý ÿ ž a ich veľké tvary. Písmená si zachovávajú veľkosť a ostatné znaky zostávajú nezmenené.\n\nExample: Odstránenie diakritiky\n```js\nconsole.log('Príliš žluťoučký kůň'.toASCII()); // Prilis zlutoucky kun\nconsole.log('Ťažký ñ'.toASCII()); // Tazky ñ\n```\n\n### String.toSearch()\n\nType: `method`\n\nNormalizuje text na fulltextové porovnávanie.\n\nReturns: `String` Normalizovaný text.\n\nMetóda odstráni interpunkciu, prevedie text na malé písmená ASCII, nahradí `y` za `i` a opakované znaky zredukuje na jeden.\n\nExample: Normalizácia\n```js\nconsole.log('Hello Yellow!'.toSearch()); // helo ielow\nconsole.log('Príliš žlté'.toSearch()); // prilis zlte\n```\n\n### String.VARIABLES([args])\n\nType: `method`\n\nNahradí premenné `--key--` v reťazci.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `args` | `Object` | no |  | Hodnoty premenných. |\n\nReturns: `String` Reťazec s nahradenými premennými.\n\nDefinícia v tvare `--key=value--` sa z textu odstráni a nastaví premennú pre zvyšok reťazca. Premenná bez hodnoty zostane v texte.\n\nExample: Používanie premenných\n```js\nconsole.log('--color-- and --size--'.VARIABLES({ color: 'red' })); // red and --size--\nconsole.log('--color=blue--Color: --color--'.VARIABLES()); // Color: blue\n```\n","entries":[{"type":"method","name":"args()","signature":"String.args(obj, [encode])","since":"","deprecated":false},{"type":"method","name":"encode()","signature":"String.encode()","since":"","deprecated":false},{"type":"method","name":"env()","signature":"String.env()","since":"","deprecated":false},{"type":"method","name":"flags()","signature":"String.flags([path])","since":"","deprecated":false},{"type":"method","name":"format()","signature":"String.format([value0], [value1], [...])","since":"","deprecated":false},{"type":"method","name":"isEmail()","signature":"String.isEmail()","since":"","deprecated":false},{"type":"method","name":"isJSONDate()","signature":"String.isJSONDate()","since":"","deprecated":false},{"type":"method","name":"isPhone()","signature":"String.isPhone()","since":"","deprecated":false},{"type":"method","name":"isURL()","signature":"String.isURL()","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"String.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"String.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseComponent()","signature":"String.parseComponent(tags)","since":"","deprecated":false},{"type":"method","name":"parseConfig()","signature":"String.parseConfig([def], [noconvert])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"String.parseDate([format])","since":"","deprecated":false},{"type":"method","name":"parseExpire()","signature":"String.parseExpire()","since":"","deprecated":false},{"type":"method","name":"parseFloat()","signature":"String.parseFloat([def])","since":"","deprecated":false},{"type":"method","name":"parseInt()","signature":"String.parseInt([def])","since":"","deprecated":false},{"type":"method","name":"parseSource()","signature":"String.parseSource([type])","since":"","deprecated":false},{"type":"method","name":"ROOT()","signature":"String.ROOT([noBase])","since":"","deprecated":false},{"type":"method","name":"slug()","signature":"String.slug([max])","since":"","deprecated":false},{"type":"method","name":"toASCII()","signature":"String.toASCII()","since":"","deprecated":false},{"type":"method","name":"toSearch()","signature":"String.toSearch()","since":"","deprecated":false},{"type":"method","name":"VARIABLES()","signature":"String.VARIABLES([args])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcWN7Ao61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/number/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"Number","summary":"Methods that jComponent adds to Number.prototype for formatting, rounding, calculating and pluralizing.","markdown":"---\ntitle: Number\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/number/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Number\n\n> Methods that jComponent adds to Number.prototype for formatting, rounding, calculating and pluralizing.\n\njComponent adds these methods to every number. The default separators and currencies are set in [DEF](../def/), and the same formatting is available in templates through the [Tangular helpers](../tangular-helpers/).\n\n## API\n\n### Number.add(value, [decimals])\n\nType: `method`\n\nCalculates a new number from an operation written as a string.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String or Number` | yes |  | The operation, or a number to add. |\n| `decimals` | `Number` | no |  | Cuts the result to this number of decimal places. |\n\nReturns: `Number` The result.\n\nA number is added to the value. The string starts with the operator `+`, `-`, `*` or `/`. The forms `+10%` and `-10%` add or subtract a percentage of the number, and `10%` returns that percentage. `inc()` is an alias of this method.\n\nExample: Operations\n```js\nconsole.log((100).add('+10')); // 110\nconsole.log((100).add(10)); // 110\nconsole.log((100).add('*2')); // 200\nconsole.log((100).add('/4')); // 25\nconsole.log((100).add('-10%')); // 90\nconsole.log((200).add('10%')); // 20\nconsole.log((10).add('/3', 2)); // 3.33\nconsole.log((100).inc('+5')); // 105\n```\n\n### Number.currency([name], [a], [b], [c])\n\nType: `method`\n\nFormats the number with a currency registered in `DEF.currencies`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | The currency name, or a `[key]` phrase that holds it. |\n| `a` | `Object` | no |  | Custom argument for the currency function. |\n| `b` | `Object` | no |  | Custom argument for the currency function. |\n| `c` | `Object` | no |  | Custom argument for the currency function. |\n\nReturns: `String` The formatted price.\n\nA currency is a function that receives the number and the arguments `a`, `b` and `c`. A name that is not registered formats the number with two decimal places.\n\nExample: Registering a currency\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currencies.usd = (value, suffix) => '$' + value.format(2) + suffix;\nconsole.log((1234.5).currency('eur')); // 1 234.50 EUR\nconsole.log((1234.5).currency('usd', ' net')); // $1 234.50 net\nconsole.log((1234.5).currency('unknown')); // 1 234.50\n```\n\n### Number.floor(decimals)\n\nType: `method`\n\nRounds the number down to a number of decimal places.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | yes |  | The decimal places to keep. |\n\nReturns: `Number` The rounded number.\n\nExample: Rounding down\n```js\nconsole.log((1.987).floor(2)); // 1.98\nconsole.log((1.987).floor(0)); // 1\nconsole.log((-1.981).floor(1)); // -2\n```\n\n### Number.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nWrites the number with thousands and decimal separators.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | The decimal places, or a `[key]` phrase. |\n| `separator` | `String` | no | `DEF.thousandsseparator` | The thousands separator. |\n| `decimalSeparator` | `String` | no | `DEF.decimalseparator` | The decimal separator. |\n\nReturns: `String` The formatted number.\n\nExtra decimal places are rounded. Missing decimal places are filled with zeros. A number in exponential notation is written in full. When `decimals` is omitted the number keeps its own decimal part.\n\nThe first argument can also be a `[key]` phrase for a value set with [ENV()](../globals/). The value is the number of decimals or an object with the fields `decimals`, `separator` and `decimalseparator`.\n\nExample: Formatting\n```js\nconsole.log((1234567.891).format()); // 1 234 567.891\nconsole.log((1234.5).format(2)); // 1 234.50\nconsole.log((1.999).format(2)); // 2.00\nconsole.log((0.0000001).format()); // 0.0000001\nconsole.log((1234.5).format(2, '.', ',')); // 1.234,50\n```\n\nExample: Environment formats\n```js\nENV('money', { decimals: 2, separator: ',', decimalseparator: '.' });\nconsole.log((1234.5).format('[money]')); // 1,234.50\n```\n\n### Number.padLeft(length, [char])\n\nType: `method`\n\nWrites the number as text and fills its start up to a length.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | The final length. |\n| `char` | `String` | no | `0` | The fill character. |\n\nReturns: `String` The padded text.\n\nExample: Padding\n```js\nconsole.log((7).padLeft(3)); // 007\nconsole.log((7).padLeft(3, '_')); // __7\n```\n\n### Number.padRight(length, [char])\n\nType: `method`\n\nWrites the number as text and fills its end up to a length.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | The final length. |\n| `char` | `String` | no | `0` | The fill character. |\n\nReturns: `String` The padded text.\n\nExample: Padding\n```js\nconsole.log((7).padRight(3)); // 700\nconsole.log((7).padRight(3, '_')); // 7__\n```\n\n### Number.parseDate([offset])\n\nType: `method`\n\nConverts a timestamp in milliseconds to a `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | Milliseconds added to the timestamp. |\n\nReturns: `Date` The date.\n\nExample: Timestamps\n```js\nconsole.log((1700000000000).parseDate().toISOString()); // 2023-11-14T22:13:20.000Z\nconsole.log((1700000000000).parseDate(3600000).toISOString()); // 2023-11-14T23:13:20.000Z\n```\n\n### Number.pluralize(zero, one, few, other)\n\nType: `method`\n\nSelects the text that matches the number.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | The text for 0, or all the forms. |\n| `one` | `String` | no |  | The text for 1. |\n| `few` | `String` | no |  | The text for numbers from 2 to 4. |\n| `other` | `String` | no |  | The text for other numbers. |\n\nReturns: `String` The selected text.\n\n`zero` is used for 0, `one` for 1, `few` for numbers greater than 1 and lower than 5, and `other` for the rest. In the selected text `#` writes the number and `##` writes it formatted with `format()`.\n\nAll four forms can also be passed as one array, as one comma-separated string, or as a `[key]` phrase that holds that string.\n\nExample: Four forms\n```js\nconsole.log((0).pluralize('no items', '# item', '# items', '## items')); // no items\nconsole.log((1).pluralize('no items', '# item', '# items', '## items')); // 1 item\nconsole.log((3).pluralize('no items', '# item', '# items', '## items')); // 3 items\nconsole.log((1234).pluralize('no items', '# item', '# items', '## items')); // 1 234 items\n```\n\nExample: One value with all the forms\n```js\nconsole.log((7).pluralize('none,one,few,many')); // many\nconsole.log((3).pluralize(['none', 'one', 'few', 'many'])); // few\n```\n\n### Number.round([decimals])\n\nType: `method`\n\nRounds the number to a number of decimal places.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | no | `0` | The decimal places to keep. |\n\nReturns: `Number` The rounded number.\n\nA negative value rounds to tens, hundreds and so on.\n\nExample: Rounding\n```js\nconsole.log((1.005).round(2)); // 1.01\nconsole.log((1.5).round()); // 2\nconsole.log((1234.5).round(-2)); // 1200\n```\n","entries":[{"type":"method","name":"add()","signature":"Number.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"Number.currency([name], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"Number.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Number.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"Number.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"Number.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"Number.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"Number.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"Number.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcWN7Ao61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/number/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"Number","summary":"Methoden, die jComponent zu Number.prototype hinzufügt, um zu formatieren, zu runden, zu rechnen und Pluralformen zu wählen.","markdown":"---\ntitle: Number\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/number/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Number\n\n> Methoden, die jComponent zu Number.prototype hinzufügt, um zu formatieren, zu runden, zu rechnen und Pluralformen zu wählen.\n\njComponent fügt diese Methoden jeder Zahl hinzu. Die Standardtrennzeichen und Währungen werden in [DEF](../def/) festgelegt, und dieselbe Formatierung steht in Templates über die [Tangular-Helper](../tangular-helpers/) zur Verfügung.\n\n## API\n\n### Number.add(value, [decimals])\n\nType: `method`\n\nBerechnet eine neue Zahl aus einer als String geschriebenen Operation.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String or Number` | yes |  | Die Operation oder eine Zahl, die addiert wird. |\n| `decimals` | `Number` | no |  | Kürzt das Ergebnis auf diese Anzahl von Dezimalstellen. |\n\nReturns: `Number` Das Ergebnis.\n\nEine Zahl wird zum Wert addiert. Der String beginnt mit dem Operator `+`, `-`, `*` oder `/`. Die Formen `+10%` und `-10%` addieren oder subtrahieren einen Prozentsatz der Zahl, und `10%` gibt diesen Prozentsatz zurück. `inc()` ist ein Alias dieser Methode.\n\nExample: Operationen\n```js\nconsole.log((100).add('+10')); // 110\nconsole.log((100).add(10)); // 110\nconsole.log((100).add('*2')); // 200\nconsole.log((100).add('/4')); // 25\nconsole.log((100).add('-10%')); // 90\nconsole.log((200).add('10%')); // 20\nconsole.log((10).add('/3', 2)); // 3.33\nconsole.log((100).inc('+5')); // 105\n```\n\n### Number.currency([name], [a], [b], [c])\n\nType: `method`\n\nFormatiert die Zahl mit einer in `DEF.currencies` registrierten Währung.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | Der Name der Währung oder ein `[key]`-Ausdruck, der ihn enthält. |\n| `a` | `Object` | no |  | Eigenes Argument für die Währungsfunktion. |\n| `b` | `Object` | no |  | Eigenes Argument für die Währungsfunktion. |\n| `c` | `Object` | no |  | Eigenes Argument für die Währungsfunktion. |\n\nReturns: `String` Der formatierte Preis.\n\nEine Währung ist eine Funktion, die die Zahl und die Argumente `a`, `b` und `c` erhält. Bei einem nicht registrierten Namen wird die Zahl mit zwei Dezimalstellen formatiert.\n\nExample: Währung registrieren\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currencies.usd = (value, suffix) => '$' + value.format(2) + suffix;\nconsole.log((1234.5).currency('eur')); // 1 234.50 EUR\nconsole.log((1234.5).currency('usd', ' net')); // $1 234.50 net\nconsole.log((1234.5).currency('unknown')); // 1 234.50\n```\n\n### Number.floor(decimals)\n\nType: `method`\n\nRundet die Zahl auf eine Anzahl von Dezimalstellen ab.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | yes |  | Die beizubehaltenden Dezimalstellen. |\n\nReturns: `Number` Die gerundete Zahl.\n\nExample: Abrunden\n```js\nconsole.log((1.987).floor(2)); // 1.98\nconsole.log((1.987).floor(0)); // 1\nconsole.log((-1.981).floor(1)); // -2\n```\n\n### Number.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nSchreibt die Zahl mit Tausender- und Dezimaltrennzeichen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | Die Dezimalstellen oder ein `[key]`-Ausdruck. |\n| `separator` | `String` | no | `DEF.thousandsseparator` | Das Tausendertrennzeichen. |\n| `decimalSeparator` | `String` | no | `DEF.decimalseparator` | Das Dezimaltrennzeichen. |\n\nReturns: `String` Die formatierte Zahl.\n\nÜberzählige Dezimalstellen werden gerundet. Fehlende Dezimalstellen werden mit Nullen aufgefüllt. Eine Zahl in Exponentialschreibweise wird vollständig ausgeschrieben. Wenn du `decimals` weglässt, behält die Zahl ihren eigenen Dezimalteil.\n\nDas erste Argument kann auch ein `[key]`-Ausdruck für einen mit [ENV()](../globals/) gesetzten Wert sein. Der Wert ist die Anzahl der Dezimalstellen oder ein Objekt mit den Feldern `decimals`, `separator` und `decimalseparator`.\n\nExample: Formatierung\n```js\nconsole.log((1234567.891).format()); // 1 234 567.891\nconsole.log((1234.5).format(2)); // 1 234.50\nconsole.log((1.999).format(2)); // 2.00\nconsole.log((0.0000001).format()); // 0.0000001\nconsole.log((1234.5).format(2, '.', ',')); // 1.234,50\n```\n\nExample: Formate aus der Umgebung\n```js\nENV('money', { decimals: 2, separator: ',', decimalseparator: '.' });\nconsole.log((1234.5).format('[money]')); // 1,234.50\n```\n\n### Number.padLeft(length, [char])\n\nType: `method`\n\nSchreibt die Zahl als Text und füllt ihren Anfang bis zu einer bestimmten Länge auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Die endgültige Länge. |\n| `char` | `String` | no | `0` | Das Füllzeichen. |\n\nReturns: `String` Der aufgefüllte Text.\n\nExample: Auffüllen\n```js\nconsole.log((7).padLeft(3)); // 007\nconsole.log((7).padLeft(3, '_')); // __7\n```\n\n### Number.padRight(length, [char])\n\nType: `method`\n\nSchreibt die Zahl als Text und füllt ihr Ende bis zu einer bestimmten Länge auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Die endgültige Länge. |\n| `char` | `String` | no | `0` | Das Füllzeichen. |\n\nReturns: `String` Der aufgefüllte Text.\n\nExample: Auffüllen\n```js\nconsole.log((7).padRight(3)); // 700\nconsole.log((7).padRight(3, '_')); // 7__\n```\n\n### Number.parseDate([offset])\n\nType: `method`\n\nWandelt einen Zeitstempel in Millisekunden in ein `Date` um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | Millisekunden, die zum Zeitstempel addiert werden. |\n\nReturns: `Date` Das Datum.\n\nExample: Zeitstempel\n```js\nconsole.log((1700000000000).parseDate().toISOString()); // 2023-11-14T22:13:20.000Z\nconsole.log((1700000000000).parseDate(3600000).toISOString()); // 2023-11-14T23:13:20.000Z\n```\n\n### Number.pluralize(zero, one, few, other)\n\nType: `method`\n\nWählt den Text aus, der zur Zahl passt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Der Text für 0 oder alle Formen. |\n| `one` | `String` | no |  | Der Text für 1. |\n| `few` | `String` | no |  | Der Text für Zahlen von 2 bis 4. |\n| `other` | `String` | no |  | Der Text für andere Zahlen. |\n\nReturns: `String` Der ausgewählte Text.\n\n`zero` wird für 0 verwendet, `one` für 1, `few` für Zahlen größer als 1 und kleiner als 5 und `other` für alle übrigen. Im ausgewählten Text schreibt `#` die Zahl und `##` die mit `format()` formatierte Zahl.\n\nAlle vier Formen lassen sich auch als ein Array, als ein durch Kommas getrennter String oder als `[key]`-Ausdruck übergeben, der diesen String enthält.\n\nExample: Vier Formen\n```js\nconsole.log((0).pluralize('no items', '# item', '# items', '## items')); // no items\nconsole.log((1).pluralize('no items', '# item', '# items', '## items')); // 1 item\nconsole.log((3).pluralize('no items', '# item', '# items', '## items')); // 3 items\nconsole.log((1234).pluralize('no items', '# item', '# items', '## items')); // 1 234 items\n```\n\nExample: Ein Wert mit allen Formen\n```js\nconsole.log((7).pluralize('none,one,few,many')); // many\nconsole.log((3).pluralize(['none', 'one', 'few', 'many'])); // few\n```\n\n### Number.round([decimals])\n\nType: `method`\n\nRundet die Zahl auf eine Anzahl von Dezimalstellen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | no | `0` | Die beizubehaltenden Dezimalstellen. |\n\nReturns: `Number` Die gerundete Zahl.\n\nEin negativer Wert rundet auf Zehner, Hunderter und so weiter.\n\nExample: Runden\n```js\nconsole.log((1.005).round(2)); // 1.01\nconsole.log((1.5).round()); // 2\nconsole.log((1234.5).round(-2)); // 1200\n```\n","entries":[{"type":"method","name":"add()","signature":"Number.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"Number.currency([name], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"Number.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Number.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"Number.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"Number.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"Number.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"Number.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"Number.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcWN7Ao61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/number/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Number","summary":"Métodos que jComponent añade a Number.prototype para dar formato, redondear, calcular y pluralizar.","markdown":"---\ntitle: Number\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/number/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Number\n\n> Métodos que jComponent añade a Number.prototype para dar formato, redondear, calcular y pluralizar.\n\njComponent añade estos métodos a todos los números. Los separadores y las monedas predeterminados se establecen en [DEF](../def/), y el mismo formato está disponible en las plantillas mediante los [helpers de Tangular](../tangular-helpers/).\n\n## API\n\n### Number.add(value, [decimals])\n\nType: `method`\n\nCalcula un número nuevo a partir de una operación escrita como cadena.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String or Number` | yes |  | La operación, o un número que se suma. |\n| `decimals` | `Number` | no |  | Recorta el resultado a este número de decimales. |\n\nReturns: `Number` El resultado.\n\nSe suma un número al valor. La cadena empieza por el operador `+`, `-`, `*` o `/`. Las formas `+10%` y `-10%` suman o restan un porcentaje del número, y `10%` devuelve ese porcentaje. `inc()` es un alias de este método.\n\nExample: Operaciones\n```js\nconsole.log((100).add('+10')); // 110\nconsole.log((100).add(10)); // 110\nconsole.log((100).add('*2')); // 200\nconsole.log((100).add('/4')); // 25\nconsole.log((100).add('-10%')); // 90\nconsole.log((200).add('10%')); // 20\nconsole.log((10).add('/3', 2)); // 3.33\nconsole.log((100).inc('+5')); // 105\n```\n\n### Number.currency([name], [a], [b], [c])\n\nType: `method`\n\nDa formato al número con una moneda registrada en `DEF.currencies`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | El nombre de la moneda, o una frase `[key]` que lo contiene. |\n| `a` | `Object` | no |  | Un argumento personalizado para la función de la moneda. |\n| `b` | `Object` | no |  | Un argumento personalizado para la función de la moneda. |\n| `c` | `Object` | no |  | Un argumento personalizado para la función de la moneda. |\n\nReturns: `String` El precio con formato.\n\nUna moneda es una función que recibe el número y los argumentos `a`, `b` y `c`. Un nombre que no está registrado da formato al número con dos decimales.\n\nExample: Registrar una moneda\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currencies.usd = (value, suffix) => '$' + value.format(2) + suffix;\nconsole.log((1234.5).currency('eur')); // 1 234.50 EUR\nconsole.log((1234.5).currency('usd', ' net')); // $1 234.50 net\nconsole.log((1234.5).currency('unknown')); // 1 234.50\n```\n\n### Number.floor(decimals)\n\nType: `method`\n\nRedondea el número hacia abajo a un número de decimales.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | yes |  | Los decimales que se conservan. |\n\nReturns: `Number` El número redondeado.\n\nExample: Redondear hacia abajo\n```js\nconsole.log((1.987).floor(2)); // 1.98\nconsole.log((1.987).floor(0)); // 1\nconsole.log((-1.981).floor(1)); // -2\n```\n\n### Number.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nEscribe el número con separadores de miles y de decimales.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | Los decimales, o una frase `[key]`. |\n| `separator` | `String` | no | `DEF.thousandsseparator` | El separador de miles. |\n| `decimalSeparator` | `String` | no | `DEF.decimalseparator` | El separador decimal. |\n\nReturns: `String` El número con formato.\n\nLos decimales sobrantes se redondean. Los decimales que faltan se rellenan con ceros. Un número en notación exponencial se escribe completo. Cuando se omite `decimals`, el número conserva su propia parte decimal.\n\nEl primer argumento también puede ser una frase `[key]` para un valor establecido con [ENV()](../globals/). El valor es el número de decimales o un objeto con los campos `decimals`, `separator` y `decimalseparator`.\n\nExample: Formato\n```js\nconsole.log((1234567.891).format()); // 1 234 567.891\nconsole.log((1234.5).format(2)); // 1 234.50\nconsole.log((1.999).format(2)); // 2.00\nconsole.log((0.0000001).format()); // 0.0000001\nconsole.log((1234.5).format(2, '.', ',')); // 1.234,50\n```\n\nExample: Formatos del entorno\n```js\nENV('money', { decimals: 2, separator: ',', decimalseparator: '.' });\nconsole.log((1234.5).format('[money]')); // 1,234.50\n```\n\n### Number.padLeft(length, [char])\n\nType: `method`\n\nEscribe el número como texto y rellena su inicio hasta una longitud.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longitud final. |\n| `char` | `String` | no | `0` | El carácter de relleno. |\n\nReturns: `String` El texto rellenado.\n\nExample: Relleno\n```js\nconsole.log((7).padLeft(3)); // 007\nconsole.log((7).padLeft(3, '_')); // __7\n```\n\n### Number.padRight(length, [char])\n\nType: `method`\n\nEscribe el número como texto y rellena su final hasta una longitud.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longitud final. |\n| `char` | `String` | no | `0` | El carácter de relleno. |\n\nReturns: `String` El texto rellenado.\n\nExample: Relleno\n```js\nconsole.log((7).padRight(3)); // 700\nconsole.log((7).padRight(3, '_')); // 7__\n```\n\n### Number.parseDate([offset])\n\nType: `method`\n\nConvierte una marca de tiempo en milisegundos en un `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | Los milisegundos que se suman a la marca de tiempo. |\n\nReturns: `Date` La fecha.\n\nExample: Marcas de tiempo\n```js\nconsole.log((1700000000000).parseDate().toISOString()); // 2023-11-14T22:13:20.000Z\nconsole.log((1700000000000).parseDate(3600000).toISOString()); // 2023-11-14T23:13:20.000Z\n```\n\n### Number.pluralize(zero, one, few, other)\n\nType: `method`\n\nSelecciona el texto que corresponde al número.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | El texto para 0, o todas las formas. |\n| `one` | `String` | no |  | El texto para 1. |\n| `few` | `String` | no |  | El texto para los números del 2 al 4. |\n| `other` | `String` | no |  | El texto para los demás números. |\n\nReturns: `String` El texto seleccionado.\n\n`zero` se usa para 0, `one` para 1, `few` para los números mayores que 1 y menores que 5, y `other` para el resto. En el texto seleccionado, `#` escribe el número y `##` lo escribe con el formato de `format()`.\n\nLas cuatro formas también se pueden pasar como un solo array, como una sola cadena separada por comas o como una frase `[key]` que contiene esa cadena.\n\nExample: Cuatro formas\n```js\nconsole.log((0).pluralize('no items', '# item', '# items', '## items')); // no items\nconsole.log((1).pluralize('no items', '# item', '# items', '## items')); // 1 item\nconsole.log((3).pluralize('no items', '# item', '# items', '## items')); // 3 items\nconsole.log((1234).pluralize('no items', '# item', '# items', '## items')); // 1 234 items\n```\n\nExample: Un valor con todas las formas\n```js\nconsole.log((7).pluralize('none,one,few,many')); // many\nconsole.log((3).pluralize(['none', 'one', 'few', 'many'])); // few\n```\n\n### Number.round([decimals])\n\nType: `method`\n\nRedondea el número a un número de decimales.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | no | `0` | Los decimales que se conservan. |\n\nReturns: `Number` El número redondeado.\n\nUn valor negativo redondea a decenas, centenas, etc.\n\nExample: Redondear\n```js\nconsole.log((1.005).round(2)); // 1.01\nconsole.log((1.5).round()); // 2\nconsole.log((1234.5).round(-2)); // 1200\n```\n","entries":[{"type":"method","name":"add()","signature":"Number.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"Number.currency([name], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"Number.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Number.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"Number.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"Number.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"Number.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"Number.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"Number.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcWN7Ao61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/number/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Number","summary":"Les méthodes que jComponent ajoute à Number.prototype pour formater, arrondir, calculer et gérer le pluriel.","markdown":"---\ntitle: Number\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/number/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Number\n\n> Les méthodes que jComponent ajoute à Number.prototype pour formater, arrondir, calculer et gérer le pluriel.\n\njComponent ajoute ces méthodes à chaque nombre. Les séparateurs et les devises par défaut se définissent dans [DEF](../def/), et le même formatage est disponible dans les modèles grâce aux [helpers Tangular](../tangular-helpers/).\n\n## API\n\n### Number.add(value, [decimals])\n\nType: `method`\n\nCalcule un nouveau nombre à partir d'une opération écrite sous forme de chaîne.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String or Number` | yes |  | L'opération, ou un nombre à ajouter. |\n| `decimals` | `Number` | no |  | Tronque le résultat à ce nombre de décimales. |\n\nReturns: `Number` Le résultat.\n\nUn nombre est ajouté à la valeur. La chaîne commence par l'opérateur `+`, `-`, `*` ou `/`. Les formes `+10%` et `-10%` ajoutent ou soustraient un pourcentage du nombre, et `10%` renvoie ce pourcentage. `inc()` est un alias de cette méthode.\n\nExample: Opérations\n```js\nconsole.log((100).add('+10')); // 110\nconsole.log((100).add(10)); // 110\nconsole.log((100).add('*2')); // 200\nconsole.log((100).add('/4')); // 25\nconsole.log((100).add('-10%')); // 90\nconsole.log((200).add('10%')); // 20\nconsole.log((10).add('/3', 2)); // 3.33\nconsole.log((100).inc('+5')); // 105\n```\n\n### Number.currency([name], [a], [b], [c])\n\nType: `method`\n\nFormate le nombre avec une devise enregistrée dans `DEF.currencies`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | Le nom de la devise, ou une expression `[key]` qui le contient. |\n| `a` | `Object` | no |  | Un argument personnalisé pour la fonction de la devise. |\n| `b` | `Object` | no |  | Un argument personnalisé pour la fonction de la devise. |\n| `c` | `Object` | no |  | Un argument personnalisé pour la fonction de la devise. |\n\nReturns: `String` Le prix formaté.\n\nUne devise est une fonction qui reçoit le nombre et les arguments `a`, `b` et `c`. Un nom non enregistré formate le nombre avec deux décimales.\n\nExample: Enregistrer une devise\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currencies.usd = (value, suffix) => '$' + value.format(2) + suffix;\nconsole.log((1234.5).currency('eur')); // 1 234.50 EUR\nconsole.log((1234.5).currency('usd', ' net')); // $1 234.50 net\nconsole.log((1234.5).currency('unknown')); // 1 234.50\n```\n\n### Number.floor(decimals)\n\nType: `method`\n\nArrondit le nombre vers le bas à un nombre de décimales donné.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | yes |  | Le nombre de décimales à conserver. |\n\nReturns: `Number` Le nombre arrondi.\n\nExample: Arrondir vers le bas\n```js\nconsole.log((1.987).floor(2)); // 1.98\nconsole.log((1.987).floor(0)); // 1\nconsole.log((-1.981).floor(1)); // -2\n```\n\n### Number.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nÉcrit le nombre avec des séparateurs de milliers et de décimales.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | Le nombre de décimales, ou une expression `[key]`. |\n| `separator` | `String` | no | `DEF.thousandsseparator` | Le séparateur de milliers. |\n| `decimalSeparator` | `String` | no | `DEF.decimalseparator` | Le séparateur décimal. |\n\nReturns: `String` Le nombre formaté.\n\nLes décimales en trop sont arrondies. Les décimales manquantes sont complétées par des zéros. Un nombre en notation exponentielle est écrit en entier. Quand `decimals` est omis, le nombre conserve sa propre partie décimale.\n\nLe premier argument peut aussi être une expression `[key]` pour une valeur définie avec [ENV()](../globals/). La valeur est le nombre de décimales ou un objet avec les champs `decimals`, `separator` et `decimalseparator`.\n\nExample: Formatage\n```js\nconsole.log((1234567.891).format()); // 1 234 567.891\nconsole.log((1234.5).format(2)); // 1 234.50\nconsole.log((1.999).format(2)); // 2.00\nconsole.log((0.0000001).format()); // 0.0000001\nconsole.log((1234.5).format(2, '.', ',')); // 1.234,50\n```\n\nExample: Formats de l'environnement\n```js\nENV('money', { decimals: 2, separator: ',', decimalseparator: '.' });\nconsole.log((1234.5).format('[money]')); // 1,234.50\n```\n\n### Number.padLeft(length, [char])\n\nType: `method`\n\nÉcrit le nombre sous forme de texte et complète son début jusqu'à une longueur donnée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longueur finale. |\n| `char` | `String` | no | `0` | Le caractère de remplissage. |\n\nReturns: `String` Le texte complété.\n\nExample: Remplissage\n```js\nconsole.log((7).padLeft(3)); // 007\nconsole.log((7).padLeft(3, '_')); // __7\n```\n\n### Number.padRight(length, [char])\n\nType: `method`\n\nÉcrit le nombre sous forme de texte et complète sa fin jusqu'à une longueur donnée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La longueur finale. |\n| `char` | `String` | no | `0` | Le caractère de remplissage. |\n\nReturns: `String` Le texte complété.\n\nExample: Remplissage\n```js\nconsole.log((7).padRight(3)); // 700\nconsole.log((7).padRight(3, '_')); // 7__\n```\n\n### Number.parseDate([offset])\n\nType: `method`\n\nConvertit un horodatage en millisecondes en `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | Les millisecondes ajoutées à l'horodatage. |\n\nReturns: `Date` La date.\n\nExample: Horodatages\n```js\nconsole.log((1700000000000).parseDate().toISOString()); // 2023-11-14T22:13:20.000Z\nconsole.log((1700000000000).parseDate(3600000).toISOString()); // 2023-11-14T23:13:20.000Z\n```\n\n### Number.pluralize(zero, one, few, other)\n\nType: `method`\n\nSélectionne le texte qui correspond au nombre.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Le texte pour 0, ou toutes les formes. |\n| `one` | `String` | no |  | Le texte pour 1. |\n| `few` | `String` | no |  | Le texte pour les nombres de 2 à 4. |\n| `other` | `String` | no |  | Le texte pour les autres nombres. |\n\nReturns: `String` Le texte sélectionné.\n\n`zero` est utilisé pour 0, `one` pour 1, `few` pour les nombres supérieurs à 1 et inférieurs à 5, et `other` pour le reste. Dans le texte sélectionné, `#` écrit le nombre et `##` l'écrit formaté avec `format()`.\n\nLes quatre formes peuvent aussi être passées dans un seul tableau, dans une seule chaîne séparée par des virgules ou dans une expression `[key]` qui contient cette chaîne.\n\nExample: Quatre formes\n```js\nconsole.log((0).pluralize('no items', '# item', '# items', '## items')); // no items\nconsole.log((1).pluralize('no items', '# item', '# items', '## items')); // 1 item\nconsole.log((3).pluralize('no items', '# item', '# items', '## items')); // 3 items\nconsole.log((1234).pluralize('no items', '# item', '# items', '## items')); // 1 234 items\n```\n\nExample: Une seule valeur avec toutes les formes\n```js\nconsole.log((7).pluralize('none,one,few,many')); // many\nconsole.log((3).pluralize(['none', 'one', 'few', 'many'])); // few\n```\n\n### Number.round([decimals])\n\nType: `method`\n\nArrondit le nombre à un nombre de décimales donné.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | no | `0` | Le nombre de décimales à conserver. |\n\nReturns: `Number` Le nombre arrondi.\n\nUne valeur négative arrondit à la dizaine, à la centaine et ainsi de suite.\n\nExample: Arrondir\n```js\nconsole.log((1.005).round(2)); // 1.01\nconsole.log((1.5).round()); // 2\nconsole.log((1234.5).round(-2)); // 1200\n```\n","entries":[{"type":"method","name":"add()","signature":"Number.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"Number.currency([name], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"Number.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Number.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"Number.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"Number.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"Number.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"Number.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"Number.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcWN7Ao61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/number/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Number","summary":"I metodi che jComponent aggiunge a Number.prototype per formattare, arrotondare, calcolare e gestire i plurali.","markdown":"---\ntitle: Number\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/number/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Number\n\n> I metodi che jComponent aggiunge a Number.prototype per formattare, arrotondare, calcolare e gestire i plurali.\n\njComponent aggiunge questi metodi a ogni numero. I separatori e le valute predefiniti si impostano in [DEF](../def/), e la stessa formattazione è disponibile nei template tramite gli [helper di Tangular](../tangular-helpers/).\n\n## API\n\n### Number.add(value, [decimals])\n\nType: `method`\n\nCalcola un nuovo numero a partire da un'operazione scritta come stringa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String or Number` | yes |  | L'operazione, oppure un numero da sommare. |\n| `decimals` | `Number` | no |  | Tronca il risultato a questo numero di cifre decimali. |\n\nReturns: `Number` Il risultato.\n\nUn numero viene sommato al valore. La stringa inizia con l'operatore `+`, `-`, `*` o `/`. Le forme `+10%` e `-10%` aggiungono o sottraggono una percentuale del numero, mentre `10%` restituisce quella percentuale. `inc()` è un alias di questo metodo.\n\nExample: Operazioni\n```js\nconsole.log((100).add('+10')); // 110\nconsole.log((100).add(10)); // 110\nconsole.log((100).add('*2')); // 200\nconsole.log((100).add('/4')); // 25\nconsole.log((100).add('-10%')); // 90\nconsole.log((200).add('10%')); // 20\nconsole.log((10).add('/3', 2)); // 3.33\nconsole.log((100).inc('+5')); // 105\n```\n\n### Number.currency([name], [a], [b], [c])\n\nType: `method`\n\nFormatta il numero con una valuta registrata in `DEF.currencies`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | Il nome della valuta, oppure un'espressione `[key]` che lo contiene. |\n| `a` | `Object` | no |  | Un argomento personalizzato per la funzione della valuta. |\n| `b` | `Object` | no |  | Un argomento personalizzato per la funzione della valuta. |\n| `c` | `Object` | no |  | Un argomento personalizzato per la funzione della valuta. |\n\nReturns: `String` Il prezzo formattato.\n\nUna valuta è una funzione che riceve il numero e gli argomenti `a`, `b` e `c`. Un nome non registrato formatta il numero con due cifre decimali.\n\nExample: Registrare una valuta\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currencies.usd = (value, suffix) => '$' + value.format(2) + suffix;\nconsole.log((1234.5).currency('eur')); // 1 234.50 EUR\nconsole.log((1234.5).currency('usd', ' net')); // $1 234.50 net\nconsole.log((1234.5).currency('unknown')); // 1 234.50\n```\n\n### Number.floor(decimals)\n\nType: `method`\n\nArrotonda il numero per difetto a un determinato numero di cifre decimali.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | yes |  | Le cifre decimali da mantenere. |\n\nReturns: `Number` Il numero arrotondato.\n\nExample: Arrotondare per difetto\n```js\nconsole.log((1.987).floor(2)); // 1.98\nconsole.log((1.987).floor(0)); // 1\nconsole.log((-1.981).floor(1)); // -2\n```\n\n### Number.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nScrive il numero con i separatori delle migliaia e dei decimali.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | Le cifre decimali, oppure un'espressione `[key]`. |\n| `separator` | `String` | no | `DEF.thousandsseparator` | Il separatore delle migliaia. |\n| `decimalSeparator` | `String` | no | `DEF.decimalseparator` | Il separatore decimale. |\n\nReturns: `String` Il numero formattato.\n\nLe cifre decimali in eccesso vengono arrotondate. Quelle mancanti vengono riempite con zeri. Un numero in notazione esponenziale viene scritto per intero. Quando `decimals` è omesso, il numero mantiene la propria parte decimale.\n\nIl primo argomento può essere anche un'espressione `[key]` per un valore impostato con [ENV()](../globals/). Il valore è il numero di decimali oppure un oggetto con i campi `decimals`, `separator` e `decimalseparator`.\n\nExample: Formattazione\n```js\nconsole.log((1234567.891).format()); // 1 234 567.891\nconsole.log((1234.5).format(2)); // 1 234.50\nconsole.log((1.999).format(2)); // 2.00\nconsole.log((0.0000001).format()); // 0.0000001\nconsole.log((1234.5).format(2, '.', ',')); // 1.234,50\n```\n\nExample: Formati dall'ambiente\n```js\nENV('money', { decimals: 2, separator: ',', decimalseparator: '.' });\nconsole.log((1234.5).format('[money]')); // 1,234.50\n```\n\n### Number.padLeft(length, [char])\n\nType: `method`\n\nScrive il numero come testo e ne riempie l'inizio fino a una determinata lunghezza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La lunghezza finale. |\n| `char` | `String` | no | `0` | Il carattere di riempimento. |\n\nReturns: `String` Il testo riempito.\n\nExample: Riempimento\n```js\nconsole.log((7).padLeft(3)); // 007\nconsole.log((7).padLeft(3, '_')); // __7\n```\n\n### Number.padRight(length, [char])\n\nType: `method`\n\nScrive il numero come testo e ne riempie la fine fino a una determinata lunghezza.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | La lunghezza finale. |\n| `char` | `String` | no | `0` | Il carattere di riempimento. |\n\nReturns: `String` Il testo riempito.\n\nExample: Riempimento\n```js\nconsole.log((7).padRight(3)); // 700\nconsole.log((7).padRight(3, '_')); // 7__\n```\n\n### Number.parseDate([offset])\n\nType: `method`\n\nConverte un timestamp in millisecondi in un `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | I millisecondi aggiunti al timestamp. |\n\nReturns: `Date` La data.\n\nExample: Timestamp\n```js\nconsole.log((1700000000000).parseDate().toISOString()); // 2023-11-14T22:13:20.000Z\nconsole.log((1700000000000).parseDate(3600000).toISOString()); // 2023-11-14T23:13:20.000Z\n```\n\n### Number.pluralize(zero, one, few, other)\n\nType: `method`\n\nSeleziona il testo che corrisponde al numero.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Il testo per 0, oppure tutte le forme. |\n| `one` | `String` | no |  | Il testo per 1. |\n| `few` | `String` | no |  | Il testo per i numeri da 2 a 4. |\n| `other` | `String` | no |  | Il testo per gli altri numeri. |\n\nReturns: `String` Il testo selezionato.\n\n`zero` viene usato per 0, `one` per 1, `few` per i numeri maggiori di 1 e minori di 5 e `other` per tutti gli altri. Nel testo selezionato `#` scrive il numero e `##` lo scrive formattato con `format()`.\n\nTutte e quattro le forme possono essere passate anche come un unico array, come un'unica stringa separata da virgole o come un'espressione `[key]` che contiene quella stringa.\n\nExample: Quattro forme\n```js\nconsole.log((0).pluralize('no items', '# item', '# items', '## items')); // no items\nconsole.log((1).pluralize('no items', '# item', '# items', '## items')); // 1 item\nconsole.log((3).pluralize('no items', '# item', '# items', '## items')); // 3 items\nconsole.log((1234).pluralize('no items', '# item', '# items', '## items')); // 1 234 items\n```\n\nExample: Un unico valore con tutte le forme\n```js\nconsole.log((7).pluralize('none,one,few,many')); // many\nconsole.log((3).pluralize(['none', 'one', 'few', 'many'])); // few\n```\n\n### Number.round([decimals])\n\nType: `method`\n\nArrotonda il numero a un determinato numero di cifre decimali.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | no | `0` | Le cifre decimali da mantenere. |\n\nReturns: `Number` Il numero arrotondato.\n\nUn valore negativo arrotonda alle decine, alle centinaia e così via.\n\nExample: Arrotondamento\n```js\nconsole.log((1.005).round(2)); // 1.01\nconsole.log((1.5).round()); // 2\nconsole.log((1234.5).round(-2)); // 1200\n```\n","entries":[{"type":"method","name":"add()","signature":"Number.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"Number.currency([name], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"Number.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Number.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"Number.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"Number.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"Number.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"Number.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"Number.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcWN7Ao61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/number/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Number","summary":"Metódy, ktoré jComponent pridáva do Number.prototype na formátovanie, zaokrúhľovanie, výpočty a skloňovanie podľa počtu.","markdown":"---\ntitle: Number\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/number/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Number\n\n> Metódy, ktoré jComponent pridáva do Number.prototype na formátovanie, zaokrúhľovanie, výpočty a skloňovanie podľa počtu.\n\njComponent pridáva tieto metódy každému číslu. Predvolené oddeľovače a meny sa nastavujú v [DEF](../def/) a rovnaké formátovanie je dostupné v šablónach cez [helpery Tangularu](../tangular-helpers/).\n\n## API\n\n### Number.add(value, [decimals])\n\nType: `method`\n\nVypočíta nové číslo z operácie zapísanej ako reťazec.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String or Number` | yes |  | Operácia alebo číslo, ktoré sa pripočíta. |\n| `decimals` | `Number` | no |  | Oreže výsledok na tento počet desatinných miest. |\n\nReturns: `Number` Výsledok.\n\nČíslo sa k hodnote pripočíta. Reťazec sa začína operátorom `+`, `-`, `*` alebo `/`. Tvary `+10%` a `-10%` pričítajú alebo odpočítajú percento z čísla a `10%` vráti toto percento. `inc()` je alias tejto metódy.\n\nExample: Operácie\n```js\nconsole.log((100).add('+10')); // 110\nconsole.log((100).add(10)); // 110\nconsole.log((100).add('*2')); // 200\nconsole.log((100).add('/4')); // 25\nconsole.log((100).add('-10%')); // 90\nconsole.log((200).add('10%')); // 20\nconsole.log((10).add('/3', 2)); // 3.33\nconsole.log((100).inc('+5')); // 105\n```\n\n### Number.currency([name], [a], [b], [c])\n\nType: `method`\n\nNaformátuje číslo pomocou meny zaregistrovanej v `DEF.currencies`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no | `DEF.currency` | Názov meny alebo fráza `[key]`, ktorá ho obsahuje. |\n| `a` | `Object` | no |  | Vlastný argument pre funkciu meny. |\n| `b` | `Object` | no |  | Vlastný argument pre funkciu meny. |\n| `c` | `Object` | no |  | Vlastný argument pre funkciu meny. |\n\nReturns: `String` Naformátovaná cena.\n\nMena je funkcia, ktorá dostane číslo a argumenty `a`, `b` a `c`. Názov, ktorý nie je zaregistrovaný, naformátuje číslo na dve desatinné miesta.\n\nExample: Registrácia meny\n```js\nDEF.currencies.eur = value => value.format(2) + ' EUR';\nDEF.currencies.usd = (value, suffix) => '$' + value.format(2) + suffix;\nconsole.log((1234.5).currency('eur')); // 1 234.50 EUR\nconsole.log((1234.5).currency('usd', ' net')); // $1 234.50 net\nconsole.log((1234.5).currency('unknown')); // 1 234.50\n```\n\n### Number.floor(decimals)\n\nType: `method`\n\nZaokrúhli číslo nadol na zadaný počet desatinných miest.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | yes |  | Počet desatinných miest, ktoré sa majú zachovať. |\n\nReturns: `Number` Zaokrúhlené číslo.\n\nExample: Zaokrúhľovanie nadol\n```js\nconsole.log((1.987).floor(2)); // 1.98\nconsole.log((1.987).floor(0)); // 1\nconsole.log((-1.981).floor(1)); // -2\n```\n\n### Number.format([decimals], [separator], [decimalSeparator])\n\nType: `method`\n\nZapíše číslo s oddeľovačmi tisícov a desatinných miest.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number or String` | no |  | Počet desatinných miest alebo fráza `[key]`. |\n| `separator` | `String` | no | `DEF.thousandsseparator` | Oddeľovač tisícov. |\n| `decimalSeparator` | `String` | no | `DEF.decimalseparator` | Desatinný oddeľovač. |\n\nReturns: `String` Naformátované číslo.\n\nNadbytočné desatinné miesta sa zaokrúhlia. Chýbajúce desatinné miesta sa doplnia nulami. Číslo v exponenciálnom zápise sa vypíše celé. Keď `decimals` vynecháš, číslo si zachová vlastnú desatinnú časť.\n\nPrvým argumentom môže byť aj fráza `[key]` pre hodnotu nastavenú pomocou [ENV()](../globals/). Hodnotou je počet desatinných miest alebo objekt s poľami `decimals`, `separator` a `decimalseparator`.\n\nExample: Formátovanie\n```js\nconsole.log((1234567.891).format()); // 1 234 567.891\nconsole.log((1234.5).format(2)); // 1 234.50\nconsole.log((1.999).format(2)); // 2.00\nconsole.log((0.0000001).format()); // 0.0000001\nconsole.log((1234.5).format(2, '.', ',')); // 1.234,50\n```\n\nExample: Formáty z prostredia\n```js\nENV('money', { decimals: 2, separator: ',', decimalseparator: '.' });\nconsole.log((1234.5).format('[money]')); // 1,234.50\n```\n\n### Number.padLeft(length, [char])\n\nType: `method`\n\nZapíše číslo ako text a doplní jeho začiatok na zadanú dĺžku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Výsledná dĺžka. |\n| `char` | `String` | no | `0` | Výplňový znak. |\n\nReturns: `String` Doplnený text.\n\nExample: Dopĺňanie\n```js\nconsole.log((7).padLeft(3)); // 007\nconsole.log((7).padLeft(3, '_')); // __7\n```\n\n### Number.padRight(length, [char])\n\nType: `method`\n\nZapíše číslo ako text a doplní jeho koniec na zadanú dĺžku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `length` | `Number` | yes |  | Výsledná dĺžka. |\n| `char` | `String` | no | `0` | Výplňový znak. |\n\nReturns: `String` Doplnený text.\n\nExample: Dopĺňanie\n```js\nconsole.log((7).padRight(3)); // 700\nconsole.log((7).padRight(3, '_')); // 7__\n```\n\n### Number.parseDate([offset])\n\nType: `method`\n\nPrevedie časovú značku v milisekundách na `Date`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `offset` | `Number` | no | `0` | Milisekundy pridané k časovej značke. |\n\nReturns: `Date` Dátum.\n\nExample: Časové značky\n```js\nconsole.log((1700000000000).parseDate().toISOString()); // 2023-11-14T22:13:20.000Z\nconsole.log((1700000000000).parseDate(3600000).toISOString()); // 2023-11-14T23:13:20.000Z\n```\n\n### Number.pluralize(zero, one, few, other)\n\nType: `method`\n\nVyberie text zodpovedajúci číslu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `zero` | `String or Array` | yes |  | Text pre 0 alebo všetky tvary. |\n| `one` | `String` | no |  | Text pre 1. |\n| `few` | `String` | no |  | Text pre čísla od 2 do 4. |\n| `other` | `String` | no |  | Text pre ostatné čísla. |\n\nReturns: `String` Vybraný text.\n\n`zero` sa použije pre 0, `one` pre 1, `few` pre čísla väčšie ako 1 a menšie ako 5 a `other` pre ostatné. Vo vybranom texte `#` zapíše číslo a `##` ho zapíše naformátované pomocou `format()`.\n\nVšetky štyri tvary môžeš odovzdať aj ako jedno pole, ako jeden reťazec oddelený čiarkami alebo ako frázu `[key]`, ktorá tento reťazec obsahuje.\n\nExample: Štyri tvary\n```js\nconsole.log((0).pluralize('no items', '# item', '# items', '## items')); // no items\nconsole.log((1).pluralize('no items', '# item', '# items', '## items')); // 1 item\nconsole.log((3).pluralize('no items', '# item', '# items', '## items')); // 3 items\nconsole.log((1234).pluralize('no items', '# item', '# items', '## items')); // 1 234 items\n```\n\nExample: Jedna hodnota so všetkými tvarmi\n```js\nconsole.log((7).pluralize('none,one,few,many')); // many\nconsole.log((3).pluralize(['none', 'one', 'few', 'many'])); // few\n```\n\n### Number.round([decimals])\n\nType: `method`\n\nZaokrúhli číslo na zadaný počet desatinných miest.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `decimals` | `Number` | no | `0` | Počet desatinných miest, ktoré sa majú zachovať. |\n\nReturns: `Number` Zaokrúhlené číslo.\n\nZáporná hodnota zaokrúhľuje na desiatky, stovky a podobne.\n\nExample: Zaokrúhľovanie\n```js\nconsole.log((1.005).round(2)); // 1.01\nconsole.log((1.5).round()); // 2\nconsole.log((1234.5).round(-2)); // 1200\n```\n","entries":[{"type":"method","name":"add()","signature":"Number.add(value, [decimals])","since":"","deprecated":false},{"type":"method","name":"currency()","signature":"Number.currency([name], [a], [b], [c])","since":"","deprecated":false},{"type":"method","name":"floor()","signature":"Number.floor(decimals)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Number.format([decimals], [separator], [decimalSeparator])","since":"","deprecated":false},{"type":"method","name":"padLeft()","signature":"Number.padLeft(length, [char])","since":"","deprecated":false},{"type":"method","name":"padRight()","signature":"Number.padRight(length, [char])","since":"","deprecated":false},{"type":"method","name":"parseDate()","signature":"Number.parseDate([offset])","since":"","deprecated":false},{"type":"method","name":"pluralize()","signature":"Number.pluralize(zero, one, few, other)","since":"","deprecated":false},{"type":"method","name":"round()","signature":"Number.round([decimals])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcNq26d61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/array/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"Array","summary":"Methods that jComponent adds to Array.prototype for searching, sorting, slicing and processing lists.","markdown":"---\ntitle: Array\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/array/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Array\n\n> Methods that jComponent adds to Array.prototype for searching, sorting, slicing and processing lists.\n\njComponent adds these methods to every array. Lists prepared with them are often rendered with [Templates with Tangular](../../guides/tangular/).\n\n## API\n\n### Array.attr(name, [value])\n\nType: `method`\n\nAdds an HTML attribute as text to the array.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The attribute name. |\n| `value` | `Object` | no |  | The attribute value. |\n\nReturns: `Array` The same array.\n\nThe value is escaped and `[key]` phrases in it are replaced as in [env()](../string/). Without `value` the attribute name is also its value. A `null` value adds nothing.\n\nExample: Building attributes\n```js\nvar attrs = [];\nattrs.attr('id', 'box').attr('title', '<b>').attr('disabled').attr('hidden', null);\nconsole.log(attrs.join(' ')); // id=\"box\" title=\"&lt;b&gt;\" disabled=\"disabled\"\n```\n\n### Array.findAll(filter, [value])\n\nType: `method`\n\nReturns all the items that match.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | The field name, the test function or the value to find. |\n| `value` | `Object` | no |  | The value of the field. |\n\nReturns: `Array` A new array with the matching items.\n\nWith `filter` and `value`, the method compares the field named `filter` with `value`. With a function, it receives `(item, index)`. With one other value, it compares the items themselves.\n\nExample: Finding items\n```js\nconsole.log([{ a: 1 }, { a: 2 }, { a: 1 }].findAll('a', 1)); // [{\"a\":1},{\"a\":1}]\nconsole.log([1, 2, 3].findAll(value => value > 1)); // [2,3]\nconsole.log([1, 2, 1].findAll(1)); // [1,1]\n```\n\n### Array.findIndex(filter, [value])\n\nType: `method`\n\nReturns the index of the first item that matches.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | The field name, the test function or the value to find. |\n| `value` | `Object` | no |  | The value of the field. |\n\nReturns: `Number` The index, or `-1` when nothing matches.\n\nThe arguments work as in `findAll()`.\n\nExample: Finding an index\n```js\nconsole.log([{ a: 1 }, { a: 2 }].findIndex('a', 2)); // 1\nconsole.log([5, 6].findIndex((value, index) => index === 1)); // 1\nconsole.log([1, 2].findIndex(9)); // -1\n```\n\n### Array.findItem(filter, [value])\n\nType: `method`\n\nReturns the first item that matches.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | The field name, the test function or the value to find. |\n| `value` | `Object` | no |  | The value of the field. |\n\nReturns: `Object` The item, or `undefined` when nothing matches.\n\nThe arguments work as in `findAll()`.\n\nExample: Finding an item\n```js\nconsole.log([{ id: 1, name: 'A' }].findItem('id', 1)); // {\"id\":1,\"name\":\"A\"}\nconsole.log([1, 2, 3].findItem(value => value > 1)); // 2\nconsole.log([1].findItem(9) === undefined); // true\n```\n\n### Array.findValue(filter, value, field, [def], [cache])\n\nType: `method`\n\nReturns one field of the first item that matches.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String or Function` | yes |  | The field to compare, or the test function. |\n| `value` | `Object` | yes |  | The value of the compared field. |\n| `field` | `String` | yes |  | The name of the field to return. |\n| `def` | `Object` | no |  | The value returned when no item matches or the field is empty. |\n| `cache` | `Boolean` | no | `false` | Keeps the result for later calls. |\n\nReturns: `Object` The value of the field.\n\nWith a function as the filter, the signature is `findValue(fn, field, [def], [cache])`. A nested `field` is written with dots, for example `user.age`.\n\nWith `cache` set to `true`, the result is kept in [TEMP](../globals/) under a key made of the filter, the value and the field. A later call with the same arguments returns the kept result, even for another array.\n\nExample: Reading a field\n```js\nvar users = [{ id: 1, name: 'Ana' }];\nconsole.log(users.findValue('id', 1, 'name')); // Ana\nconsole.log(users.findValue('id', 9, 'name', 'nobody')); // nobody\nconsole.log(users.findValue(user => user.id === 1, 'name', 'nobody')); // Ana\nconsole.log([{ id: 1, user: { age: 5 } }].findValue('id', 1, 'user.age')); // 5\n```\n\n### Array.group(key)\n\nType: `method`\n\nGroups the items by the value of a field.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | The field name. |\n\nReturns: `Array` Objects with the fields `name` and `items`.\n\nThe groups are sorted by name. Items without the field are in a group with an empty name.\n\nExample: Grouping\n```js\nvar list = [{ type: 'b', id: 1 }, { type: 'a', id: 2 }, { type: 'b', id: 3 }];\nconsole.log(list.group('type')); // [{\"name\":\"a\",\"items\":[{\"type\":\"a\",\"id\":2}]},{\"name\":\"b\",\"items\":[{\"type\":\"b\",\"id\":1},{\"type\":\"b\",\"id\":3}]}]\n```\n\n### Array.last([def])\n\nType: `method`\n\nReturns the last item.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | The value returned for an empty array. |\n\nReturns: `Object` The last item or `def`.\n\nExample: Last item\n```js\nconsole.log([1, 2, 3].last()); // 3\nconsole.log([].last('empty')); // empty\n```\n\n### Array.quicksort([sort], [direction])\n\nType: `method`\n\nSorts the array in place.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | The fields to sort by. |\n| `direction` | `Boolean, String or Number` | no |  | `false`, `desc` or `2` sorts one field in descending order. |\n\nReturns: `Array` The same array.\n\nWithout arguments, the items are sorted in ascending order and compared as text.\n\nA string sorts objects by their fields. Each field can end with `_asc` or `_desc`, several fields are separated by commas, and a nested field is written with dots. Strings, numbers, booleans and dates are supported.\n\nExample: Plain values\n```js\nconsole.log(['b', 'c', 'a'].quicksort()); // [\"a\",\"b\",\"c\"]\n```\n\nExample: Objects\n```js\nvar list = [{ name: 'b', age: 1 }, { name: 'a', age: 2 }, { name: 'a', age: 3 }];\nconsole.log(list.quicksort('name_asc,age_desc')); // [{\"name\":\"a\",\"age\":3},{\"name\":\"a\",\"age\":2},{\"name\":\"b\",\"age\":1}]\nconsole.log(list.quicksort('age', 'desc')[0].age); // 3\nconsole.log([{ user: { age: 2 } }, { user: { age: 1 } }].quicksort('user.age')[0].user.age); // 1\n```\n\n### Array.remove(filter, [value])\n\nType: `method`\n\nReturns a copy of the array without the items that match.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | The field name, the test function or the value to remove. |\n| `value` | `Object` | no |  | The value of the field. |\n\nReturns: `Array` A new array with the remaining items.\n\nThe arguments work as in `findAll()`. The original array does not change.\n\nExample: Removing items\n```js\nconsole.log([{ a: 1 }, { a: 2 }].remove('a', 1)); // [{\"a\":2}]\nconsole.log([1, 2, 3].remove(value => value > 1)); // [1]\nconsole.log([1, 2, 1].remove(1)); // [2]\n```\n\n### Array.skip(count)\n\nType: `method`\n\nReturns the items after the first `count` items.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | The number of items to skip. |\n\nReturns: `Array` A new array.\n\nExample: Skipping\n```js\nconsole.log([1, 2, 3, 4].skip(2)); // [3,4]\n```\n\n### Array.take(count)\n\nType: `method`\n\nReturns the first `count` items.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | The number of items to return, from 1 up. |\n\nReturns: `Array` A new array.\n\nExample: Taking\n```js\nconsole.log([1, 2, 3].take(2)); // [1,2]\nconsole.log([1].take(5)); // [1]\n```\n\n### Array.takeskip(take, skip)\n\nType: `method`\n\nSkips a number of items and returns the following ones.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `take` | `Number` | yes |  | The number of items to return. |\n| `skip` | `Number` | yes |  | The number of items to skip. |\n\nReturns: `Array` A new array.\n\nThe method is useful for paging.\n\nExample: A page of items\n```js\nconsole.log([1, 2, 3, 4, 5].takeskip(2, 1)); // [2,3]\n```\n\n### Array.trim()\n\nType: `method`\n\nTrims the strings and leaves out the empty values.\n\nReturns: `Array` A new array with the remaining values.\n\nEvery falsy value is left out, including `0`. The strings in the original array are trimmed too.\n\nExample: Cleaning a list\n```js\nconsole.log([' a ', '', 0, null, 'b ', 5].trim()); // [\"a\",\"b\",5]\n```\n\n### Array.wait(onItem, [callback], [thread])\n\nType: `method`\n\nProcesses the items one after another, or several at a time.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | The function that processes an item. |\n| `callback` | `Function` | no |  | The function called at the end. |\n| `thread` | `Number or Boolean` | no | `1` | The number of parallel items, or `true` to empty the array. |\n\nReturns: `Array` The same array.\n\n`onItem` receives `(item, next, index)` and must call `next()` when the item is finished. `index` is the position of the item, starting at 1. `callback` runs when all the items are finished, and it can be left out with `thread` passed in its place.\n\nA number in `thread` sets how many items run at the same time. `true` removes each item from the array as it is processed, and `index` is then `0`.\n\nExample: One item at a time\n```js\nvar log = [];\n[10, 20].wait(function(item, next, index) {\n\tlog.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(log); // [\"1:10\",\"2:20\"]\n});\n```\n\nExample: Two items at a time\n```js\nvar running = 0;\nvar max = 0;\n[1, 2, 3, 4, 5].wait(function(item, next) {\n\trunning++;\n\tmax = Math.max(max, running);\n\tsetTimeout(function() {\n\t\trunning--;\n\t\tnext();\n\t}, 10);\n}, function() {\n\tconsole.log(max); // 2\n}, 2);\n```\n\nExample: Emptying the array\n```js\nvar queue = [1, 2, 3];\nqueue.wait((item, next) => next(), function() {\n\tconsole.log(queue.length); // 0\n}, true);\n```\n","entries":[{"type":"method","name":"attr()","signature":"Array.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"Array.findAll(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"Array.findIndex(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"Array.findItem(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"Array.findValue(filter, value, field, [def], [cache])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"Array.group(key)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"Array.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"Array.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"Array.remove(filter, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"Array.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"Array.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"Array.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"Array.trim()","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"Array.wait(onItem, [callback], [thread])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcNq26d61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/array/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"Array","summary":"Methoden, die jComponent zu Array.prototype hinzufügt, um Listen zu durchsuchen, zu sortieren, aufzuteilen und zu verarbeiten.","markdown":"---\ntitle: Array\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/array/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Array\n\n> Methoden, die jComponent zu Array.prototype hinzufügt, um Listen zu durchsuchen, zu sortieren, aufzuteilen und zu verarbeiten.\n\njComponent fügt diese Methoden jedem Array hinzu. Damit vorbereitete Listen werden oft mit [Templates mit Tangular](../../guides/tangular/) gerendert.\n\n## API\n\n### Array.attr(name, [value])\n\nType: `method`\n\nFügt dem Array ein HTML-Attribut als Text hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Attributname. |\n| `value` | `Object` | no |  | Der Attributwert. |\n\nReturns: `Array` Dasselbe Array.\n\nDer Wert wird maskiert, und `[key]`-Ausdrücke darin werden wie bei [env()](../string/) ersetzt. Ohne `value` ist der Attributname zugleich sein Wert. Ein `null`-Wert fügt nichts hinzu.\n\nExample: Attribute erstellen\n```js\nvar attrs = [];\nattrs.attr('id', 'box').attr('title', '<b>').attr('disabled').attr('hidden', null);\nconsole.log(attrs.join(' ')); // id=\"box\" title=\"&lt;b&gt;\" disabled=\"disabled\"\n```\n\n### Array.findAll(filter, [value])\n\nType: `method`\n\nGibt alle passenden Einträge zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Der Feldname, die Testfunktion oder der zu suchende Wert. |\n| `value` | `Object` | no |  | Der Wert des Feldes. |\n\nReturns: `Array` Ein neues Array mit den passenden Einträgen.\n\nMit `filter` und `value` vergleicht die Methode das Feld namens `filter` mit `value`. Eine Funktion erhält `(item, index)`. Mit einem einzelnen anderen Wert vergleicht die Methode die Einträge selbst.\n\nExample: Einträge finden\n```js\nconsole.log([{ a: 1 }, { a: 2 }, { a: 1 }].findAll('a', 1)); // [{\"a\":1},{\"a\":1}]\nconsole.log([1, 2, 3].findAll(value => value > 1)); // [2,3]\nconsole.log([1, 2, 1].findAll(1)); // [1,1]\n```\n\n### Array.findIndex(filter, [value])\n\nType: `method`\n\nGibt den Index des ersten passenden Eintrags zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Der Feldname, die Testfunktion oder der zu suchende Wert. |\n| `value` | `Object` | no |  | Der Wert des Feldes. |\n\nReturns: `Number` Der Index oder `-1`, wenn nichts passt.\n\nDie Argumente funktionieren wie bei `findAll()`.\n\nExample: Index finden\n```js\nconsole.log([{ a: 1 }, { a: 2 }].findIndex('a', 2)); // 1\nconsole.log([5, 6].findIndex((value, index) => index === 1)); // 1\nconsole.log([1, 2].findIndex(9)); // -1\n```\n\n### Array.findItem(filter, [value])\n\nType: `method`\n\nGibt den ersten passenden Eintrag zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Der Feldname, die Testfunktion oder der zu suchende Wert. |\n| `value` | `Object` | no |  | Der Wert des Feldes. |\n\nReturns: `Object` Der Eintrag oder `undefined`, wenn nichts passt.\n\nDie Argumente funktionieren wie bei `findAll()`.\n\nExample: Eintrag finden\n```js\nconsole.log([{ id: 1, name: 'A' }].findItem('id', 1)); // {\"id\":1,\"name\":\"A\"}\nconsole.log([1, 2, 3].findItem(value => value > 1)); // 2\nconsole.log([1].findItem(9) === undefined); // true\n```\n\n### Array.findValue(filter, value, field, [def], [cache])\n\nType: `method`\n\nGibt ein Feld des ersten passenden Eintrags zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String or Function` | yes |  | Das zu vergleichende Feld oder die Testfunktion. |\n| `value` | `Object` | yes |  | Der Wert des verglichenen Feldes. |\n| `field` | `String` | yes |  | Der Name des zurückzugebenden Feldes. |\n| `def` | `Object` | no |  | Der Rückgabewert, wenn kein Eintrag passt oder das Feld leer ist. |\n| `cache` | `Boolean` | no | `false` | Bewahrt das Ergebnis für spätere Aufrufe auf. |\n\nReturns: `Object` Der Wert des Feldes.\n\nMit einer Funktion als Filter lautet die Signatur `findValue(fn, field, [def], [cache])`. Ein verschachteltes `field` schreibst du mit Punkten, zum Beispiel `user.age`.\n\nIst `cache` auf `true` gesetzt, wird das Ergebnis in [TEMP](../globals/) unter einem Schlüssel aus Filter, Wert und Feld aufbewahrt. Ein späterer Aufruf mit denselben Argumenten gibt das aufbewahrte Ergebnis zurück, auch bei einem anderen Array.\n\nExample: Feld lesen\n```js\nvar users = [{ id: 1, name: 'Ana' }];\nconsole.log(users.findValue('id', 1, 'name')); // Ana\nconsole.log(users.findValue('id', 9, 'name', 'nobody')); // nobody\nconsole.log(users.findValue(user => user.id === 1, 'name', 'nobody')); // Ana\nconsole.log([{ id: 1, user: { age: 5 } }].findValue('id', 1, 'user.age')); // 5\n```\n\n### Array.group(key)\n\nType: `method`\n\nGruppiert die Einträge nach dem Wert eines Feldes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Der Feldname. |\n\nReturns: `Array` Objekte mit den Feldern `name` und `items`.\n\nDie Gruppen sind nach Namen sortiert. Einträge ohne das Feld landen in einer Gruppe mit leerem Namen.\n\nExample: Gruppieren\n```js\nvar list = [{ type: 'b', id: 1 }, { type: 'a', id: 2 }, { type: 'b', id: 3 }];\nconsole.log(list.group('type')); // [{\"name\":\"a\",\"items\":[{\"type\":\"a\",\"id\":2}]},{\"name\":\"b\",\"items\":[{\"type\":\"b\",\"id\":1},{\"type\":\"b\",\"id\":3}]}]\n```\n\n### Array.last([def])\n\nType: `method`\n\nGibt den letzten Eintrag zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | Der Rückgabewert bei einem leeren Array. |\n\nReturns: `Object` Der letzte Eintrag oder `def`.\n\nExample: Letzter Eintrag\n```js\nconsole.log([1, 2, 3].last()); // 3\nconsole.log([].last('empty')); // empty\n```\n\n### Array.quicksort([sort], [direction])\n\nType: `method`\n\nSortiert das Array direkt.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | Die Felder, nach denen sortiert wird. |\n| `direction` | `Boolean, String or Number` | no |  | `false`, `desc` oder `2` sortiert ein Feld absteigend. |\n\nReturns: `Array` Dasselbe Array.\n\nOhne Argumente werden die Einträge aufsteigend sortiert und als Text verglichen.\n\nEin String sortiert Objekte nach ihren Feldern. Jedes Feld kann auf `_asc` oder `_desc` enden, mehrere Felder werden durch Kommas getrennt, und ein verschachteltes Feld wird mit Punkten geschrieben. Unterstützt werden Strings, Zahlen, Booleans und Datumswerte.\n\nExample: Einfache Werte\n```js\nconsole.log(['b', 'c', 'a'].quicksort()); // [\"a\",\"b\",\"c\"]\n```\n\nExample: Objekte\n```js\nvar list = [{ name: 'b', age: 1 }, { name: 'a', age: 2 }, { name: 'a', age: 3 }];\nconsole.log(list.quicksort('name_asc,age_desc')); // [{\"name\":\"a\",\"age\":3},{\"name\":\"a\",\"age\":2},{\"name\":\"b\",\"age\":1}]\nconsole.log(list.quicksort('age', 'desc')[0].age); // 3\nconsole.log([{ user: { age: 2 } }, { user: { age: 1 } }].quicksort('user.age')[0].user.age); // 1\n```\n\n### Array.remove(filter, [value])\n\nType: `method`\n\nGibt eine Kopie des Arrays ohne die passenden Einträge zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Der Feldname, die Testfunktion oder der zu entfernende Wert. |\n| `value` | `Object` | no |  | Der Wert des Feldes. |\n\nReturns: `Array` Ein neues Array mit den verbleibenden Einträgen.\n\nDie Argumente funktionieren wie bei `findAll()`. Das ursprüngliche Array bleibt unverändert.\n\nExample: Einträge entfernen\n```js\nconsole.log([{ a: 1 }, { a: 2 }].remove('a', 1)); // [{\"a\":2}]\nconsole.log([1, 2, 3].remove(value => value > 1)); // [1]\nconsole.log([1, 2, 1].remove(1)); // [2]\n```\n\n### Array.skip(count)\n\nType: `method`\n\nGibt die Einträge nach den ersten `count` Einträgen zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | Die Anzahl der zu überspringenden Einträge. |\n\nReturns: `Array` Ein neues Array.\n\nExample: Überspringen\n```js\nconsole.log([1, 2, 3, 4].skip(2)); // [3,4]\n```\n\n### Array.take(count)\n\nType: `method`\n\nGibt die ersten `count` Einträge zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | Die Anzahl der zurückzugebenden Einträge, ab 1. |\n\nReturns: `Array` Ein neues Array.\n\nExample: Entnehmen\n```js\nconsole.log([1, 2, 3].take(2)); // [1,2]\nconsole.log([1].take(5)); // [1]\n```\n\n### Array.takeskip(take, skip)\n\nType: `method`\n\nÜberspringt eine Anzahl von Einträgen und gibt die folgenden zurück.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `take` | `Number` | yes |  | Die Anzahl der zurückzugebenden Einträge. |\n| `skip` | `Number` | yes |  | Die Anzahl der zu überspringenden Einträge. |\n\nReturns: `Array` Ein neues Array.\n\nDie Methode ist nützlich für die Seitennavigation.\n\nExample: Eine Seite mit Einträgen\n```js\nconsole.log([1, 2, 3, 4, 5].takeskip(2, 1)); // [2,3]\n```\n\n### Array.trim()\n\nType: `method`\n\nTrimmt die Strings und lässt die leeren Werte weg.\n\nReturns: `Array` Ein neues Array mit den verbleibenden Werten.\n\nJeder falsy Wert wird weggelassen, auch `0`. Die Strings im ursprünglichen Array werden ebenfalls getrimmt.\n\nExample: Liste bereinigen\n```js\nconsole.log([' a ', '', 0, null, 'b ', 5].trim()); // [\"a\",\"b\",5]\n```\n\n### Array.wait(onItem, [callback], [thread])\n\nType: `method`\n\nVerarbeitet die Einträge nacheinander oder mehrere gleichzeitig.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | Die Funktion, die einen Eintrag verarbeitet. |\n| `callback` | `Function` | no |  | Die Funktion, die am Ende aufgerufen wird. |\n| `thread` | `Number or Boolean` | no | `1` | Die Anzahl paralleler Einträge oder `true`, um das Array zu leeren. |\n\nReturns: `Array` Dasselbe Array.\n\n`onItem` erhält `(item, next, index)` und muss `next()` aufrufen, wenn der Eintrag fertig ist. `index` ist die Position des Eintrags, beginnend bei 1. `callback` wird ausgeführt, wenn alle Einträge fertig sind, und kann weggelassen werden, indem du an seiner Stelle `thread` übergibst.\n\nEine Zahl in `thread` legt fest, wie viele Einträge gleichzeitig laufen. `true` entfernt jeden Eintrag bei der Verarbeitung aus dem Array, und `index` ist dann `0`.\n\nExample: Ein Eintrag nach dem anderen\n```js\nvar log = [];\n[10, 20].wait(function(item, next, index) {\n\tlog.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(log); // [\"1:10\",\"2:20\"]\n});\n```\n\nExample: Zwei Einträge gleichzeitig\n```js\nvar running = 0;\nvar max = 0;\n[1, 2, 3, 4, 5].wait(function(item, next) {\n\trunning++;\n\tmax = Math.max(max, running);\n\tsetTimeout(function() {\n\t\trunning--;\n\t\tnext();\n\t}, 10);\n}, function() {\n\tconsole.log(max); // 2\n}, 2);\n```\n\nExample: Array leeren\n```js\nvar queue = [1, 2, 3];\nqueue.wait((item, next) => next(), function() {\n\tconsole.log(queue.length); // 0\n}, true);\n```\n","entries":[{"type":"method","name":"attr()","signature":"Array.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"Array.findAll(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"Array.findIndex(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"Array.findItem(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"Array.findValue(filter, value, field, [def], [cache])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"Array.group(key)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"Array.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"Array.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"Array.remove(filter, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"Array.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"Array.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"Array.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"Array.trim()","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"Array.wait(onItem, [callback], [thread])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcNq26d61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/array/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Array","summary":"Métodos que jComponent añade a Array.prototype para buscar, ordenar, trocear y procesar listas.","markdown":"---\ntitle: Array\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/array/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Array\n\n> Métodos que jComponent añade a Array.prototype para buscar, ordenar, trocear y procesar listas.\n\njComponent añade estos métodos a todos los arrays. Las listas preparadas con ellos suelen renderizarse con [Plantillas con Tangular](../../guides/tangular/).\n\n## API\n\n### Array.attr(name, [value])\n\nType: `method`\n\nAñade al array un atributo HTML como texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del atributo. |\n| `value` | `Object` | no |  | El valor del atributo. |\n\nReturns: `Array` El mismo array.\n\nEl valor se escapa y las frases `[key]` que contiene se sustituyen como en [env()](../string/). Sin `value`, el nombre del atributo es también su valor. Un valor `null` no añade nada.\n\nExample: Construir atributos\n```js\nvar attrs = [];\nattrs.attr('id', 'box').attr('title', '<b>').attr('disabled').attr('hidden', null);\nconsole.log(attrs.join(' ')); // id=\"box\" title=\"&lt;b&gt;\" disabled=\"disabled\"\n```\n\n### Array.findAll(filter, [value])\n\nType: `method`\n\nDevuelve todos los elementos que coinciden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | El nombre del campo, la función de comprobación o el valor que se busca. |\n| `value` | `Object` | no |  | El valor del campo. |\n\nReturns: `Array` Un array nuevo con los elementos que coinciden.\n\nCon `filter` y `value`, el método compara el campo llamado `filter` con `value`. Con una función, esta recibe `(item, index)`. Con otro valor único, compara los propios elementos.\n\nExample: Buscar elementos\n```js\nconsole.log([{ a: 1 }, { a: 2 }, { a: 1 }].findAll('a', 1)); // [{\"a\":1},{\"a\":1}]\nconsole.log([1, 2, 3].findAll(value => value > 1)); // [2,3]\nconsole.log([1, 2, 1].findAll(1)); // [1,1]\n```\n\n### Array.findIndex(filter, [value])\n\nType: `method`\n\nDevuelve el índice del primer elemento que coincide.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | El nombre del campo, la función de comprobación o el valor que se busca. |\n| `value` | `Object` | no |  | El valor del campo. |\n\nReturns: `Number` El índice, o `-1` cuando nada coincide.\n\nLos argumentos funcionan como en `findAll()`.\n\nExample: Buscar un índice\n```js\nconsole.log([{ a: 1 }, { a: 2 }].findIndex('a', 2)); // 1\nconsole.log([5, 6].findIndex((value, index) => index === 1)); // 1\nconsole.log([1, 2].findIndex(9)); // -1\n```\n\n### Array.findItem(filter, [value])\n\nType: `method`\n\nDevuelve el primer elemento que coincide.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | El nombre del campo, la función de comprobación o el valor que se busca. |\n| `value` | `Object` | no |  | El valor del campo. |\n\nReturns: `Object` El elemento, o `undefined` cuando nada coincide.\n\nLos argumentos funcionan como en `findAll()`.\n\nExample: Buscar un elemento\n```js\nconsole.log([{ id: 1, name: 'A' }].findItem('id', 1)); // {\"id\":1,\"name\":\"A\"}\nconsole.log([1, 2, 3].findItem(value => value > 1)); // 2\nconsole.log([1].findItem(9) === undefined); // true\n```\n\n### Array.findValue(filter, value, field, [def], [cache])\n\nType: `method`\n\nDevuelve un campo del primer elemento que coincide.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String or Function` | yes |  | El campo que se compara o la función de comprobación. |\n| `value` | `Object` | yes |  | El valor del campo comparado. |\n| `field` | `String` | yes |  | El nombre del campo que se devuelve. |\n| `def` | `Object` | no |  | El valor que se devuelve cuando ningún elemento coincide o el campo está vacío. |\n| `cache` | `Boolean` | no | `false` | Guarda el resultado para las siguientes llamadas. |\n\nReturns: `Object` El valor del campo.\n\nCon una función como filtro, la firma es `findValue(fn, field, [def], [cache])`. Un `field` anidado se escribe con puntos, por ejemplo `user.age`.\n\nCon `cache` en `true`, el resultado se guarda en [TEMP](../globals/) con una clave formada por el filtro, el valor y el campo. Una llamada posterior con los mismos argumentos devuelve el resultado guardado, incluso para otro array.\n\nExample: Leer un campo\n```js\nvar users = [{ id: 1, name: 'Ana' }];\nconsole.log(users.findValue('id', 1, 'name')); // Ana\nconsole.log(users.findValue('id', 9, 'name', 'nobody')); // nobody\nconsole.log(users.findValue(user => user.id === 1, 'name', 'nobody')); // Ana\nconsole.log([{ id: 1, user: { age: 5 } }].findValue('id', 1, 'user.age')); // 5\n```\n\n### Array.group(key)\n\nType: `method`\n\nAgrupa los elementos por el valor de un campo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | El nombre del campo. |\n\nReturns: `Array` Objetos con los campos `name` e `items`.\n\nLos grupos se ordenan por nombre. Los elementos sin el campo quedan en un grupo con el nombre vacío.\n\nExample: Agrupar\n```js\nvar list = [{ type: 'b', id: 1 }, { type: 'a', id: 2 }, { type: 'b', id: 3 }];\nconsole.log(list.group('type')); // [{\"name\":\"a\",\"items\":[{\"type\":\"a\",\"id\":2}]},{\"name\":\"b\",\"items\":[{\"type\":\"b\",\"id\":1},{\"type\":\"b\",\"id\":3}]}]\n```\n\n### Array.last([def])\n\nType: `method`\n\nDevuelve el último elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | El valor que se devuelve para un array vacío. |\n\nReturns: `Object` El último elemento o `def`.\n\nExample: Último elemento\n```js\nconsole.log([1, 2, 3].last()); // 3\nconsole.log([].last('empty')); // empty\n```\n\n### Array.quicksort([sort], [direction])\n\nType: `method`\n\nOrdena el array en su lugar.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | Los campos por los que se ordena. |\n| `direction` | `Boolean, String or Number` | no |  | `false`, `desc` o `2` ordena un campo de forma descendente. |\n\nReturns: `Array` El mismo array.\n\nSin argumentos, los elementos se ordenan de forma ascendente y se comparan como texto.\n\nUna cadena ordena los objetos por sus campos. Cada campo puede terminar en `_asc` o `_desc`, varios campos se separan con comas y un campo anidado se escribe con puntos. Se admiten cadenas, números, booleanos y fechas.\n\nExample: Valores simples\n```js\nconsole.log(['b', 'c', 'a'].quicksort()); // [\"a\",\"b\",\"c\"]\n```\n\nExample: Objetos\n```js\nvar list = [{ name: 'b', age: 1 }, { name: 'a', age: 2 }, { name: 'a', age: 3 }];\nconsole.log(list.quicksort('name_asc,age_desc')); // [{\"name\":\"a\",\"age\":3},{\"name\":\"a\",\"age\":2},{\"name\":\"b\",\"age\":1}]\nconsole.log(list.quicksort('age', 'desc')[0].age); // 3\nconsole.log([{ user: { age: 2 } }, { user: { age: 1 } }].quicksort('user.age')[0].user.age); // 1\n```\n\n### Array.remove(filter, [value])\n\nType: `method`\n\nDevuelve una copia del array sin los elementos que coinciden.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | El nombre del campo, la función de comprobación o el valor que se elimina. |\n| `value` | `Object` | no |  | El valor del campo. |\n\nReturns: `Array` Un array nuevo con los elementos restantes.\n\nLos argumentos funcionan como en `findAll()`. El array original no cambia.\n\nExample: Eliminar elementos\n```js\nconsole.log([{ a: 1 }, { a: 2 }].remove('a', 1)); // [{\"a\":2}]\nconsole.log([1, 2, 3].remove(value => value > 1)); // [1]\nconsole.log([1, 2, 1].remove(1)); // [2]\n```\n\n### Array.skip(count)\n\nType: `method`\n\nDevuelve los elementos que siguen a los primeros `count` elementos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | El número de elementos que se omiten. |\n\nReturns: `Array` Un array nuevo.\n\nExample: Omitir\n```js\nconsole.log([1, 2, 3, 4].skip(2)); // [3,4]\n```\n\n### Array.take(count)\n\nType: `method`\n\nDevuelve los primeros `count` elementos.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | El número de elementos que se devuelven, a partir de 1. |\n\nReturns: `Array` Un array nuevo.\n\nExample: Tomar\n```js\nconsole.log([1, 2, 3].take(2)); // [1,2]\nconsole.log([1].take(5)); // [1]\n```\n\n### Array.takeskip(take, skip)\n\nType: `method`\n\nOmite un número de elementos y devuelve los siguientes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `take` | `Number` | yes |  | El número de elementos que se devuelven. |\n| `skip` | `Number` | yes |  | El número de elementos que se omiten. |\n\nReturns: `Array` Un array nuevo.\n\nEl método es útil para paginar.\n\nExample: Una página de elementos\n```js\nconsole.log([1, 2, 3, 4, 5].takeskip(2, 1)); // [2,3]\n```\n\n### Array.trim()\n\nType: `method`\n\nRecorta las cadenas y descarta los valores vacíos.\n\nReturns: `Array` Un array nuevo con los valores restantes.\n\nSe descarta todo valor falsy, incluido `0`. Las cadenas del array original también se recortan.\n\nExample: Limpiar una lista\n```js\nconsole.log([' a ', '', 0, null, 'b ', 5].trim()); // [\"a\",\"b\",5]\n```\n\n### Array.wait(onItem, [callback], [thread])\n\nType: `method`\n\nProcesa los elementos uno tras otro, o varios a la vez.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | La función que procesa un elemento. |\n| `callback` | `Function` | no |  | La función a la que se llama al final. |\n| `thread` | `Number or Boolean` | no | `1` | El número de elementos en paralelo, o `true` para vaciar el array. |\n\nReturns: `Array` El mismo array.\n\n`onItem` recibe `(item, next, index)` y debe llamar a `next()` cuando termina con el elemento. `index` es la posición del elemento, empezando por 1. `callback` se ejecuta cuando han terminado todos los elementos, y se puede omitir pasando `thread` en su lugar.\n\nUn número en `thread` establece cuántos elementos se ejecutan a la vez. `true` quita cada elemento del array a medida que se procesa, y entonces `index` es `0`.\n\nExample: Un elemento cada vez\n```js\nvar log = [];\n[10, 20].wait(function(item, next, index) {\n\tlog.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(log); // [\"1:10\",\"2:20\"]\n});\n```\n\nExample: Dos elementos cada vez\n```js\nvar running = 0;\nvar max = 0;\n[1, 2, 3, 4, 5].wait(function(item, next) {\n\trunning++;\n\tmax = Math.max(max, running);\n\tsetTimeout(function() {\n\t\trunning--;\n\t\tnext();\n\t}, 10);\n}, function() {\n\tconsole.log(max); // 2\n}, 2);\n```\n\nExample: Vaciar el array\n```js\nvar queue = [1, 2, 3];\nqueue.wait((item, next) => next(), function() {\n\tconsole.log(queue.length); // 0\n}, true);\n```\n","entries":[{"type":"method","name":"attr()","signature":"Array.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"Array.findAll(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"Array.findIndex(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"Array.findItem(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"Array.findValue(filter, value, field, [def], [cache])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"Array.group(key)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"Array.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"Array.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"Array.remove(filter, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"Array.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"Array.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"Array.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"Array.trim()","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"Array.wait(onItem, [callback], [thread])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcNq26d61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/array/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Array","summary":"Les méthodes que jComponent ajoute à Array.prototype pour rechercher, trier, découper et traiter des listes.","markdown":"---\ntitle: Array\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/array/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Array\n\n> Les méthodes que jComponent ajoute à Array.prototype pour rechercher, trier, découper et traiter des listes.\n\njComponent ajoute ces méthodes à chaque tableau. Les listes préparées avec elles sont souvent affichées avec des [Modèles avec Tangular](../../guides/tangular/).\n\n## API\n\n### Array.attr(name, [value])\n\nType: `method`\n\nAjoute un attribut HTML sous forme de texte au tableau.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'attribut. |\n| `value` | `Object` | no |  | La valeur de l'attribut. |\n\nReturns: `Array` Le même tableau.\n\nLa valeur est échappée et ses expressions `[key]` sont remplacées comme dans [env()](../string/). Sans `value`, le nom de l'attribut sert aussi de valeur. Une valeur `null` n'ajoute rien.\n\nExample: Construire des attributs\n```js\nvar attrs = [];\nattrs.attr('id', 'box').attr('title', '<b>').attr('disabled').attr('hidden', null);\nconsole.log(attrs.join(' ')); // id=\"box\" title=\"&lt;b&gt;\" disabled=\"disabled\"\n```\n\n### Array.findAll(filter, [value])\n\nType: `method`\n\nRenvoie tous les éléments correspondants.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Le nom du champ, la fonction de test ou la valeur à trouver. |\n| `value` | `Object` | no |  | La valeur du champ. |\n\nReturns: `Array` Un nouveau tableau contenant les éléments correspondants.\n\nAvec `filter` et `value`, la méthode compare le champ nommé `filter` à `value`. Une fonction reçoit `(item, index)`. Avec une seule autre valeur, la méthode compare les éléments eux-mêmes.\n\nExample: Trouver des éléments\n```js\nconsole.log([{ a: 1 }, { a: 2 }, { a: 1 }].findAll('a', 1)); // [{\"a\":1},{\"a\":1}]\nconsole.log([1, 2, 3].findAll(value => value > 1)); // [2,3]\nconsole.log([1, 2, 1].findAll(1)); // [1,1]\n```\n\n### Array.findIndex(filter, [value])\n\nType: `method`\n\nRenvoie l'index du premier élément correspondant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Le nom du champ, la fonction de test ou la valeur à trouver. |\n| `value` | `Object` | no |  | La valeur du champ. |\n\nReturns: `Number` L'index, ou `-1` quand rien ne correspond.\n\nLes arguments fonctionnent comme dans `findAll()`.\n\nExample: Trouver un index\n```js\nconsole.log([{ a: 1 }, { a: 2 }].findIndex('a', 2)); // 1\nconsole.log([5, 6].findIndex((value, index) => index === 1)); // 1\nconsole.log([1, 2].findIndex(9)); // -1\n```\n\n### Array.findItem(filter, [value])\n\nType: `method`\n\nRenvoie le premier élément correspondant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Le nom du champ, la fonction de test ou la valeur à trouver. |\n| `value` | `Object` | no |  | La valeur du champ. |\n\nReturns: `Object` L'élément, ou `undefined` quand rien ne correspond.\n\nLes arguments fonctionnent comme dans `findAll()`.\n\nExample: Trouver un élément\n```js\nconsole.log([{ id: 1, name: 'A' }].findItem('id', 1)); // {\"id\":1,\"name\":\"A\"}\nconsole.log([1, 2, 3].findItem(value => value > 1)); // 2\nconsole.log([1].findItem(9) === undefined); // true\n```\n\n### Array.findValue(filter, value, field, [def], [cache])\n\nType: `method`\n\nRenvoie un champ du premier élément correspondant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String or Function` | yes |  | Le champ à comparer, ou la fonction de test. |\n| `value` | `Object` | yes |  | La valeur du champ comparé. |\n| `field` | `String` | yes |  | Le nom du champ à renvoyer. |\n| `def` | `Object` | no |  | La valeur renvoyée quand aucun élément ne correspond ou que le champ est vide. |\n| `cache` | `Boolean` | no | `false` | Conserve le résultat pour les appels suivants. |\n\nReturns: `Object` La valeur du champ.\n\nAvec une fonction comme filtre, la signature est `findValue(fn, field, [def], [cache])`. Un `field` imbriqué s'écrit avec des points, par exemple `user.age`.\n\nAvec `cache` à `true`, le résultat est conservé dans [TEMP](../globals/) sous une clé formée du filtre, de la valeur et du champ. Un appel ultérieur avec les mêmes arguments renvoie le résultat conservé, même pour un autre tableau.\n\nExample: Lire un champ\n```js\nvar users = [{ id: 1, name: 'Ana' }];\nconsole.log(users.findValue('id', 1, 'name')); // Ana\nconsole.log(users.findValue('id', 9, 'name', 'nobody')); // nobody\nconsole.log(users.findValue(user => user.id === 1, 'name', 'nobody')); // Ana\nconsole.log([{ id: 1, user: { age: 5 } }].findValue('id', 1, 'user.age')); // 5\n```\n\n### Array.group(key)\n\nType: `method`\n\nRegroupe les éléments selon la valeur d'un champ.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Le nom du champ. |\n\nReturns: `Array` Des objets avec les champs `name` et `items`.\n\nLes groupes sont triés par nom. Les éléments sans ce champ sont placés dans un groupe au nom vide.\n\nExample: Regrouper\n```js\nvar list = [{ type: 'b', id: 1 }, { type: 'a', id: 2 }, { type: 'b', id: 3 }];\nconsole.log(list.group('type')); // [{\"name\":\"a\",\"items\":[{\"type\":\"a\",\"id\":2}]},{\"name\":\"b\",\"items\":[{\"type\":\"b\",\"id\":1},{\"type\":\"b\",\"id\":3}]}]\n```\n\n### Array.last([def])\n\nType: `method`\n\nRenvoie le dernier élément.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | La valeur renvoyée pour un tableau vide. |\n\nReturns: `Object` Le dernier élément ou `def`.\n\nExample: Dernier élément\n```js\nconsole.log([1, 2, 3].last()); // 3\nconsole.log([].last('empty')); // empty\n```\n\n### Array.quicksort([sort], [direction])\n\nType: `method`\n\nTrie le tableau sur place.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | Les champs de tri. |\n| `direction` | `Boolean, String or Number` | no |  | `false`, `desc` ou `2` trie un champ par ordre décroissant. |\n\nReturns: `Array` Le même tableau.\n\nSans argument, les éléments sont triés par ordre croissant et comparés comme du texte.\n\nUne chaîne trie les objets selon leurs champs. Chaque champ peut se terminer par `_asc` ou `_desc`, plusieurs champs sont séparés par des virgules et un champ imbriqué s'écrit avec des points. Les chaînes, les nombres, les booléens et les dates sont pris en charge.\n\nExample: Valeurs simples\n```js\nconsole.log(['b', 'c', 'a'].quicksort()); // [\"a\",\"b\",\"c\"]\n```\n\nExample: Objets\n```js\nvar list = [{ name: 'b', age: 1 }, { name: 'a', age: 2 }, { name: 'a', age: 3 }];\nconsole.log(list.quicksort('name_asc,age_desc')); // [{\"name\":\"a\",\"age\":3},{\"name\":\"a\",\"age\":2},{\"name\":\"b\",\"age\":1}]\nconsole.log(list.quicksort('age', 'desc')[0].age); // 3\nconsole.log([{ user: { age: 2 } }, { user: { age: 1 } }].quicksort('user.age')[0].user.age); // 1\n```\n\n### Array.remove(filter, [value])\n\nType: `method`\n\nRenvoie une copie du tableau sans les éléments correspondants.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Le nom du champ, la fonction de test ou la valeur à retirer. |\n| `value` | `Object` | no |  | La valeur du champ. |\n\nReturns: `Array` Un nouveau tableau contenant les éléments restants.\n\nLes arguments fonctionnent comme dans `findAll()`. Le tableau d'origine ne change pas.\n\nExample: Retirer des éléments\n```js\nconsole.log([{ a: 1 }, { a: 2 }].remove('a', 1)); // [{\"a\":2}]\nconsole.log([1, 2, 3].remove(value => value > 1)); // [1]\nconsole.log([1, 2, 1].remove(1)); // [2]\n```\n\n### Array.skip(count)\n\nType: `method`\n\nRenvoie les éléments situés après les `count` premiers.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | Le nombre d'éléments à sauter. |\n\nReturns: `Array` Un nouveau tableau.\n\nExample: Sauter des éléments\n```js\nconsole.log([1, 2, 3, 4].skip(2)); // [3,4]\n```\n\n### Array.take(count)\n\nType: `method`\n\nRenvoie les `count` premiers éléments.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | Le nombre d'éléments à renvoyer, à partir de 1. |\n\nReturns: `Array` Un nouveau tableau.\n\nExample: Prendre des éléments\n```js\nconsole.log([1, 2, 3].take(2)); // [1,2]\nconsole.log([1].take(5)); // [1]\n```\n\n### Array.takeskip(take, skip)\n\nType: `method`\n\nSaute un certain nombre d'éléments et renvoie les suivants.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `take` | `Number` | yes |  | Le nombre d'éléments à renvoyer. |\n| `skip` | `Number` | yes |  | Le nombre d'éléments à sauter. |\n\nReturns: `Array` Un nouveau tableau.\n\nLa méthode est utile pour la pagination.\n\nExample: Une page d'éléments\n```js\nconsole.log([1, 2, 3, 4, 5].takeskip(2, 1)); // [2,3]\n```\n\n### Array.trim()\n\nType: `method`\n\nSupprime les espaces superflues des chaînes et écarte les valeurs vides.\n\nReturns: `Array` Un nouveau tableau contenant les valeurs restantes.\n\nToute valeur falsy est écartée, y compris `0`. Les chaînes du tableau d'origine sont elles aussi nettoyées.\n\nExample: Nettoyer une liste\n```js\nconsole.log([' a ', '', 0, null, 'b ', 5].trim()); // [\"a\",\"b\",5]\n```\n\n### Array.wait(onItem, [callback], [thread])\n\nType: `method`\n\nTraite les éléments l'un après l'autre, ou plusieurs à la fois.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | La fonction qui traite un élément. |\n| `callback` | `Function` | no |  | La fonction appelée à la fin. |\n| `thread` | `Number or Boolean` | no | `1` | Le nombre d'éléments en parallèle, ou `true` pour vider le tableau. |\n\nReturns: `Array` Le même tableau.\n\n`onItem` reçoit `(item, next, index)` et doit appeler `next()` quand l'élément est terminé. `index` est la position de l'élément, à partir de 1. `callback` s'exécute quand tous les éléments sont terminés, et peut être omis en passant `thread` à sa place.\n\nUn nombre dans `thread` définit combien d'éléments s'exécutent en même temps. `true` retire chaque élément du tableau au fur et à mesure de son traitement, et `index` vaut alors `0`.\n\nExample: Un élément à la fois\n```js\nvar log = [];\n[10, 20].wait(function(item, next, index) {\n\tlog.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(log); // [\"1:10\",\"2:20\"]\n});\n```\n\nExample: Deux éléments à la fois\n```js\nvar running = 0;\nvar max = 0;\n[1, 2, 3, 4, 5].wait(function(item, next) {\n\trunning++;\n\tmax = Math.max(max, running);\n\tsetTimeout(function() {\n\t\trunning--;\n\t\tnext();\n\t}, 10);\n}, function() {\n\tconsole.log(max); // 2\n}, 2);\n```\n\nExample: Vider le tableau\n```js\nvar queue = [1, 2, 3];\nqueue.wait((item, next) => next(), function() {\n\tconsole.log(queue.length); // 0\n}, true);\n```\n","entries":[{"type":"method","name":"attr()","signature":"Array.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"Array.findAll(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"Array.findIndex(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"Array.findItem(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"Array.findValue(filter, value, field, [def], [cache])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"Array.group(key)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"Array.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"Array.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"Array.remove(filter, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"Array.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"Array.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"Array.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"Array.trim()","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"Array.wait(onItem, [callback], [thread])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcNq26d61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/array/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Array","summary":"I metodi che jComponent aggiunge a Array.prototype per cercare, ordinare, suddividere ed elaborare gli elenchi.","markdown":"---\ntitle: Array\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/array/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Array\n\n> I metodi che jComponent aggiunge a Array.prototype per cercare, ordinare, suddividere ed elaborare gli elenchi.\n\njComponent aggiunge questi metodi a ogni array. Gli elenchi preparati con questi metodi vengono spesso renderizzati con [Template con Tangular](../../guides/tangular/).\n\n## API\n\n### Array.attr(name, [value])\n\nType: `method`\n\nAggiunge all'array un attributo HTML sotto forma di testo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'attributo. |\n| `value` | `Object` | no |  | Il valore dell'attributo. |\n\nReturns: `Array` Lo stesso array.\n\nIl valore viene sottoposto a escape e le espressioni `[key]` al suo interno vengono sostituite come in [env()](../string/). Senza `value`, il nome dell'attributo è anche il suo valore. Un valore `null` non aggiunge nulla.\n\nExample: Costruire gli attributi\n```js\nvar attrs = [];\nattrs.attr('id', 'box').attr('title', '<b>').attr('disabled').attr('hidden', null);\nconsole.log(attrs.join(' ')); // id=\"box\" title=\"&lt;b&gt;\" disabled=\"disabled\"\n```\n\n### Array.findAll(filter, [value])\n\nType: `method`\n\nRestituisce tutti gli elementi corrispondenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Il nome del campo, la funzione di test o il valore da trovare. |\n| `value` | `Object` | no |  | Il valore del campo. |\n\nReturns: `Array` Un nuovo array con gli elementi corrispondenti.\n\nCon `filter` e `value`, il metodo confronta il campo chiamato `filter` con `value`. Una funzione riceve `(item, index)`. Con un solo altro valore, il metodo confronta direttamente gli elementi.\n\nExample: Trovare gli elementi\n```js\nconsole.log([{ a: 1 }, { a: 2 }, { a: 1 }].findAll('a', 1)); // [{\"a\":1},{\"a\":1}]\nconsole.log([1, 2, 3].findAll(value => value > 1)); // [2,3]\nconsole.log([1, 2, 1].findAll(1)); // [1,1]\n```\n\n### Array.findIndex(filter, [value])\n\nType: `method`\n\nRestituisce l'indice del primo elemento corrispondente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Il nome del campo, la funzione di test o il valore da trovare. |\n| `value` | `Object` | no |  | Il valore del campo. |\n\nReturns: `Number` L'indice, oppure `-1` quando non c'è nessuna corrispondenza.\n\nGli argomenti funzionano come in `findAll()`.\n\nExample: Trovare un indice\n```js\nconsole.log([{ a: 1 }, { a: 2 }].findIndex('a', 2)); // 1\nconsole.log([5, 6].findIndex((value, index) => index === 1)); // 1\nconsole.log([1, 2].findIndex(9)); // -1\n```\n\n### Array.findItem(filter, [value])\n\nType: `method`\n\nRestituisce il primo elemento corrispondente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Il nome del campo, la funzione di test o il valore da trovare. |\n| `value` | `Object` | no |  | Il valore del campo. |\n\nReturns: `Object` L'elemento, oppure `undefined` quando non c'è nessuna corrispondenza.\n\nGli argomenti funzionano come in `findAll()`.\n\nExample: Trovare un elemento\n```js\nconsole.log([{ id: 1, name: 'A' }].findItem('id', 1)); // {\"id\":1,\"name\":\"A\"}\nconsole.log([1, 2, 3].findItem(value => value > 1)); // 2\nconsole.log([1].findItem(9) === undefined); // true\n```\n\n### Array.findValue(filter, value, field, [def], [cache])\n\nType: `method`\n\nRestituisce un campo del primo elemento corrispondente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String or Function` | yes |  | Il campo da confrontare, oppure la funzione di test. |\n| `value` | `Object` | yes |  | Il valore del campo confrontato. |\n| `field` | `String` | yes |  | Il nome del campo da restituire. |\n| `def` | `Object` | no |  | Il valore restituito quando nessun elemento corrisponde o il campo è vuoto. |\n| `cache` | `Boolean` | no | `false` | Conserva il risultato per le chiamate successive. |\n\nReturns: `Object` Il valore del campo.\n\nCon una funzione come filtro, la firma è `findValue(fn, field, [def], [cache])`. Un `field` annidato si scrive con i punti, ad esempio `user.age`.\n\nCon `cache` impostato su `true`, il risultato viene conservato in [TEMP](../globals/) con una chiave composta dal filtro, dal valore e dal campo. Una chiamata successiva con gli stessi argomenti restituisce il risultato conservato, anche per un altro array.\n\nExample: Leggere un campo\n```js\nvar users = [{ id: 1, name: 'Ana' }];\nconsole.log(users.findValue('id', 1, 'name')); // Ana\nconsole.log(users.findValue('id', 9, 'name', 'nobody')); // nobody\nconsole.log(users.findValue(user => user.id === 1, 'name', 'nobody')); // Ana\nconsole.log([{ id: 1, user: { age: 5 } }].findValue('id', 1, 'user.age')); // 5\n```\n\n### Array.group(key)\n\nType: `method`\n\nRaggruppa gli elementi in base al valore di un campo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Il nome del campo. |\n\nReturns: `Array` Oggetti con i campi `name` e `items`.\n\nI gruppi sono ordinati per nome. Gli elementi senza il campo finiscono in un gruppo con il nome vuoto.\n\nExample: Raggruppamento\n```js\nvar list = [{ type: 'b', id: 1 }, { type: 'a', id: 2 }, { type: 'b', id: 3 }];\nconsole.log(list.group('type')); // [{\"name\":\"a\",\"items\":[{\"type\":\"a\",\"id\":2}]},{\"name\":\"b\",\"items\":[{\"type\":\"b\",\"id\":1},{\"type\":\"b\",\"id\":3}]}]\n```\n\n### Array.last([def])\n\nType: `method`\n\nRestituisce l'ultimo elemento.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | Il valore restituito per un array vuoto. |\n\nReturns: `Object` L'ultimo elemento oppure `def`.\n\nExample: Ultimo elemento\n```js\nconsole.log([1, 2, 3].last()); // 3\nconsole.log([].last('empty')); // empty\n```\n\n### Array.quicksort([sort], [direction])\n\nType: `method`\n\nOrdina l'array sul posto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | I campi in base ai quali ordinare. |\n| `direction` | `Boolean, String or Number` | no |  | `false`, `desc` o `2` ordina un campo in modo decrescente. |\n\nReturns: `Array` Lo stesso array.\n\nSenza argomenti, gli elementi vengono ordinati in modo crescente e confrontati come testo.\n\nUna stringa ordina gli oggetti in base ai loro campi. Ogni campo può terminare con `_asc` o `_desc`, più campi sono separati da virgole e un campo annidato si scrive con i punti. Sono supportati stringhe, numeri, booleani e date.\n\nExample: Valori semplici\n```js\nconsole.log(['b', 'c', 'a'].quicksort()); // [\"a\",\"b\",\"c\"]\n```\n\nExample: Oggetti\n```js\nvar list = [{ name: 'b', age: 1 }, { name: 'a', age: 2 }, { name: 'a', age: 3 }];\nconsole.log(list.quicksort('name_asc,age_desc')); // [{\"name\":\"a\",\"age\":3},{\"name\":\"a\",\"age\":2},{\"name\":\"b\",\"age\":1}]\nconsole.log(list.quicksort('age', 'desc')[0].age); // 3\nconsole.log([{ user: { age: 2 } }, { user: { age: 1 } }].quicksort('user.age')[0].user.age); // 1\n```\n\n### Array.remove(filter, [value])\n\nType: `method`\n\nRestituisce una copia dell'array senza gli elementi corrispondenti.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Il nome del campo, la funzione di test o il valore da rimuovere. |\n| `value` | `Object` | no |  | Il valore del campo. |\n\nReturns: `Array` Un nuovo array con gli elementi rimanenti.\n\nGli argomenti funzionano come in `findAll()`. L'array originale non cambia.\n\nExample: Rimuovere gli elementi\n```js\nconsole.log([{ a: 1 }, { a: 2 }].remove('a', 1)); // [{\"a\":2}]\nconsole.log([1, 2, 3].remove(value => value > 1)); // [1]\nconsole.log([1, 2, 1].remove(1)); // [2]\n```\n\n### Array.skip(count)\n\nType: `method`\n\nRestituisce gli elementi che seguono i primi `count` elementi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | Il numero di elementi da saltare. |\n\nReturns: `Array` Un nuovo array.\n\nExample: Saltare elementi\n```js\nconsole.log([1, 2, 3, 4].skip(2)); // [3,4]\n```\n\n### Array.take(count)\n\nType: `method`\n\nRestituisce i primi `count` elementi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | Il numero di elementi da restituire, a partire da 1. |\n\nReturns: `Array` Un nuovo array.\n\nExample: Prendere elementi\n```js\nconsole.log([1, 2, 3].take(2)); // [1,2]\nconsole.log([1].take(5)); // [1]\n```\n\n### Array.takeskip(take, skip)\n\nType: `method`\n\nSalta un certo numero di elementi e restituisce quelli successivi.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `take` | `Number` | yes |  | Il numero di elementi da restituire. |\n| `skip` | `Number` | yes |  | Il numero di elementi da saltare. |\n\nReturns: `Array` Un nuovo array.\n\nIl metodo è utile per la paginazione.\n\nExample: Una pagina di elementi\n```js\nconsole.log([1, 2, 3, 4, 5].takeskip(2, 1)); // [2,3]\n```\n\n### Array.trim()\n\nType: `method`\n\nElimina gli spazi iniziali e finali dalle stringhe e omette i valori vuoti.\n\nReturns: `Array` Un nuovo array con i valori rimanenti.\n\nOgni valore falsy viene omesso, compreso `0`. Anche le stringhe nell'array originale vengono private degli spazi iniziali e finali.\n\nExample: Pulire un elenco\n```js\nconsole.log([' a ', '', 0, null, 'b ', 5].trim()); // [\"a\",\"b\",5]\n```\n\n### Array.wait(onItem, [callback], [thread])\n\nType: `method`\n\nElabora gli elementi uno dopo l'altro, oppure più elementi alla volta.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | La funzione che elabora un elemento. |\n| `callback` | `Function` | no |  | La funzione chiamata alla fine. |\n| `thread` | `Number or Boolean` | no | `1` | Il numero di elementi in parallelo, oppure `true` per svuotare l'array. |\n\nReturns: `Array` Lo stesso array.\n\n`onItem` riceve `(item, next, index)` e deve chiamare `next()` quando l'elemento è terminato. `index` è la posizione dell'elemento, a partire da 1. `callback` viene eseguito quando tutti gli elementi sono terminati e può essere omesso passando `thread` al suo posto.\n\nUn numero in `thread` stabilisce quanti elementi vengono eseguiti contemporaneamente. `true` rimuove ogni elemento dall'array man mano che viene elaborato, e in questo caso `index` è `0`.\n\nExample: Un elemento alla volta\n```js\nvar log = [];\n[10, 20].wait(function(item, next, index) {\n\tlog.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(log); // [\"1:10\",\"2:20\"]\n});\n```\n\nExample: Due elementi alla volta\n```js\nvar running = 0;\nvar max = 0;\n[1, 2, 3, 4, 5].wait(function(item, next) {\n\trunning++;\n\tmax = Math.max(max, running);\n\tsetTimeout(function() {\n\t\trunning--;\n\t\tnext();\n\t}, 10);\n}, function() {\n\tconsole.log(max); // 2\n}, 2);\n```\n\nExample: Svuotare l'array\n```js\nvar queue = [1, 2, 3];\nqueue.wait((item, next) => next(), function() {\n\tconsole.log(queue.length); // 0\n}, true);\n```\n","entries":[{"type":"method","name":"attr()","signature":"Array.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"Array.findAll(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"Array.findIndex(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"Array.findItem(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"Array.findValue(filter, value, field, [def], [cache])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"Array.group(key)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"Array.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"Array.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"Array.remove(filter, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"Array.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"Array.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"Array.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"Array.trim()","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"Array.wait(onItem, [callback], [thread])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcNq26d61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/array/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Array","summary":"Metódy, ktoré jComponent pridáva do Array.prototype na vyhľadávanie, triedenie, delenie a spracovanie zoznamov.","markdown":"---\ntitle: Array\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/array/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Array\n\n> Metódy, ktoré jComponent pridáva do Array.prototype na vyhľadávanie, triedenie, delenie a spracovanie zoznamov.\n\njComponent pridáva tieto metódy každému poľu. Zoznamy pripravené s ich pomocou sa často vykresľujú pomocou [Šablón s Tangularom](../../guides/tangular/).\n\n## API\n\n### Array.attr(name, [value])\n\nType: `method`\n\nPridá do poľa atribút HTML ako text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov atribútu. |\n| `value` | `Object` | no |  | Hodnota atribútu. |\n\nReturns: `Array` To isté pole.\n\nHodnota sa escapuje a frázy `[key]` v nej sa nahrádzajú ako v [env()](../string/). Bez `value` je názov atribútu zároveň jeho hodnotou. Hodnota `null` nepridá nič.\n\nExample: Vytváranie atribútov\n```js\nvar attrs = [];\nattrs.attr('id', 'box').attr('title', '<b>').attr('disabled').attr('hidden', null);\nconsole.log(attrs.join(' ')); // id=\"box\" title=\"&lt;b&gt;\" disabled=\"disabled\"\n```\n\n### Array.findAll(filter, [value])\n\nType: `method`\n\nVráti všetky zodpovedajúce položky.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Názov poľa, testovacia funkcia alebo hľadaná hodnota. |\n| `value` | `Object` | no |  | Hodnota poľa. |\n\nReturns: `Array` Nové pole so zodpovedajúcimi položkami.\n\nS `filter` a `value` metóda porovná pole s názvom `filter` s hodnotou `value`. Funkcia dostane `(item, index)`. S jednou inou hodnotou metóda porovnáva samotné položky.\n\nExample: Hľadanie položiek\n```js\nconsole.log([{ a: 1 }, { a: 2 }, { a: 1 }].findAll('a', 1)); // [{\"a\":1},{\"a\":1}]\nconsole.log([1, 2, 3].findAll(value => value > 1)); // [2,3]\nconsole.log([1, 2, 1].findAll(1)); // [1,1]\n```\n\n### Array.findIndex(filter, [value])\n\nType: `method`\n\nVráti index prvej zodpovedajúcej položky.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Názov poľa, testovacia funkcia alebo hľadaná hodnota. |\n| `value` | `Object` | no |  | Hodnota poľa. |\n\nReturns: `Number` Index, alebo `-1`, keď nič nezodpovedá.\n\nArgumenty fungujú ako vo `findAll()`.\n\nExample: Hľadanie indexu\n```js\nconsole.log([{ a: 1 }, { a: 2 }].findIndex('a', 2)); // 1\nconsole.log([5, 6].findIndex((value, index) => index === 1)); // 1\nconsole.log([1, 2].findIndex(9)); // -1\n```\n\n### Array.findItem(filter, [value])\n\nType: `method`\n\nVráti prvú zodpovedajúcu položku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Názov poľa, testovacia funkcia alebo hľadaná hodnota. |\n| `value` | `Object` | no |  | Hodnota poľa. |\n\nReturns: `Object` Položka, alebo `undefined`, keď nič nezodpovedá.\n\nArgumenty fungujú ako vo `findAll()`.\n\nExample: Hľadanie položky\n```js\nconsole.log([{ id: 1, name: 'A' }].findItem('id', 1)); // {\"id\":1,\"name\":\"A\"}\nconsole.log([1, 2, 3].findItem(value => value > 1)); // 2\nconsole.log([1].findItem(9) === undefined); // true\n```\n\n### Array.findValue(filter, value, field, [def], [cache])\n\nType: `method`\n\nVráti jedno pole prvej zodpovedajúcej položky.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String or Function` | yes |  | Pole na porovnanie alebo testovacia funkcia. |\n| `value` | `Object` | yes |  | Hodnota porovnávaného poľa. |\n| `field` | `String` | yes |  | Názov poľa, ktoré sa má vrátiť. |\n| `def` | `Object` | no |  | Hodnota vrátená, keď žiadna položka nezodpovedá alebo je pole prázdne. |\n| `cache` | `Boolean` | no | `false` | Uchová výsledok pre neskoršie volania. |\n\nReturns: `Object` Hodnota poľa.\n\nS funkciou ako filtrom je signatúra `findValue(fn, field, [def], [cache])`. Vnorené `field` zapíšeš s bodkami, napríklad `user.age`.\n\nKeď je `cache` nastavené na `true`, výsledok sa uchová v [TEMP](../globals/) pod kľúčom zloženým z filtra, hodnoty a poľa. Neskoršie volanie s rovnakými argumentmi vráti uchovaný výsledok, aj keď ho zavoláš na inom poli.\n\nExample: Čítanie poľa\n```js\nvar users = [{ id: 1, name: 'Ana' }];\nconsole.log(users.findValue('id', 1, 'name')); // Ana\nconsole.log(users.findValue('id', 9, 'name', 'nobody')); // nobody\nconsole.log(users.findValue(user => user.id === 1, 'name', 'nobody')); // Ana\nconsole.log([{ id: 1, user: { age: 5 } }].findValue('id', 1, 'user.age')); // 5\n```\n\n### Array.group(key)\n\nType: `method`\n\nZoskupí položky podľa hodnoty poľa.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `key` | `String` | yes |  | Názov poľa. |\n\nReturns: `Array` Objekty s poľami `name` a `items`.\n\nSkupiny sú zoradené podľa názvu. Položky bez daného poľa sú v skupine s prázdnym názvom.\n\nExample: Zoskupovanie\n```js\nvar list = [{ type: 'b', id: 1 }, { type: 'a', id: 2 }, { type: 'b', id: 3 }];\nconsole.log(list.group('type')); // [{\"name\":\"a\",\"items\":[{\"type\":\"a\",\"id\":2}]},{\"name\":\"b\",\"items\":[{\"type\":\"b\",\"id\":1},{\"type\":\"b\",\"id\":3}]}]\n```\n\n### Array.last([def])\n\nType: `method`\n\nVráti poslednú položku.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `def` | `Object` | no |  | Hodnota vrátená pre prázdne pole. |\n\nReturns: `Object` Posledná položka alebo `def`.\n\nExample: Posledná položka\n```js\nconsole.log([1, 2, 3].last()); // 3\nconsole.log([].last('empty')); // empty\n```\n\n### Array.quicksort([sort], [direction])\n\nType: `method`\n\nZoradí pole na mieste.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `sort` | `String` | no |  | Polia, podľa ktorých sa má zoradiť. |\n| `direction` | `Boolean, String or Number` | no |  | `false`, `desc` alebo `2` zoradí jedno pole zostupne. |\n\nReturns: `Array` To isté pole.\n\nBez argumentov sa položky zoradia vzostupne a porovnávajú sa ako text.\n\nReťazec zoradí objekty podľa ich polí. Každé pole sa môže končiť na `_asc` alebo `_desc`, viacero polí sa oddeľuje čiarkami a vnorené pole sa zapisuje s bodkami. Podporované sú reťazce, čísla, booleovské hodnoty a dátumy.\n\nExample: Jednoduché hodnoty\n```js\nconsole.log(['b', 'c', 'a'].quicksort()); // [\"a\",\"b\",\"c\"]\n```\n\nExample: Objekty\n```js\nvar list = [{ name: 'b', age: 1 }, { name: 'a', age: 2 }, { name: 'a', age: 3 }];\nconsole.log(list.quicksort('name_asc,age_desc')); // [{\"name\":\"a\",\"age\":3},{\"name\":\"a\",\"age\":2},{\"name\":\"b\",\"age\":1}]\nconsole.log(list.quicksort('age', 'desc')[0].age); // 3\nconsole.log([{ user: { age: 2 } }, { user: { age: 1 } }].quicksort('user.age')[0].user.age); // 1\n```\n\n### Array.remove(filter, [value])\n\nType: `method`\n\nVráti kópiu poľa bez zodpovedajúcich položiek.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `filter` | `String, Function or Object` | yes |  | Názov poľa, testovacia funkcia alebo hodnota na odstránenie. |\n| `value` | `Object` | no |  | Hodnota poľa. |\n\nReturns: `Array` Nové pole so zostávajúcimi položkami.\n\nArgumenty fungujú ako vo `findAll()`. Pôvodné pole sa nemení.\n\nExample: Odstraňovanie položiek\n```js\nconsole.log([{ a: 1 }, { a: 2 }].remove('a', 1)); // [{\"a\":2}]\nconsole.log([1, 2, 3].remove(value => value > 1)); // [1]\nconsole.log([1, 2, 1].remove(1)); // [2]\n```\n\n### Array.skip(count)\n\nType: `method`\n\nVráti položky za prvými `count` položkami.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | Počet položiek na preskočenie. |\n\nReturns: `Array` Nové pole.\n\nExample: Preskakovanie\n```js\nconsole.log([1, 2, 3, 4].skip(2)); // [3,4]\n```\n\n### Array.take(count)\n\nType: `method`\n\nVráti prvých `count` položiek.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `count` | `Number` | yes |  | Počet položiek, ktoré sa majú vrátiť, od 1 vyššie. |\n\nReturns: `Array` Nové pole.\n\nExample: Výber\n```js\nconsole.log([1, 2, 3].take(2)); // [1,2]\nconsole.log([1].take(5)); // [1]\n```\n\n### Array.takeskip(take, skip)\n\nType: `method`\n\nPreskočí zadaný počet položiek a vráti nasledujúce.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `take` | `Number` | yes |  | Počet položiek, ktoré sa majú vrátiť. |\n| `skip` | `Number` | yes |  | Počet položiek na preskočenie. |\n\nReturns: `Array` Nové pole.\n\nMetóda je užitočná pri stránkovaní.\n\nExample: Stránka položiek\n```js\nconsole.log([1, 2, 3, 4, 5].takeskip(2, 1)); // [2,3]\n```\n\n### Array.trim()\n\nType: `method`\n\nOreže reťazce a vynechá prázdne hodnoty.\n\nReturns: `Array` Nové pole so zostávajúcimi hodnotami.\n\nVynechá sa každá nepravdivá hodnota vrátane `0`. Orežú sa aj reťazce v pôvodnom poli.\n\nExample: Čistenie zoznamu\n```js\nconsole.log([' a ', '', 0, null, 'b ', 5].trim()); // [\"a\",\"b\",5]\n```\n\n### Array.wait(onItem, [callback], [thread])\n\nType: `method`\n\nSpracuje položky jednu po druhej alebo niekoľko naraz.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `onItem` | `Function` | yes |  | Funkcia, ktorá spracuje položku. |\n| `callback` | `Function` | no |  | Funkcia zavolaná na konci. |\n| `thread` | `Number or Boolean` | no | `1` | Počet paralelných položiek alebo `true` na vyprázdnenie poľa. |\n\nReturns: `Array` To isté pole.\n\n`onItem` dostane `(item, next, index)` a po dokončení položky musí zavolať `next()`. `index` je pozícia položky počítaná od 1. `callback` sa spustí po dokončení všetkých položiek a môžeš ho vynechať a na jeho miesto odovzdať `thread`.\n\nČíslo v `thread` určuje, koľko položiek beží naraz. `true` odstraňuje každú položku z poľa pri jej spracovaní a `index` je potom `0`.\n\nExample: Jedna položka naraz\n```js\nvar log = [];\n[10, 20].wait(function(item, next, index) {\n\tlog.push(index + ':' + item);\n\tsetTimeout(next, 10);\n}, function() {\n\tconsole.log(log); // [\"1:10\",\"2:20\"]\n});\n```\n\nExample: Dve položky naraz\n```js\nvar running = 0;\nvar max = 0;\n[1, 2, 3, 4, 5].wait(function(item, next) {\n\trunning++;\n\tmax = Math.max(max, running);\n\tsetTimeout(function() {\n\t\trunning--;\n\t\tnext();\n\t}, 10);\n}, function() {\n\tconsole.log(max); // 2\n}, 2);\n```\n\nExample: Vyprázdnenie poľa\n```js\nvar queue = [1, 2, 3];\nqueue.wait((item, next) => next(), function() {\n\tconsole.log(queue.length); // 0\n}, true);\n```\n","entries":[{"type":"method","name":"attr()","signature":"Array.attr(name, [value])","since":"","deprecated":false},{"type":"method","name":"findAll()","signature":"Array.findAll(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findIndex()","signature":"Array.findIndex(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findItem()","signature":"Array.findItem(filter, [value])","since":"","deprecated":false},{"type":"method","name":"findValue()","signature":"Array.findValue(filter, value, field, [def], [cache])","since":"","deprecated":false},{"type":"method","name":"group()","signature":"Array.group(key)","since":"","deprecated":false},{"type":"method","name":"last()","signature":"Array.last([def])","since":"","deprecated":false},{"type":"method","name":"quicksort()","signature":"Array.quicksort([sort], [direction])","since":"","deprecated":false},{"type":"method","name":"remove()","signature":"Array.remove(filter, [value])","since":"","deprecated":false},{"type":"method","name":"skip()","signature":"Array.skip(count)","since":"","deprecated":false},{"type":"method","name":"take()","signature":"Array.take(count)","since":"","deprecated":false},{"type":"method","name":"takeskip()","signature":"Array.takeskip(take, skip)","since":"","deprecated":false},{"type":"method","name":"trim()","signature":"Array.trim()","since":"","deprecated":false},{"type":"method","name":"wait()","signature":"Array.wait(onItem, [callback], [thread])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcQT5Id61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/date/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"Date","summary":"Methods that jComponent adds to Date.prototype for date arithmetic, formatting and UTC conversion.","markdown":"---\ntitle: Date\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/date/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Date\n\n> Methods that jComponent adds to Date.prototype for date arithmetic, formatting and UTC conversion.\n\njComponent adds these methods to every date. The default format is set in [DEF](../def/), text is converted to a date with [parseDate()](../string/), and the month and day names come from the global arrays `MONTHS` and `DAYS`.\n\n## API\n\n### Date.add(value)\n\nType: `method`\n\nReturns a new date moved by a duration.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | The duration. |\n\nReturns: `Date` A new date. The original date does not change.\n\nThe value is a number, a space and a unit. A negative number moves the date back, and the number can be a `[key]` phrase set with [ENV()](../globals/). An unknown unit returns an unchanged copy.\n\n| Unit | Accepted names |\n| --- | --- |\n| Seconds | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minutes | `minutes`, `minute`, `min`, `mm`, `m` |\n| Hours | `hours`, `hour`, `hh`, `h` |\n| Days | `days`, `day`, `dd`, `d` |\n| Weeks | `weeks`, `week`, `ww`, `w` |\n| Months | `months`, `month`, `MM`, `M` |\n| Years | `years`, `year`, `yyyy`, `yy`, `y` |\n\nExample: Moving a date\n```js\nvar date = new Date(2026, 0, 15, 10, 0, 0);\nconsole.log(date.add('1 day').format('yyyy-MM-dd')); // 2026-01-16\nconsole.log(date.add('-1 month').format('yyyy-MM-dd')); // 2025-12-15\nconsole.log(date.add('2 hours').format('HH:mm')); // 12:00\nconsole.log(date.add('30 m').format('HH:mm')); // 10:30\nconsole.log(date.format('yyyy-MM-dd HH:mm')); // 2026-01-15 10:00\n```\n\n### Date.format([format], [utc])\n\nType: `method`\n\nWrites the date as text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `DEF.dateformat` | The layout of the text. |\n| `utc` | `Boolean` | no | `false` | `true` writes the date in UTC. |\n\nReturns: `String` The formatted date.\n\nEvery token in `format` is replaced, so other letters that match a token cannot be used as literal text.\n\n| Token | Output | Example |\n| --- | --- | --- |\n| `yyyy`, `YYYY` | Full year | `2026` |\n| `yy`, `YY` | Two-digit year | `26` |\n| `MMMM` | Month name | `November` |\n| `MMM` | First three letters of the month | `Nov` |\n| `MM` | Month with two digits | `11` |\n| `M` | Month | `11` |\n| `dddd`, `DDDD` | Day name | `Sunday` |\n| `ddd`, `DDD` | First two letters of the day in uppercase | `SU` |\n| `dd`, `DD` | Day with two digits | `08` |\n| `d`, `D` | Day | `8` |\n| `HH`, `hh` | Hours with two digits (0 to 23) | `15` |\n| `H`, `h` | Hours (0 to 23) | `15` |\n| `mm` | Minutes with two digits | `04` |\n| `m` | Minutes | `4` |\n| `ss` | Seconds with two digits | `05` |\n| `s` | Seconds | `5` |\n| `ww` | ISO week with two digits | `45` |\n| `w` | ISO week | `45` |\n| `a` | `AM` or `PM` | `PM` |\n\nStart the format with `!` to write the hours on a 12-hour clock, from 1 to 12, for example `!hh:mm a`. A `[key]` format uses the format set with [ENV()](../globals/).\n\n`format('iso')` returns the ISO 8601 date in UTC, the same as `toISOString()`, and an empty string for an invalid date. Setting `DEF.dateformatutc` to `true` makes every call use UTC.\n\nExample: Layouts\n```js\nvar date = new Date(2026, 10, 8, 15, 4, 5);\nconsole.log(date.format()); // 2026-11-08\nconsole.log(date.format('dd.MM.yyyy HH:mm')); // 08.11.2026 15:04\nconsole.log(date.format('dddd, d MMMM yyyy')); // Sunday, 8 November 2026\nconsole.log(date.format('MMM yy')); // Nov 26\nconsole.log(date.format('ww')); // 45\n```\n\nExample: UTC output\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4, 5));\nconsole.log(date.format('yyyy-MM-dd HH:mm', true)); // 2026-11-08 15:04\nconsole.log(date.format('iso')); // 2026-11-08T15:04:05.000Z\n```\n\nExample: 12-hour clock and environment formats\n```js\nvar date = new Date(2026, 10, 8, 12, 30);\nconsole.log(date.format('!hh:mm a')); // 12:30 PM\n\nENV('short', 'dd.MM.');\nconsole.log(date.format('[short]')); // 08.11.\nENV('short', 'MM/dd');\nconsole.log(date.format('[short]')); // 11/08\n```\n\n### Date.toUTC([ticks])\n\nType: `method`\n\nMoves the date by the time zone offset, so that its local fields show the UTC time.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no | `false` | `true` returns the timestamp in milliseconds in place of a `Date`. |\n\nReturns: `Date or Number` The converted date, or its timestamp.\n\nExample: Converting to UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4));\nconsole.log(date.toUTC().format('yyyy-MM-dd HH:mm')); // 2026-11-08 15:04\nconsole.log(date.toUTC(true) === date.toUTC().getTime()); // true\n```\n","entries":[{"type":"method","name":"add()","signature":"Date.add(value)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"Date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcQT5Id61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/date/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"Date","summary":"Methoden, die jComponent zu Date.prototype für Datumsberechnungen, Formatierung und UTC-Umwandlung hinzufügt.","markdown":"---\ntitle: Date\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/date/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Date\n\n> Methoden, die jComponent zu Date.prototype für Datumsberechnungen, Formatierung und UTC-Umwandlung hinzufügt.\n\njComponent fügt diese Methoden jedem Datum hinzu. Das Standardformat wird in [DEF](../def/) festgelegt, Text wird mit [parseDate()](../string/) in ein Datum umgewandelt, und die Monats- und Tagesnamen stammen aus den globalen Arrays `MONTHS` und `DAYS`.\n\n## API\n\n### Date.add(value)\n\nType: `method`\n\nGibt ein neues Datum zurück, das um eine Dauer verschoben ist.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Die Dauer. |\n\nReturns: `Date` Ein neues Datum. Das ursprüngliche Datum bleibt unverändert.\n\nDer Wert besteht aus einer Zahl, einem Leerzeichen und einer Einheit. Eine negative Zahl verschiebt das Datum zurück, und die Zahl kann ein mit [ENV()](../globals/) gesetzter `[key]`-Ausdruck sein. Eine unbekannte Einheit ergibt eine unveränderte Kopie.\n\n| Einheit | Akzeptierte Namen |\n| --- | --- |\n| Sekunden | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minuten | `minutes`, `minute`, `min`, `mm`, `m` |\n| Stunden | `hours`, `hour`, `hh`, `h` |\n| Tage | `days`, `day`, `dd`, `d` |\n| Wochen | `weeks`, `week`, `ww`, `w` |\n| Monate | `months`, `month`, `MM`, `M` |\n| Jahre | `years`, `year`, `yyyy`, `yy`, `y` |\n\nExample: Datum verschieben\n```js\nvar date = new Date(2026, 0, 15, 10, 0, 0);\nconsole.log(date.add('1 day').format('yyyy-MM-dd')); // 2026-01-16\nconsole.log(date.add('-1 month').format('yyyy-MM-dd')); // 2025-12-15\nconsole.log(date.add('2 hours').format('HH:mm')); // 12:00\nconsole.log(date.add('30 m').format('HH:mm')); // 10:30\nconsole.log(date.format('yyyy-MM-dd HH:mm')); // 2026-01-15 10:00\n```\n\n### Date.format([format], [utc])\n\nType: `method`\n\nSchreibt das Datum als Text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `DEF.dateformat` | Das Layout des Textes. |\n| `utc` | `Boolean` | no | `false` | `true` schreibt das Datum in UTC. |\n\nReturns: `String` Das formatierte Datum.\n\nJedes Token in `format` wird ersetzt, andere Buchstaben, die einem Token entsprechen, lassen sich also nicht als wörtlicher Text verwenden.\n\n| Token | Ausgabe | Beispiel |\n| --- | --- | --- |\n| `yyyy`, `YYYY` | Vollständiges Jahr | `2026` |\n| `yy`, `YY` | Zweistelliges Jahr | `26` |\n| `MMMM` | Monatsname | `November` |\n| `MMM` | Die ersten drei Buchstaben des Monats | `Nov` |\n| `MM` | Monat, zweistellig | `11` |\n| `M` | Monat | `11` |\n| `dddd`, `DDDD` | Tagesname | `Sunday` |\n| `ddd`, `DDD` | Die ersten zwei Buchstaben des Tages in Großbuchstaben | `SU` |\n| `dd`, `DD` | Tag, zweistellig | `08` |\n| `d`, `D` | Tag | `8` |\n| `HH`, `hh` | Stunden, zweistellig (0 bis 23) | `15` |\n| `H`, `h` | Stunden (0 bis 23) | `15` |\n| `mm` | Minuten, zweistellig | `04` |\n| `m` | Minuten | `4` |\n| `ss` | Sekunden, zweistellig | `05` |\n| `s` | Sekunden | `5` |\n| `ww` | ISO-Woche, zweistellig | `45` |\n| `w` | ISO-Woche | `45` |\n| `a` | `AM` oder `PM` | `PM` |\n\nBeginne das Format mit `!`, um die Stunden im 12-Stunden-Format von 1 bis 12 zu schreiben, zum Beispiel `!hh:mm a`. Ein `[key]`-Format verwendet das mit [ENV()](../globals/) gesetzte Format.\n\n`format('iso')` gibt das ISO-8601-Datum in UTC zurück, genau wie `toISOString()`, und bei einem ungültigen Datum einen leeren String. Wenn du `DEF.dateformatutc` auf `true` setzt, verwendet jeder Aufruf UTC.\n\nExample: Layouts\n```js\nvar date = new Date(2026, 10, 8, 15, 4, 5);\nconsole.log(date.format()); // 2026-11-08\nconsole.log(date.format('dd.MM.yyyy HH:mm')); // 08.11.2026 15:04\nconsole.log(date.format('dddd, d MMMM yyyy')); // Sunday, 8 November 2026\nconsole.log(date.format('MMM yy')); // Nov 26\nconsole.log(date.format('ww')); // 45\n```\n\nExample: Ausgabe in UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4, 5));\nconsole.log(date.format('yyyy-MM-dd HH:mm', true)); // 2026-11-08 15:04\nconsole.log(date.format('iso')); // 2026-11-08T15:04:05.000Z\n```\n\nExample: 12-Stunden-Format und Formate aus der Umgebung\n```js\nvar date = new Date(2026, 10, 8, 12, 30);\nconsole.log(date.format('!hh:mm a')); // 12:30 PM\n\nENV('short', 'dd.MM.');\nconsole.log(date.format('[short]')); // 08.11.\nENV('short', 'MM/dd');\nconsole.log(date.format('[short]')); // 11/08\n```\n\n### Date.toUTC([ticks])\n\nType: `method`\n\nVerschiebt das Datum um den Zeitzonenversatz, sodass seine lokalen Felder die UTC-Zeit anzeigen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no | `false` | `true` gibt statt eines `Date` den Zeitstempel in Millisekunden zurück. |\n\nReturns: `Date or Number` Das umgewandelte Datum oder sein Zeitstempel.\n\nExample: In UTC umwandeln\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4));\nconsole.log(date.toUTC().format('yyyy-MM-dd HH:mm')); // 2026-11-08 15:04\nconsole.log(date.toUTC(true) === date.toUTC().getTime()); // true\n```\n","entries":[{"type":"method","name":"add()","signature":"Date.add(value)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"Date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcQT5Id61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/date/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Date","summary":"Métodos que jComponent añade a Date.prototype para la aritmética de fechas, el formato y la conversión a UTC.","markdown":"---\ntitle: Date\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/date/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Date\n\n> Métodos que jComponent añade a Date.prototype para la aritmética de fechas, el formato y la conversión a UTC.\n\njComponent añade estos métodos a todas las fechas. El formato predeterminado se establece en [DEF](../def/), el texto se convierte en fecha con [parseDate()](../string/), y los nombres de los meses y los días proceden de los arrays globales `MONTHS` y `DAYS`.\n\n## API\n\n### Date.add(value)\n\nType: `method`\n\nDevuelve una fecha nueva desplazada una duración.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | La duración. |\n\nReturns: `Date` Una fecha nueva. La fecha original no cambia.\n\nEl valor es un número, un espacio y una unidad. Un número negativo mueve la fecha hacia atrás, y el número puede ser una frase `[key]` establecida con [ENV()](../globals/). Una unidad desconocida devuelve una copia sin cambios.\n\n| Unidad | Nombres aceptados |\n| --- | --- |\n| Segundos | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minutos | `minutes`, `minute`, `min`, `mm`, `m` |\n| Horas | `hours`, `hour`, `hh`, `h` |\n| Días | `days`, `day`, `dd`, `d` |\n| Semanas | `weeks`, `week`, `ww`, `w` |\n| Meses | `months`, `month`, `MM`, `M` |\n| Años | `years`, `year`, `yyyy`, `yy`, `y` |\n\nExample: Mover una fecha\n```js\nvar date = new Date(2026, 0, 15, 10, 0, 0);\nconsole.log(date.add('1 day').format('yyyy-MM-dd')); // 2026-01-16\nconsole.log(date.add('-1 month').format('yyyy-MM-dd')); // 2025-12-15\nconsole.log(date.add('2 hours').format('HH:mm')); // 12:00\nconsole.log(date.add('30 m').format('HH:mm')); // 10:30\nconsole.log(date.format('yyyy-MM-dd HH:mm')); // 2026-01-15 10:00\n```\n\n### Date.format([format], [utc])\n\nType: `method`\n\nEscribe la fecha como texto.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `DEF.dateformat` | El patrón del texto. |\n| `utc` | `Boolean` | no | `false` | `true` escribe la fecha en UTC. |\n\nReturns: `String` La fecha con formato.\n\nSe sustituyen todos los tokens de `format`, así que otras letras que coincidan con un token no se pueden usar como texto literal.\n\n| Token | Salida | Ejemplo |\n| --- | --- | --- |\n| `yyyy`, `YYYY` | Año completo | `2026` |\n| `yy`, `YY` | Año con dos dígitos | `26` |\n| `MMMM` | Nombre del mes | `November` |\n| `MMM` | Tres primeras letras del mes | `Nov` |\n| `MM` | Mes con dos dígitos | `11` |\n| `M` | Mes | `11` |\n| `dddd`, `DDDD` | Nombre del día | `Sunday` |\n| `ddd`, `DDD` | Dos primeras letras del día en mayúsculas | `SU` |\n| `dd`, `DD` | Día con dos dígitos | `08` |\n| `d`, `D` | Día | `8` |\n| `HH`, `hh` | Horas con dos dígitos (de 0 a 23) | `15` |\n| `H`, `h` | Horas (de 0 a 23) | `15` |\n| `mm` | Minutos con dos dígitos | `04` |\n| `m` | Minutos | `4` |\n| `ss` | Segundos con dos dígitos | `05` |\n| `s` | Segundos | `5` |\n| `ww` | Semana ISO con dos dígitos | `45` |\n| `w` | Semana ISO | `45` |\n| `a` | `AM` o `PM` | `PM` |\n\nEmpieza el formato con `!` para escribir las horas en formato de 12 horas, de 1 a 12, por ejemplo `!hh:mm a`. Un formato `[key]` usa el formato establecido con [ENV()](../globals/).\n\n`format('iso')` devuelve la fecha ISO 8601 en UTC, igual que `toISOString()`, y una cadena vacía para una fecha no válida. Si estableces `DEF.dateformatutc` en `true`, todas las llamadas usan UTC.\n\nExample: Patrones\n```js\nvar date = new Date(2026, 10, 8, 15, 4, 5);\nconsole.log(date.format()); // 2026-11-08\nconsole.log(date.format('dd.MM.yyyy HH:mm')); // 08.11.2026 15:04\nconsole.log(date.format('dddd, d MMMM yyyy')); // Sunday, 8 November 2026\nconsole.log(date.format('MMM yy')); // Nov 26\nconsole.log(date.format('ww')); // 45\n```\n\nExample: Salida en UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4, 5));\nconsole.log(date.format('yyyy-MM-dd HH:mm', true)); // 2026-11-08 15:04\nconsole.log(date.format('iso')); // 2026-11-08T15:04:05.000Z\n```\n\nExample: Formato de 12 horas y formatos de entorno\n```js\nvar date = new Date(2026, 10, 8, 12, 30);\nconsole.log(date.format('!hh:mm a')); // 12:30 PM\n\nENV('short', 'dd.MM.');\nconsole.log(date.format('[short]')); // 08.11.\nENV('short', 'MM/dd');\nconsole.log(date.format('[short]')); // 11/08\n```\n\n### Date.toUTC([ticks])\n\nType: `method`\n\nDesplaza la fecha según la diferencia de zona horaria, de modo que sus campos locales muestren la hora UTC.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no | `false` | `true` devuelve la marca de tiempo en milisegundos en lugar de un `Date`. |\n\nReturns: `Date or Number` La fecha convertida o su marca de tiempo.\n\nExample: Convertir a UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4));\nconsole.log(date.toUTC().format('yyyy-MM-dd HH:mm')); // 2026-11-08 15:04\nconsole.log(date.toUTC(true) === date.toUTC().getTime()); // true\n```\n","entries":[{"type":"method","name":"add()","signature":"Date.add(value)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"Date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcQT5Id61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/date/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Date","summary":"Les méthodes que jComponent ajoute à Date.prototype pour les calculs sur les dates, le formatage et la conversion UTC.","markdown":"---\ntitle: Date\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/date/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Date\n\n> Les méthodes que jComponent ajoute à Date.prototype pour les calculs sur les dates, le formatage et la conversion UTC.\n\njComponent ajoute ces méthodes à chaque date. Le format par défaut se définit dans [DEF](../def/), le texte est converti en date avec [parseDate()](../string/), et les noms des mois et des jours proviennent des tableaux globaux `MONTHS` et `DAYS`.\n\n## API\n\n### Date.add(value)\n\nType: `method`\n\nRenvoie une nouvelle date décalée d'une durée.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | La durée. |\n\nReturns: `Date` Une nouvelle date. La date d'origine ne change pas.\n\nLa valeur se compose d'un nombre, d'une espace et d'une unité. Un nombre négatif recule la date, et le nombre peut être une expression `[key]` définie avec [ENV()](../globals/). Une unité inconnue renvoie une copie inchangée.\n\n| Unité | Noms acceptés |\n| --- | --- |\n| Secondes | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minutes | `minutes`, `minute`, `min`, `mm`, `m` |\n| Heures | `hours`, `hour`, `hh`, `h` |\n| Jours | `days`, `day`, `dd`, `d` |\n| Semaines | `weeks`, `week`, `ww`, `w` |\n| Mois | `months`, `month`, `MM`, `M` |\n| Années | `years`, `year`, `yyyy`, `yy`, `y` |\n\nExample: Décaler une date\n```js\nvar date = new Date(2026, 0, 15, 10, 0, 0);\nconsole.log(date.add('1 day').format('yyyy-MM-dd')); // 2026-01-16\nconsole.log(date.add('-1 month').format('yyyy-MM-dd')); // 2025-12-15\nconsole.log(date.add('2 hours').format('HH:mm')); // 12:00\nconsole.log(date.add('30 m').format('HH:mm')); // 10:30\nconsole.log(date.format('yyyy-MM-dd HH:mm')); // 2026-01-15 10:00\n```\n\n### Date.format([format], [utc])\n\nType: `method`\n\nÉcrit la date sous forme de texte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `DEF.dateformat` | La disposition du texte. |\n| `utc` | `Boolean` | no | `false` | `true` écrit la date en UTC. |\n\nReturns: `String` La date formatée.\n\nChaque jeton de `format` est remplacé : les autres lettres qui correspondent à un jeton ne peuvent donc pas servir de texte littéral.\n\n| Jeton | Sortie | Exemple |\n| --- | --- | --- |\n| `yyyy`, `YYYY` | Année complète | `2026` |\n| `yy`, `YY` | Année sur deux chiffres | `26` |\n| `MMMM` | Nom du mois | `November` |\n| `MMM` | Trois premières lettres du mois | `Nov` |\n| `MM` | Mois sur deux chiffres | `11` |\n| `M` | Mois | `11` |\n| `dddd`, `DDDD` | Nom du jour | `Sunday` |\n| `ddd`, `DDD` | Deux premières lettres du jour en majuscules | `SU` |\n| `dd`, `DD` | Jour sur deux chiffres | `08` |\n| `d`, `D` | Jour | `8` |\n| `HH`, `hh` | Heures sur deux chiffres (de 0 à 23) | `15` |\n| `H`, `h` | Heures (de 0 à 23) | `15` |\n| `mm` | Minutes sur deux chiffres | `04` |\n| `m` | Minutes | `4` |\n| `ss` | Secondes sur deux chiffres | `05` |\n| `s` | Secondes | `5` |\n| `ww` | Semaine ISO sur deux chiffres | `45` |\n| `w` | Semaine ISO | `45` |\n| `a` | `AM` ou `PM` | `PM` |\n\nCommence le format par `!` pour écrire les heures sur 12 heures, de 1 à 12, par exemple `!hh:mm a`. Un format `[key]` utilise le format défini avec [ENV()](../globals/).\n\n`format('iso')` renvoie la date ISO 8601 en UTC, comme `toISOString()`, et une chaîne vide pour une date non valide. Définir `DEF.dateformatutc` à `true` fait utiliser l'UTC à chaque appel.\n\nExample: Dispositions\n```js\nvar date = new Date(2026, 10, 8, 15, 4, 5);\nconsole.log(date.format()); // 2026-11-08\nconsole.log(date.format('dd.MM.yyyy HH:mm')); // 08.11.2026 15:04\nconsole.log(date.format('dddd, d MMMM yyyy')); // Sunday, 8 November 2026\nconsole.log(date.format('MMM yy')); // Nov 26\nconsole.log(date.format('ww')); // 45\n```\n\nExample: Sortie en UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4, 5));\nconsole.log(date.format('yyyy-MM-dd HH:mm', true)); // 2026-11-08 15:04\nconsole.log(date.format('iso')); // 2026-11-08T15:04:05.000Z\n```\n\nExample: Horloge sur 12 heures et formats d'environnement\n```js\nvar date = new Date(2026, 10, 8, 12, 30);\nconsole.log(date.format('!hh:mm a')); // 12:30 PM\n\nENV('short', 'dd.MM.');\nconsole.log(date.format('[short]')); // 08.11.\nENV('short', 'MM/dd');\nconsole.log(date.format('[short]')); // 11/08\n```\n\n### Date.toUTC([ticks])\n\nType: `method`\n\nDécale la date du fuseau horaire, pour que ses champs locaux affichent l'heure UTC.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no | `false` | `true` renvoie l'horodatage en millisecondes au lieu d'une `Date`. |\n\nReturns: `Date or Number` La date convertie, ou son horodatage.\n\nExample: Convertir en UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4));\nconsole.log(date.toUTC().format('yyyy-MM-dd HH:mm')); // 2026-11-08 15:04\nconsole.log(date.toUTC(true) === date.toUTC().getTime()); // true\n```\n","entries":[{"type":"method","name":"add()","signature":"Date.add(value)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"Date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcQT5Id61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/date/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Date","summary":"I metodi che jComponent aggiunge a Date.prototype per l'aritmetica delle date, la formattazione e la conversione in UTC.","markdown":"---\ntitle: Date\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/date/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Date\n\n> I metodi che jComponent aggiunge a Date.prototype per l'aritmetica delle date, la formattazione e la conversione in UTC.\n\njComponent aggiunge questi metodi a ogni data. Il formato predefinito si imposta in [DEF](../def/), il testo viene convertito in data con [parseDate()](../string/), e i nomi dei mesi e dei giorni provengono dagli array globali `MONTHS` e `DAYS`.\n\n## API\n\n### Date.add(value)\n\nType: `method`\n\nRestituisce una nuova data spostata di una durata.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | La durata. |\n\nReturns: `Date` Una nuova data. La data originale non cambia.\n\nIl valore è composto da un numero, uno spazio e un'unità. Un numero negativo sposta la data indietro, e il numero può essere un'espressione `[key]` impostata con [ENV()](../globals/). Un'unità sconosciuta restituisce una copia invariata.\n\n| Unità | Nomi accettati |\n| --- | --- |\n| Secondi | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minuti | `minutes`, `minute`, `min`, `mm`, `m` |\n| Ore | `hours`, `hour`, `hh`, `h` |\n| Giorni | `days`, `day`, `dd`, `d` |\n| Settimane | `weeks`, `week`, `ww`, `w` |\n| Mesi | `months`, `month`, `MM`, `M` |\n| Anni | `years`, `year`, `yyyy`, `yy`, `y` |\n\nExample: Spostare una data\n```js\nvar date = new Date(2026, 0, 15, 10, 0, 0);\nconsole.log(date.add('1 day').format('yyyy-MM-dd')); // 2026-01-16\nconsole.log(date.add('-1 month').format('yyyy-MM-dd')); // 2025-12-15\nconsole.log(date.add('2 hours').format('HH:mm')); // 12:00\nconsole.log(date.add('30 m').format('HH:mm')); // 10:30\nconsole.log(date.format('yyyy-MM-dd HH:mm')); // 2026-01-15 10:00\n```\n\n### Date.format([format], [utc])\n\nType: `method`\n\nScrive la data come testo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `DEF.dateformat` | Il layout del testo. |\n| `utc` | `Boolean` | no | `false` | `true` scrive la data in UTC. |\n\nReturns: `String` La data formattata.\n\nOgni token in `format` viene sostituito, quindi le altre lettere che corrispondono a un token non possono essere usate come testo letterale.\n\n| Token | Risultato | Esempio |\n| --- | --- | --- |\n| `yyyy`, `YYYY` | Anno completo | `2026` |\n| `yy`, `YY` | Anno a due cifre | `26` |\n| `MMMM` | Nome del mese | `November` |\n| `MMM` | Prime tre lettere del mese | `Nov` |\n| `MM` | Mese a due cifre | `11` |\n| `M` | Mese | `11` |\n| `dddd`, `DDDD` | Nome del giorno | `Sunday` |\n| `ddd`, `DDD` | Prime due lettere del giorno in maiuscolo | `SU` |\n| `dd`, `DD` | Giorno a due cifre | `08` |\n| `d`, `D` | Giorno | `8` |\n| `HH`, `hh` | Ore a due cifre (da 0 a 23) | `15` |\n| `H`, `h` | Ore (da 0 a 23) | `15` |\n| `mm` | Minuti a due cifre | `04` |\n| `m` | Minuti | `4` |\n| `ss` | Secondi a due cifre | `05` |\n| `s` | Secondi | `5` |\n| `ww` | Settimana ISO a due cifre | `45` |\n| `w` | Settimana ISO | `45` |\n| `a` | `AM` o `PM` | `PM` |\n\nInizia il formato con `!` per scrivere le ore nel formato a 12 ore, da 1 a 12, ad esempio `!hh:mm a`. Un formato `[key]` usa il formato impostato con [ENV()](../globals/).\n\n`format('iso')` restituisce la data ISO 8601 in UTC, come `toISOString()`, e una stringa vuota per una data non valida. Impostando `DEF.dateformatutc` su `true`, ogni chiamata usa UTC.\n\nExample: Layout\n```js\nvar date = new Date(2026, 10, 8, 15, 4, 5);\nconsole.log(date.format()); // 2026-11-08\nconsole.log(date.format('dd.MM.yyyy HH:mm')); // 08.11.2026 15:04\nconsole.log(date.format('dddd, d MMMM yyyy')); // Sunday, 8 November 2026\nconsole.log(date.format('MMM yy')); // Nov 26\nconsole.log(date.format('ww')); // 45\n```\n\nExample: Output in UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4, 5));\nconsole.log(date.format('yyyy-MM-dd HH:mm', true)); // 2026-11-08 15:04\nconsole.log(date.format('iso')); // 2026-11-08T15:04:05.000Z\n```\n\nExample: Formato a 12 ore e formati dall'ambiente\n```js\nvar date = new Date(2026, 10, 8, 12, 30);\nconsole.log(date.format('!hh:mm a')); // 12:30 PM\n\nENV('short', 'dd.MM.');\nconsole.log(date.format('[short]')); // 08.11.\nENV('short', 'MM/dd');\nconsole.log(date.format('[short]')); // 11/08\n```\n\n### Date.toUTC([ticks])\n\nType: `method`\n\nSposta la data in base al fuso orario, in modo che i suoi campi locali mostrino l'ora UTC.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no | `false` | `true` restituisce il timestamp in millisecondi al posto di un `Date`. |\n\nReturns: `Date or Number` La data convertita, oppure il suo timestamp.\n\nExample: Convertire in UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4));\nconsole.log(date.toUTC().format('yyyy-MM-dd HH:mm')); // 2026-11-08 15:04\nconsole.log(date.toUTC(true) === date.toUTC().getTime()); // true\n```\n","entries":[{"type":"method","name":"add()","signature":"Date.add(value)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"Date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcQT5Id61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/date/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Date","summary":"Metódy, ktoré jComponent pridáva do Date.prototype na počítanie s dátumami, formátovanie a prevod na UTC.","markdown":"---\ntitle: Date\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/date/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Date\n\n> Metódy, ktoré jComponent pridáva do Date.prototype na počítanie s dátumami, formátovanie a prevod na UTC.\n\njComponent pridáva tieto metódy každému dátumu. Predvolený formát sa nastavuje v [DEF](../def/), text sa na dátum prevádza pomocou [parseDate()](../string/) a názvy mesiacov a dní pochádzajú z globálnych polí `MONTHS` a `DAYS`.\n\n## API\n\n### Date.add(value)\n\nType: `method`\n\nVráti nový dátum posunutý o zadané trvanie.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `value` | `String` | yes |  | Trvanie. |\n\nReturns: `Date` Nový dátum. Pôvodný dátum sa nemení.\n\nHodnotu tvorí číslo, medzera a jednotka. Záporné číslo posunie dátum dozadu a číslom môže byť fráza `[key]` nastavená pomocou [ENV()](../globals/). Neznáma jednotka vráti nezmenenú kópiu.\n\n| Jednotka | Prijímané názvy |\n| --- | --- |\n| Sekundy | `seconds`, `second`, `sec`, `ss`, `s` |\n| Minúty | `minutes`, `minute`, `min`, `mm`, `m` |\n| Hodiny | `hours`, `hour`, `hh`, `h` |\n| Dni | `days`, `day`, `dd`, `d` |\n| Týždne | `weeks`, `week`, `ww`, `w` |\n| Mesiace | `months`, `month`, `MM`, `M` |\n| Roky | `years`, `year`, `yyyy`, `yy`, `y` |\n\nExample: Posun dátumu\n```js\nvar date = new Date(2026, 0, 15, 10, 0, 0);\nconsole.log(date.add('1 day').format('yyyy-MM-dd')); // 2026-01-16\nconsole.log(date.add('-1 month').format('yyyy-MM-dd')); // 2025-12-15\nconsole.log(date.add('2 hours').format('HH:mm')); // 12:00\nconsole.log(date.add('30 m').format('HH:mm')); // 10:30\nconsole.log(date.format('yyyy-MM-dd HH:mm')); // 2026-01-15 10:00\n```\n\n### Date.format([format], [utc])\n\nType: `method`\n\nZapíše dátum ako text.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `format` | `String` | no | `DEF.dateformat` | Rozloženie textu. |\n| `utc` | `Boolean` | no | `false` | `true` zapíše dátum v UTC. |\n\nReturns: `String` Naformátovaný dátum.\n\nKaždý token vo `format` sa nahradí, takže ďalšie písmená zhodné s tokenom nemožno použiť ako doslovný text.\n\n| Token | Výstup | Príklad |\n| --- | --- | --- |\n| `yyyy`, `YYYY` | Celý rok | `2026` |\n| `yy`, `YY` | Dvojciferný rok | `26` |\n| `MMMM` | Názov mesiaca | `November` |\n| `MMM` | Prvé tri písmená mesiaca | `Nov` |\n| `MM` | Mesiac s dvoma číslicami | `11` |\n| `M` | Mesiac | `11` |\n| `dddd`, `DDDD` | Názov dňa | `Sunday` |\n| `ddd`, `DDD` | Prvé dve písmená dňa veľkými písmenami | `SU` |\n| `dd`, `DD` | Deň s dvoma číslicami | `08` |\n| `d`, `D` | Deň | `8` |\n| `HH`, `hh` | Hodiny s dvoma číslicami (0 až 23) | `15` |\n| `H`, `h` | Hodiny (0 až 23) | `15` |\n| `mm` | Minúty s dvoma číslicami | `04` |\n| `m` | Minúty | `4` |\n| `ss` | Sekundy s dvoma číslicami | `05` |\n| `s` | Sekundy | `5` |\n| `ww` | Týždeň ISO s dvoma číslicami | `45` |\n| `w` | Týždeň ISO | `45` |\n| `a` | `AM` alebo `PM` | `PM` |\n\nAk chceš hodiny zapísať v 12-hodinovom formáte, od 1 do 12, začni formát znakom `!`, napríklad `!hh:mm a`. Formát `[key]` použije formát nastavený cez [ENV()](../globals/).\n\n`format('iso')` vráti dátum ISO 8601 v UTC, rovnako ako `toISOString()`, a pre neplatný dátum prázdny reťazec. Nastavenie `DEF.dateformatutc` na `true` zabezpečí, že každé volanie použije UTC.\n\nExample: Rozloženia\n```js\nvar date = new Date(2026, 10, 8, 15, 4, 5);\nconsole.log(date.format()); // 2026-11-08\nconsole.log(date.format('dd.MM.yyyy HH:mm')); // 08.11.2026 15:04\nconsole.log(date.format('dddd, d MMMM yyyy')); // Sunday, 8 November 2026\nconsole.log(date.format('MMM yy')); // Nov 26\nconsole.log(date.format('ww')); // 45\n```\n\nExample: Výstup v UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4, 5));\nconsole.log(date.format('yyyy-MM-dd HH:mm', true)); // 2026-11-08 15:04\nconsole.log(date.format('iso')); // 2026-11-08T15:04:05.000Z\n```\n\nExample: 12-hodinový formát a formáty z prostredia\n```js\nvar date = new Date(2026, 10, 8, 12, 30);\nconsole.log(date.format('!hh:mm a')); // 12:30 PM\n\nENV('short', 'dd.MM.');\nconsole.log(date.format('[short]')); // 08.11.\nENV('short', 'MM/dd');\nconsole.log(date.format('[short]')); // 11/08\n```\n\n### Date.toUTC([ticks])\n\nType: `method`\n\nPosunie dátum o posun časového pásma, aby jeho lokálne polia zobrazovali čas UTC.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `ticks` | `Boolean` | no | `false` | `true` vráti namiesto `Date` časovú značku v milisekundách. |\n\nReturns: `Date or Number` Prevedený dátum alebo jeho časová značka.\n\nExample: Prevod na UTC\n```js\nvar date = new Date(Date.UTC(2026, 10, 8, 15, 4));\nconsole.log(date.toUTC().format('yyyy-MM-dd HH:mm')); // 2026-11-08 15:04\nconsole.log(date.toUTC(true) === date.toUTC().getTime()); // true\n```\n","entries":[{"type":"method","name":"add()","signature":"Date.add(value)","since":"","deprecated":false},{"type":"method","name":"format()","signature":"Date.format([format], [utc])","since":"","deprecated":false},{"type":"method","name":"toUTC()","signature":"Date.toUTC([ticks])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcUf56o61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/reference/jquery/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"en","title":"jQuery extensions","summary":"Methods that jComponent adds to jQuery for classes, attributes, SVG, finding instances and calling the library.","markdown":"---\ntitle: jQuery extensions\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/reference/jquery/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# jQuery extensions\n\n> Methods that jComponent adds to jQuery for classes, attributes, SVG, finding instances and calling the library.\n\njComponent includes jQuery and adds these methods to every jQuery selection. They are mostly used inside components and plugins: see [Creating components](../../guides/creating-components/) and [Plugins](../../guides/plugins/).\n\n## API\n\n### $(selector).aclass(name, [delay])\n\nType: `method`\n\nAdds a CSS class.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The class name. |\n| `delay` | `Number` | no |  | The delay in milliseconds. |\n\nReturns: `jQuery` The same selection.\n\nWith `delay`, the class is added later. Each element holds one delayed class change: a new delayed call from `aclass()`, `rclass()` or `rclass2()` replaces the one that is waiting.\n\nExample: Adding a class\n```js\nvar el = $('<div>');\nel.aclass('active');\nconsole.log(el.attr('class')); // active\n```\n\nExample: Adding a class later\n```js\nvar el = $('<div>');\nel.aclass('active', 50);\nconsole.log(el.hclass('active')); // false\nsetTimeout(function() {\n\tconsole.log(el.hclass('active')); // true\n}, 100);\n```\n\n### $(selector).asvg(tag)\n\nType: `method`\n\nAppends an SVG element.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | A tag name or SVG markup. |\n\nReturns: `jQuery` The new element when `tag` is a tag name.\n\nWith a tag name, the method creates the element in the SVG namespace and returns it. `tag` can also be SVG markup, which is appended to the selection.\n\nExample: Drawing\n```js\nvar svg = $('<svg></svg>');\nvar circle = svg.asvg('circle');\ncircle.attr('r', 5);\nsvg.asvg('<rect width=\"5\"></rect>');\nconsole.log(circle[0].namespaceURI); // http://www.w3.org/2000/svg\nconsole.log(svg.html()); // <circle r=\"5\"></circle><rect width=\"5\"></rect>\n```\n\n### $(selector).attrd(name, [value])\n\nType: `method`\n\nReads or writes a `data-` attribute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The attribute name without `data-`. |\n| `value` | `Object` | no |  | The value to write. |\n\nReturns: `String or jQuery` The value when reading, or the same selection when writing.\n\nExample: Reading and writing\n```js\nvar el = $('<div data-id=\"7\">');\nconsole.log(el.attrd('id')); // 7\nel.attrd('name', 'box');\nconsole.log(el.attr('data-name')); // box\n```\n\n### $(selector).attrd2(name)\n\nType: `method`\n\nReads a `data-` attribute from the element or from its closest parent that has it.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The attribute name without `data-`. |\n\nReturns: `String` The value, or `undefined` when no element has the attribute.\n\nThe search ends at `<body>`.\n\nExample: Searching the parents\n```html\n<div data-id=\"7\"><span><b id=\"item\"></b></span></div>\n<script>\nconsole.log($('#item').attrd2('id')); // 7\nconsole.log($('#item').attrd2('missing') === undefined); // true\n</script>\n```\n\n### $(selector).autofocus([selector])\n\nType: `method`\n\nMoves the focus to the first visible field inside the selection.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | The fields to search. |\n\nReturns: `jQuery` The same selection.\n\nThe method tries again for a short time when no field can take the focus yet. It does nothing on mobile devices.\n\nExample: Focusing a form\n```html\n<div id=\"form\"><input id=\"code\" type=\"hidden\"><input id=\"name\"></div>\n<script>\n$('#form').autofocus();\nconsole.log(document.activeElement.id); // name\n</script>\n```\n\n### $(selector).binder()\n\nType: `method`\n\nReturns the closest [ui-bind](../ui-bind/) instance.\n\nReturns: `Object` The instance, or `undefined` when there is none.\n\nThe search starts at the first element of the selection and goes through its parents.\n\nExample: Finding the binder\n```html\n<ui-bind id=\"title\" path=\"common.title\" config=\"text\"></ui-bind>\n<script>\nsetTimeout(function() {\n\tconsole.log($('#title').binder().element[0].tagName); // UI-BIND\n\tconsole.log($('body').binder() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuns a command on the components inside the selection.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The command, optionally followed by flags. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nOnly the components nested in the selected elements are reached. Components register commands with [command()](../component/), and the global [CMD()](../globals/) reaches all of them. The method returns nothing.\n\nExample: A command in one panel\n```html\n<div id=\"left\"><ui-component name=\"list\" id=\"a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"list\" id=\"b\"></ui-component></div>\n<script>\nCOMPONENT('list', function(self) {\n\tself.command('clear', () => console.log('clear', self.element.attr('id')));\n});\nON('ready', function() {\n\t$('#left').CMD('clear'); // clear a\n});\n</script>\n```\n\n### $(selector).component()\n\nType: `method`\n\nReturns the closest [Component](../component/) instance.\n\nReturns: `Component` The instance, or `undefined` when there is none.\n\nThe search starts at the first element of the selection and goes through its parents.\n\nExample: Finding the component\n```html\n<ui-component name=\"note\" path=\"common.note\"><b id=\"label\"></b></ui-component>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('#label').component().name); // note\n\tconsole.log($('body').component() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).COMPONENTS()\n\nType: `method`\n\nReturns the ready components inside the selection.\n\nReturns: `Array` The [Component](../component/) instances.\n\nExample: Listing components\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\"></ui-component></div>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('body').COMPONENTS().length); // 2\n\tconsole.log($('#left').COMPONENTS()[0].path.toString()); // common.a\n}, 300);\n</script>\n```\n\n### $(selector).EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuns a function, a plugin method, an event or a component setter.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | What to run. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nThe form of `name` selects what runs:\n\n| Name | What runs |\n| --- | --- |\n| `myfunction` | A global function |\n| `FUNC.path` | The function at a path |\n| `plugin/method` | A method of a plugin |\n| `?/method`, `\\|method` | A method of the closest plugin |\n| `#name` | The event `name` |\n| `-component/method` | A component setter |\n\nThe method returns nothing.\n\nExample: Running a function\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = id => out.push('save ' + id);\n});\nFUNC.hello = name => out.push('hello ' + name);\nON('saved', id => out.push('event ' + id));\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.EXEC('FUNC.hello', 'Ana');\n\tbutton.EXEC('orders/save', 1);\n\tbutton.EXEC('?/save', 2);\n\tbutton.EXEC('|save', 3);\n\tbutton.EXEC('#saved', 4);\n\tconsole.log(out); // [\"hello Ana\",\"save 1\",\"save 2\",\"save 3\",\"event 4\"]\n}, 300);\n</script>\n```\n\n### $(selector).hclass(name)\n\nType: `method`\n\nChecks if the element has a CSS class.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The class name. |\n\nReturns: `Boolean` `true` when the class is present.\n\nExample: Checking a class\n```js\nvar el = $('<div class=\"active\">');\nconsole.log(el.hclass('active')); // true\nconsole.log(el.hclass('hidden')); // false\n```\n\n### $(selector).multiple(selectors)\n\nType: `method`\n\nRuns several searches inside the selection at once.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | The result keys and their selectors. |\n\nReturns: `Object` A jQuery selection for each key.\n\nExample: Finding elements\n```js\nvar el = $('<div><input><input><button></button></div>');\nvar found = el.multiple({ fields: 'input', submit: 'button' });\nconsole.log(found.fields.length); // 2\nconsole.log(found.submit.length); // 1\n```\n\n### $(selector).plugin()\n\nType: `method`\n\nReturns the closest [Plugin](../plugin/) instance.\n\nReturns: `Plugin` The instance, or `undefined` when there is none.\n\nThe search starts at the first element of the selection and goes through its parents.\n\nExample: Finding the plugin\n```html\n<ui-plugin path=\"orders\"><b id=\"label\"></b></ui-plugin>\n<script>\nPLUGIN('orders', function(exports) {});\nsetTimeout(function() {\n\tconsole.log($('#label').plugin().name); // orders\n\tconsole.log($('body').plugin() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).psvg(tag)\n\nType: `method`\n\nInserts an SVG element at the start of the selection.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | A tag name or SVG markup. |\n\nReturns: `jQuery` The new element when `tag` is a tag name.\n\nWith a tag name, the method creates the element in the SVG namespace and returns it. `tag` can also be SVG markup, which is inserted at the start of the selection.\n\nExample: Inserting first\n```js\nvar svg = $('<svg><line></line></svg>');\nvar group = svg.psvg('g');\nsvg.psvg('<path></path>');\nconsole.log(group[0].tagName); // g\nconsole.log(svg.html()); // <path></path><g></g><line></line>\n```\n\n### $(selector).rattr(name)\n\nType: `method`\n\nRemoves an attribute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The attribute name. |\n\nReturns: `jQuery` The same selection.\n\nExample: Removing an attribute\n```js\nvar el = $('<div title=\"x\" id=\"a\">');\nel.rattr('title');\nconsole.log(el[0].outerHTML); // <div id=\"a\"></div>\n```\n\n### $(selector).rattrd(name, [name2], [...])\n\nType: `method`\n\nRemoves `data-` attributes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The attribute name without `data-`. Each further argument removes one more attribute. |\n\nReturns: `jQuery` The same selection.\n\nExample: Removing attributes\n```js\nvar el = $('<div data-a=\"1\" data-b=\"2\" data-c=\"3\">');\nel.rattrd('a', 'b');\nconsole.log(el[0].outerHTML); // <div data-c=\"3\"></div>\n```\n\n### $(selector).rclass([name], [delay])\n\nType: `method`\n\nRemoves a CSS class, or all of them.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | The class name. |\n| `delay` | `Number` | no |  | The delay in milliseconds. |\n\nReturns: `jQuery` The same selection.\n\nWithout `name`, every class is removed. With `delay`, the class is removed later, and the delayed change works as in `aclass()`.\n\nExample: Removing classes\n```js\nvar el = $('<div class=\"a b c\">');\nel.rclass('a');\nconsole.log(el.attr('class')); // b c\nel.rclass();\nconsole.log(el.attr('class') === ''); // true\n```\n\n### $(selector).rclass2(search, [delay])\n\nType: `method`\n\nRemoves all the CSS classes that contain a text or match a pattern.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | The text to find or the pattern to test. |\n| `delay` | `Number` | no |  | The delay in milliseconds. |\n\nReturns: `jQuery` The same selection.\n\nWith `delay`, the classes are removed later, and the delayed change works as in `aclass()`.\n\nExample: Removing by text or pattern\n```js\nvar el = $('<div class=\"tab-1 tab-2 box\">');\nel.rclass2('tab-');\nconsole.log(el.attr('class')); // box\nvar other = $('<div class=\"tab-1 tab-2 box\">');\nother.rclass2(/1$/);\nconsole.log(other.attr('class')); // tab-2 box\n```\n\n### $(selector).scrollbar()\n\nType: `method`\n\nReturns the closest custom scrollbar created with [SCROLLBAR()](../globals/).\n\nReturns: `Object` The scrollbar instance, or `undefined` when there is none.\n\nThe search starts at the first element of the selection and goes through its parents.\n\nExample: Finding the scrollbar\n```html\n<div id=\"area\" style=\"height:50px\"><p id=\"text\"></p></div>\n<script>\nvar scrollbar = SCROLLBAR($('#area'));\nconsole.log($('#text').scrollbar() === scrollbar); // true\nconsole.log($('body').scrollbar() === undefined); // true\n</script>\n```\n\n### $(selector).SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuns a function when it exists, otherwise writes a value to a path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The function or the path. |\n| `a` | `Object` | no |  | The first argument, or the value for the path. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\nA global function, `plugin/method` and `?/method` are called with the arguments. Any other name is a path, and `a` is written to it with [SET()](../globals/). The method returns nothing.\n\nExample: Function or path\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = (a, b) => out.push(a + b);\n});\nwindow.hello = name => out.push('hello ' + name);\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.SEEX('hello', 'Ana');\n\tbutton.SEEX('?/save', 1, 2);\n\tbutton.SEEX('common.count', 5);\n\tconsole.log(out); // [\"hello Ana\",3]\n\tconsole.log(GET('common.count')); // 5\n}, 300);\n</script>\n```\n\n### $(selector).SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nCalls a method of the components inside the selection.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The components and the method. |\n| `a` | `Object` | no |  | The first argument. |\n| `b` | `Object` | no |  | The second argument. |\n| `c` | `Object` | no |  | The third argument. |\n| `d` | `Object` | no |  | The fourth argument. |\n\n`name` is `component/method`. In place of the component name, `*` selects all the components and `.path` selects the components bound to that path. The method returns nothing.\n\nExample: Calling components\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\" config=\"label:A\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\" config=\"label:B\"></ui-component></div>\n<script>\nvar out = [];\nCOMPONENT('note', function(self, config) {\n\tself.show = text => out.push(config.label + ' ' + text);\n});\nsetTimeout(function() {\n\t$('#left').SETTER('note/show', 'one');\n\t$('body').SETTER('*/show', 'two');\n\t$('body').SETTER('.common.b/show', 'three');\n\tconsole.log(out); // [\"A one\",\"A two\",\"B two\",\"B three\"]\n}, 300);\n</script>\n```\n\n### $(selector).tclass(name, [enable])\n\nType: `method`\n\nToggles a CSS class.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | The class name. |\n| `enable` | `Boolean` | no |  | `true` adds the class and `false` removes it. |\n\nReturns: `jQuery` The same selection.\n\nExample: Toggling\n```js\nvar el = $('<div>');\nel.tclass('open');\nconsole.log(el.hclass('open')); // true\nel.tclass('open');\nconsole.log(el.hclass('open')); // false\nel.tclass('open', true);\nconsole.log(el.hclass('open')); // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"$(selector).aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"$(selector).asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"$(selector).attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"$(selector).attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"$(selector).autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"$(selector).binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"$(selector).CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"$(selector).component()","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"$(selector).COMPONENTS()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"$(selector).EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"$(selector).hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"$(selector).multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"$(selector).plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"$(selector).psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"$(selector).rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"$(selector).rattrd(name, [name2], [...])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"$(selector).rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"$(selector).rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"scrollbar()","signature":"$(selector).scrollbar()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"$(selector).SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"$(selector).SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"$(selector).tclass(name, [enable])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcUf56o61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/jquery/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"de","title":"jQuery-Erweiterungen","summary":"Methoden, die jComponent zu jQuery hinzufügt: für Klassen, Attribute, SVG, das Finden von Instanzen und den Aufruf der Bibliothek.","markdown":"---\ntitle: jQuery-Erweiterungen\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/reference/jquery/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# jQuery-Erweiterungen\n\n> Methoden, die jComponent zu jQuery hinzufügt: für Klassen, Attribute, SVG, das Finden von Instanzen und den Aufruf der Bibliothek.\n\njComponent enthält jQuery und fügt jeder jQuery-Auswahl diese Methoden hinzu. Diese Methoden kommen vor allem in Komponenten und Plugins zum Einsatz: Siehe [Komponenten erstellen](../../guides/creating-components/) und [Plugins](../../guides/plugins/).\n\n## API\n\n### $(selector).aclass(name, [delay])\n\nType: `method`\n\nFügt eine CSS-Klasse hinzu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Klassenname. |\n| `delay` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nReturns: `jQuery` Dieselbe Auswahl.\n\nMit `delay` wird die Klasse später hinzugefügt. Jedes Element merkt sich eine verzögerte Klassenänderung: Ein neuer verzögerter Aufruf von `aclass()`, `rclass()` oder `rclass2()` ersetzt den wartenden.\n\nExample: Klasse hinzufügen\n```js\nvar el = $('<div>');\nel.aclass('active');\nconsole.log(el.attr('class')); // active\n```\n\nExample: Klasse später hinzufügen\n```js\nvar el = $('<div>');\nel.aclass('active', 50);\nconsole.log(el.hclass('active')); // false\nsetTimeout(function() {\n\tconsole.log(el.hclass('active')); // true\n}, 100);\n```\n\n### $(selector).asvg(tag)\n\nType: `method`\n\nHängt ein SVG-Element an.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Ein Tag-Name oder SVG-Markup. |\n\nReturns: `jQuery` Das neue Element, wenn `tag` ein Tag-Name ist.\n\nMit einem Tag-Namen erstellt die Methode das Element im SVG-Namespace und gibt es zurück. `tag` kann auch SVG-Markup sein, das an die Auswahl angehängt wird.\n\nExample: Zeichnen\n```js\nvar svg = $('<svg></svg>');\nvar circle = svg.asvg('circle');\ncircle.attr('r', 5);\nsvg.asvg('<rect width=\"5\"></rect>');\nconsole.log(circle[0].namespaceURI); // http://www.w3.org/2000/svg\nconsole.log(svg.html()); // <circle r=\"5\"></circle><rect width=\"5\"></rect>\n```\n\n### $(selector).attrd(name, [value])\n\nType: `method`\n\nLiest oder schreibt ein `data-`-Attribut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Attributname ohne `data-`. |\n| `value` | `Object` | no |  | Der zu schreibende Wert. |\n\nReturns: `String or jQuery` Beim Lesen der Wert, beim Schreiben dieselbe Auswahl.\n\nExample: Lesen und schreiben\n```js\nvar el = $('<div data-id=\"7\">');\nconsole.log(el.attrd('id')); // 7\nel.attrd('name', 'box');\nconsole.log(el.attr('data-name')); // box\n```\n\n### $(selector).attrd2(name)\n\nType: `method`\n\nLiest ein `data-`-Attribut vom Element oder von seinem nächsten übergeordneten Element, das dieses Attribut hat.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Attributname ohne `data-`. |\n\nReturns: `String` Der Wert oder `undefined`, wenn kein Element das Attribut hat.\n\nDie Suche endet bei `<body>`.\n\nExample: Übergeordnete Elemente durchsuchen\n```html\n<div data-id=\"7\"><span><b id=\"item\"></b></span></div>\n<script>\nconsole.log($('#item').attrd2('id')); // 7\nconsole.log($('#item').attrd2('missing') === undefined); // true\n</script>\n```\n\n### $(selector).autofocus([selector])\n\nType: `method`\n\nVerschiebt den Fokus auf das erste sichtbare Feld innerhalb der Auswahl.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Die zu durchsuchenden Felder. |\n\nReturns: `jQuery` Dieselbe Auswahl.\n\nKann noch kein Feld den Fokus annehmen, versucht es die Methode für kurze Zeit erneut. Auf Mobilgeräten tut sie nichts.\n\nExample: Formular fokussieren\n```html\n<div id=\"form\"><input id=\"code\" type=\"hidden\"><input id=\"name\"></div>\n<script>\n$('#form').autofocus();\nconsole.log(document.activeElement.id); // name\n</script>\n```\n\n### $(selector).binder()\n\nType: `method`\n\nGibt die nächste [ui-bind](../ui-bind/)-Instanz zurück.\n\nReturns: `Object` Die Instanz oder `undefined`, wenn es keine gibt.\n\nDie Suche beginnt beim ersten Element der Auswahl und geht durch seine übergeordneten Elemente.\n\nExample: Binder finden\n```html\n<ui-bind id=\"title\" path=\"common.title\" config=\"text\"></ui-bind>\n<script>\nsetTimeout(function() {\n\tconsole.log($('#title').binder().element[0].tagName); // UI-BIND\n\tconsole.log($('body').binder() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nFührt einen Befehl auf den Komponenten innerhalb der Auswahl aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Befehl, optional gefolgt von Flags. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nNur die Komponenten, die in den ausgewählten Elementen verschachtelt sind, werden erreicht. Komponenten registrieren Befehle mit [command()](../component/), und das globale [CMD()](../globals/) erreicht sie alle. Die Methode gibt nichts zurück.\n\nExample: Ein Befehl in einem Panel\n```html\n<div id=\"left\"><ui-component name=\"list\" id=\"a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"list\" id=\"b\"></ui-component></div>\n<script>\nCOMPONENT('list', function(self) {\n\tself.command('clear', () => console.log('clear', self.element.attr('id')));\n});\nON('ready', function() {\n\t$('#left').CMD('clear'); // clear a\n});\n</script>\n```\n\n### $(selector).component()\n\nType: `method`\n\nGibt die nächste Instanz von [Komponente](../component/) zurück.\n\nReturns: `Component` Die Instanz oder `undefined`, wenn es keine gibt.\n\nDie Suche beginnt beim ersten Element der Auswahl und geht durch seine übergeordneten Elemente.\n\nExample: Komponente finden\n```html\n<ui-component name=\"note\" path=\"common.note\"><b id=\"label\"></b></ui-component>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('#label').component().name); // note\n\tconsole.log($('body').component() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).COMPONENTS()\n\nType: `method`\n\nGibt die bereiten Komponenten innerhalb der Auswahl zurück.\n\nReturns: `Array` Die Instanzen von [Komponente](../component/).\n\nExample: Komponenten auflisten\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\"></ui-component></div>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('body').COMPONENTS().length); // 2\n\tconsole.log($('#left').COMPONENTS()[0].path.toString()); // common.a\n}, 300);\n</script>\n```\n\n### $(selector).EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nFührt eine Funktion, eine Plugin-Methode, ein Event oder einen Setter einer Komponente aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Was ausgeführt werden soll. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nDie Form von `name` bestimmt, was ausgeführt wird:\n\n| Name | Was ausgeführt wird |\n| --- | --- |\n| `myfunction` | Eine globale Funktion |\n| `FUNC.path` | Die Funktion an einem Path |\n| `plugin/method` | Eine Methode eines Plugins |\n| `?/method`, `\\|method` | Eine Methode des nächsten Plugins |\n| `#name` | Das Event `name` |\n| `-component/method` | Ein Setter einer Komponente |\n\nDie Methode gibt nichts zurück.\n\nExample: Funktion ausführen\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = id => out.push('save ' + id);\n});\nFUNC.hello = name => out.push('hello ' + name);\nON('saved', id => out.push('event ' + id));\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.EXEC('FUNC.hello', 'Ana');\n\tbutton.EXEC('orders/save', 1);\n\tbutton.EXEC('?/save', 2);\n\tbutton.EXEC('|save', 3);\n\tbutton.EXEC('#saved', 4);\n\tconsole.log(out); // [\"hello Ana\",\"save 1\",\"save 2\",\"save 3\",\"event 4\"]\n}, 300);\n</script>\n```\n\n### $(selector).hclass(name)\n\nType: `method`\n\nPrüft, ob das Element eine CSS-Klasse hat.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Klassenname. |\n\nReturns: `Boolean` `true`, wenn die Klasse vorhanden ist.\n\nExample: Klasse prüfen\n```js\nvar el = $('<div class=\"active\">');\nconsole.log(el.hclass('active')); // true\nconsole.log(el.hclass('hidden')); // false\n```\n\n### $(selector).multiple(selectors)\n\nType: `method`\n\nFührt mehrere Suchen innerhalb der Auswahl auf einmal aus.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Die Ergebnisschlüssel und ihre Selektoren. |\n\nReturns: `Object` Eine jQuery-Auswahl für jeden Schlüssel.\n\nExample: Elemente finden\n```js\nvar el = $('<div><input><input><button></button></div>');\nvar found = el.multiple({ fields: 'input', submit: 'button' });\nconsole.log(found.fields.length); // 2\nconsole.log(found.submit.length); // 1\n```\n\n### $(selector).plugin()\n\nType: `method`\n\nGibt die nächste [Plugin](../plugin/)-Instanz zurück.\n\nReturns: `Plugin` Die Instanz oder `undefined`, wenn es keine gibt.\n\nDie Suche beginnt beim ersten Element der Auswahl und geht durch seine übergeordneten Elemente.\n\nExample: Plugin finden\n```html\n<ui-plugin path=\"orders\"><b id=\"label\"></b></ui-plugin>\n<script>\nPLUGIN('orders', function(exports) {});\nsetTimeout(function() {\n\tconsole.log($('#label').plugin().name); // orders\n\tconsole.log($('body').plugin() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).psvg(tag)\n\nType: `method`\n\nFügt am Anfang der Auswahl ein SVG-Element ein.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Ein Tag-Name oder SVG-Markup. |\n\nReturns: `jQuery` Das neue Element, wenn `tag` ein Tag-Name ist.\n\nMit einem Tag-Namen erstellt die Methode das Element im SVG-Namespace und gibt es zurück. `tag` kann auch SVG-Markup sein, das am Anfang der Auswahl eingefügt wird.\n\nExample: Am Anfang einfügen\n```js\nvar svg = $('<svg><line></line></svg>');\nvar group = svg.psvg('g');\nsvg.psvg('<path></path>');\nconsole.log(group[0].tagName); // g\nconsole.log(svg.html()); // <path></path><g></g><line></line>\n```\n\n### $(selector).rattr(name)\n\nType: `method`\n\nEntfernt ein Attribut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Attributname. |\n\nReturns: `jQuery` Dieselbe Auswahl.\n\nExample: Attribut entfernen\n```js\nvar el = $('<div title=\"x\" id=\"a\">');\nel.rattr('title');\nconsole.log(el[0].outerHTML); // <div id=\"a\"></div>\n```\n\n### $(selector).rattrd(name, [name2], [...])\n\nType: `method`\n\nEntfernt `data-`-Attribute.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Attributname ohne `data-`. Jedes weitere Argument entfernt ein weiteres Attribut. |\n\nReturns: `jQuery` Dieselbe Auswahl.\n\nExample: Attribute entfernen\n```js\nvar el = $('<div data-a=\"1\" data-b=\"2\" data-c=\"3\">');\nel.rattrd('a', 'b');\nconsole.log(el[0].outerHTML); // <div data-c=\"3\"></div>\n```\n\n### $(selector).rclass([name], [delay])\n\nType: `method`\n\nEntfernt eine CSS-Klasse oder alle Klassen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Der Klassenname. |\n| `delay` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nReturns: `jQuery` Dieselbe Auswahl.\n\nOhne `name` werden alle Klassen entfernt. Mit `delay` wird die Klasse später entfernt, und die verzögerte Änderung funktioniert wie bei `aclass()`.\n\nExample: Klassen entfernen\n```js\nvar el = $('<div class=\"a b c\">');\nel.rclass('a');\nconsole.log(el.attr('class')); // b c\nel.rclass();\nconsole.log(el.attr('class') === ''); // true\n```\n\n### $(selector).rclass2(search, [delay])\n\nType: `method`\n\nEntfernt alle CSS-Klassen, die einen Text enthalten oder zu einem Muster passen.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | Der zu suchende Text oder das zu prüfende Muster. |\n| `delay` | `Number` | no |  | Die Verzögerung in Millisekunden. |\n\nReturns: `jQuery` Dieselbe Auswahl.\n\nMit `delay` werden die Klassen später entfernt, und die verzögerte Änderung funktioniert wie bei `aclass()`.\n\nExample: Nach Text oder Muster entfernen\n```js\nvar el = $('<div class=\"tab-1 tab-2 box\">');\nel.rclass2('tab-');\nconsole.log(el.attr('class')); // box\nvar other = $('<div class=\"tab-1 tab-2 box\">');\nother.rclass2(/1$/);\nconsole.log(other.attr('class')); // tab-2 box\n```\n\n### $(selector).scrollbar()\n\nType: `method`\n\nGibt die nächste benutzerdefinierte Scrollbar zurück, die mit [SCROLLBAR()](../globals/) erstellt wurde.\n\nReturns: `Object` Die Instanz der Scrollbar oder `undefined`, wenn es keine gibt.\n\nDie Suche beginnt beim ersten Element der Auswahl und geht durch seine übergeordneten Elemente.\n\nExample: Scrollbar finden\n```html\n<div id=\"area\" style=\"height:50px\"><p id=\"text\"></p></div>\n<script>\nvar scrollbar = SCROLLBAR($('#area'));\nconsole.log($('#text').scrollbar() === scrollbar); // true\nconsole.log($('body').scrollbar() === undefined); // true\n</script>\n```\n\n### $(selector).SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nFührt eine Funktion aus, wenn sie existiert, und schreibt andernfalls einen Wert an einen Path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Funktion oder der Path. |\n| `a` | `Object` | no |  | Das erste Argument oder der Wert für den Path. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\nEine globale Funktion, `plugin/method` und `?/method` werden mit den Argumenten aufgerufen. Jeder andere Name ist ein Path, an den `a` mit [SET()](../globals/) geschrieben wird. Die Methode gibt nichts zurück.\n\nExample: Funktion oder Path\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = (a, b) => out.push(a + b);\n});\nwindow.hello = name => out.push('hello ' + name);\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.SEEX('hello', 'Ana');\n\tbutton.SEEX('?/save', 1, 2);\n\tbutton.SEEX('common.count', 5);\n\tconsole.log(out); // [\"hello Ana\",3]\n\tconsole.log(GET('common.count')); // 5\n}, 300);\n</script>\n```\n\n### $(selector).SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nRuft eine Methode der Komponenten innerhalb der Auswahl auf.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Die Komponenten und die Methode. |\n| `a` | `Object` | no |  | Das erste Argument. |\n| `b` | `Object` | no |  | Das zweite Argument. |\n| `c` | `Object` | no |  | Das dritte Argument. |\n| `d` | `Object` | no |  | Das vierte Argument. |\n\n`name` ist `component/method`. Anstelle des Komponentennamens wählt `*` alle Komponenten aus und `.path` die an diesen Path gebundenen Komponenten. Die Methode gibt nichts zurück.\n\nExample: Komponenten aufrufen\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\" config=\"label:A\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\" config=\"label:B\"></ui-component></div>\n<script>\nvar out = [];\nCOMPONENT('note', function(self, config) {\n\tself.show = text => out.push(config.label + ' ' + text);\n});\nsetTimeout(function() {\n\t$('#left').SETTER('note/show', 'one');\n\t$('body').SETTER('*/show', 'two');\n\t$('body').SETTER('.common.b/show', 'three');\n\tconsole.log(out); // [\"A one\",\"A two\",\"B two\",\"B three\"]\n}, 300);\n</script>\n```\n\n### $(selector).tclass(name, [enable])\n\nType: `method`\n\nSchaltet eine CSS-Klasse um.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Der Klassenname. |\n| `enable` | `Boolean` | no |  | `true` fügt die Klasse hinzu und `false` entfernt sie. |\n\nReturns: `jQuery` Dieselbe Auswahl.\n\nExample: Umschalten\n```js\nvar el = $('<div>');\nel.tclass('open');\nconsole.log(el.hclass('open')); // true\nel.tclass('open');\nconsole.log(el.hclass('open')); // false\nel.tclass('open', true);\nconsole.log(el.hclass('open')); // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"$(selector).aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"$(selector).asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"$(selector).attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"$(selector).attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"$(selector).autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"$(selector).binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"$(selector).CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"$(selector).component()","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"$(selector).COMPONENTS()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"$(selector).EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"$(selector).hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"$(selector).multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"$(selector).plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"$(selector).psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"$(selector).rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"$(selector).rattrd(name, [name2], [...])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"$(selector).rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"$(selector).rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"scrollbar()","signature":"$(selector).scrollbar()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"$(selector).SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"$(selector).SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"$(selector).tclass(name, [enable])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcUf56o61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/jquery/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"es","title":"Extensiones de jQuery","summary":"Métodos que jComponent añade a jQuery para las clases, los atributos, SVG, la búsqueda de instancias y las llamadas a la biblioteca.","markdown":"---\ntitle: Extensiones de jQuery\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/reference/jquery/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Extensiones de jQuery\n\n> Métodos que jComponent añade a jQuery para las clases, los atributos, SVG, la búsqueda de instancias y las llamadas a la biblioteca.\n\njComponent incluye jQuery y añade estos métodos a todas las selecciones de jQuery. Se usan sobre todo dentro de componentes y plugins: consulta [Crear componentes](../../guides/creating-components/) y [Plugins](../../guides/plugins/).\n\n## API\n\n### $(selector).aclass(name, [delay])\n\nType: `method`\n\nAñade una clase CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la clase. |\n| `delay` | `Number` | no |  | El retardo en milisegundos. |\n\nReturns: `jQuery` La misma selección.\n\nCon `delay`, la clase se añade más tarde. Cada elemento guarda un solo cambio de clase retardado: una nueva llamada retardada de `aclass()`, `rclass()` o `rclass2()` sustituye a la que está en espera.\n\nExample: Añadir una clase\n```js\nvar el = $('<div>');\nel.aclass('active');\nconsole.log(el.attr('class')); // active\n```\n\nExample: Añadir una clase más tarde\n```js\nvar el = $('<div>');\nel.aclass('active', 50);\nconsole.log(el.hclass('active')); // false\nsetTimeout(function() {\n\tconsole.log(el.hclass('active')); // true\n}, 100);\n```\n\n### $(selector).asvg(tag)\n\nType: `method`\n\nAñade un elemento SVG al final.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Un nombre de etiqueta o marcado SVG. |\n\nReturns: `jQuery` El nuevo elemento cuando `tag` es un nombre de etiqueta.\n\nCon un nombre de etiqueta, el método crea el elemento en el espacio de nombres SVG y lo devuelve. `tag` también puede ser marcado SVG, que se añade al final de la selección.\n\nExample: Dibujar\n```js\nvar svg = $('<svg></svg>');\nvar circle = svg.asvg('circle');\ncircle.attr('r', 5);\nsvg.asvg('<rect width=\"5\"></rect>');\nconsole.log(circle[0].namespaceURI); // http://www.w3.org/2000/svg\nconsole.log(svg.html()); // <circle r=\"5\"></circle><rect width=\"5\"></rect>\n```\n\n### $(selector).attrd(name, [value])\n\nType: `method`\n\nLee o escribe un atributo `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del atributo sin `data-`. |\n| `value` | `Object` | no |  | El valor que se va a escribir. |\n\nReturns: `String or jQuery` El valor al leer, o la misma selección al escribir.\n\nExample: Leer y escribir\n```js\nvar el = $('<div data-id=\"7\">');\nconsole.log(el.attrd('id')); // 7\nel.attrd('name', 'box');\nconsole.log(el.attr('data-name')); // box\n```\n\n### $(selector).attrd2(name)\n\nType: `method`\n\nLee un atributo `data-` del elemento o de su padre más cercano que lo tenga.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del atributo sin `data-`. |\n\nReturns: `String` El valor, o `undefined` cuando ningún elemento tiene el atributo.\n\nLa búsqueda termina en `<body>`.\n\nExample: Buscar en los padres\n```html\n<div data-id=\"7\"><span><b id=\"item\"></b></span></div>\n<script>\nconsole.log($('#item').attrd2('id')); // 7\nconsole.log($('#item').attrd2('missing') === undefined); // true\n</script>\n```\n\n### $(selector).autofocus([selector])\n\nType: `method`\n\nMueve el foco al primer campo visible que hay dentro de la selección.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Los campos que se buscan. |\n\nReturns: `jQuery` La misma selección.\n\nEl método vuelve a intentarlo durante un breve tiempo cuando ningún campo puede recibir el foco todavía. En los dispositivos móviles no hace nada.\n\nExample: Enfocar un formulario\n```html\n<div id=\"form\"><input id=\"code\" type=\"hidden\"><input id=\"name\"></div>\n<script>\n$('#form').autofocus();\nconsole.log(document.activeElement.id); // name\n</script>\n```\n\n### $(selector).binder()\n\nType: `method`\n\nDevuelve la instancia de [ui-bind](../ui-bind/) más cercana.\n\nReturns: `Object` La instancia, o `undefined` cuando no hay ninguna.\n\nLa búsqueda empieza en el primer elemento de la selección y recorre sus padres.\n\nExample: Buscar el binder\n```html\n<ui-bind id=\"title\" path=\"common.title\" config=\"text\"></ui-bind>\n<script>\nsetTimeout(function() {\n\tconsole.log($('#title').binder().element[0].tagName); // UI-BIND\n\tconsole.log($('body').binder() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nEjecuta un comando en los componentes que hay dentro de la selección.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El comando, opcionalmente seguido de flags. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nSolo llega a los componentes anidados en los elementos seleccionados. Los componentes registran comandos con [command()](../component/), y la función global [CMD()](../globals/) llega a todos ellos. El método no devuelve nada.\n\nExample: Un comando en un panel\n```html\n<div id=\"left\"><ui-component name=\"list\" id=\"a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"list\" id=\"b\"></ui-component></div>\n<script>\nCOMPONENT('list', function(self) {\n\tself.command('clear', () => console.log('clear', self.element.attr('id')));\n});\nON('ready', function() {\n\t$('#left').CMD('clear'); // clear a\n});\n</script>\n```\n\n### $(selector).component()\n\nType: `method`\n\nDevuelve la instancia de [Component](../component/) más cercana.\n\nReturns: `Component` La instancia, o `undefined` cuando no hay ninguna.\n\nLa búsqueda empieza en el primer elemento de la selección y recorre sus padres.\n\nExample: Buscar el componente\n```html\n<ui-component name=\"note\" path=\"common.note\"><b id=\"label\"></b></ui-component>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('#label').component().name); // note\n\tconsole.log($('body').component() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).COMPONENTS()\n\nType: `method`\n\nDevuelve los componentes listos que hay dentro de la selección.\n\nReturns: `Array` Las instancias de [Component](../component/).\n\nExample: Listar los componentes\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\"></ui-component></div>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('body').COMPONENTS().length); // 2\n\tconsole.log($('#left').COMPONENTS()[0].path.toString()); // common.a\n}, 300);\n</script>\n```\n\n### $(selector).EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nEjecuta una función, un método de un plugin, un evento o un setter de un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Lo que se ejecuta. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nLa forma de `name` determina qué se ejecuta:\n\n| Nombre | Qué se ejecuta |\n| --- | --- |\n| `myfunction` | Una función global |\n| `FUNC.path` | La función de un path |\n| `plugin/method` | Un método de un plugin |\n| `?/method`, `\\|method` | Un método del plugin más cercano |\n| `#name` | El evento `name` |\n| `-component/method` | Un setter de un componente |\n\nEl método no devuelve nada.\n\nExample: Ejecutar una función\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = id => out.push('save ' + id);\n});\nFUNC.hello = name => out.push('hello ' + name);\nON('saved', id => out.push('event ' + id));\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.EXEC('FUNC.hello', 'Ana');\n\tbutton.EXEC('orders/save', 1);\n\tbutton.EXEC('?/save', 2);\n\tbutton.EXEC('|save', 3);\n\tbutton.EXEC('#saved', 4);\n\tconsole.log(out); // [\"hello Ana\",\"save 1\",\"save 2\",\"save 3\",\"event 4\"]\n}, 300);\n</script>\n```\n\n### $(selector).hclass(name)\n\nType: `method`\n\nComprueba si el elemento tiene una clase CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la clase. |\n\nReturns: `Boolean` `true` cuando la clase está presente.\n\nExample: Comprobar una clase\n```js\nvar el = $('<div class=\"active\">');\nconsole.log(el.hclass('active')); // true\nconsole.log(el.hclass('hidden')); // false\n```\n\n### $(selector).multiple(selectors)\n\nType: `method`\n\nEjecuta varias búsquedas a la vez dentro de la selección.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Las claves del resultado y sus selectores. |\n\nReturns: `Object` Una selección de jQuery por cada clave.\n\nExample: Buscar elementos\n```js\nvar el = $('<div><input><input><button></button></div>');\nvar found = el.multiple({ fields: 'input', submit: 'button' });\nconsole.log(found.fields.length); // 2\nconsole.log(found.submit.length); // 1\n```\n\n### $(selector).plugin()\n\nType: `method`\n\nDevuelve la instancia de [Plugin](../plugin/) más cercana.\n\nReturns: `Plugin` La instancia, o `undefined` cuando no hay ninguna.\n\nLa búsqueda empieza en el primer elemento de la selección y recorre sus padres.\n\nExample: Buscar el plugin\n```html\n<ui-plugin path=\"orders\"><b id=\"label\"></b></ui-plugin>\n<script>\nPLUGIN('orders', function(exports) {});\nsetTimeout(function() {\n\tconsole.log($('#label').plugin().name); // orders\n\tconsole.log($('body').plugin() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).psvg(tag)\n\nType: `method`\n\nInserta un elemento SVG al inicio de la selección.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Un nombre de etiqueta o marcado SVG. |\n\nReturns: `jQuery` El nuevo elemento cuando `tag` es un nombre de etiqueta.\n\nCon un nombre de etiqueta, el método crea el elemento en el espacio de nombres SVG y lo devuelve. `tag` también puede ser marcado SVG, que se inserta al inicio de la selección.\n\nExample: Insertar al principio\n```js\nvar svg = $('<svg><line></line></svg>');\nvar group = svg.psvg('g');\nsvg.psvg('<path></path>');\nconsole.log(group[0].tagName); // g\nconsole.log(svg.html()); // <path></path><g></g><line></line>\n```\n\n### $(selector).rattr(name)\n\nType: `method`\n\nElimina un atributo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del atributo. |\n\nReturns: `jQuery` La misma selección.\n\nExample: Eliminar un atributo\n```js\nvar el = $('<div title=\"x\" id=\"a\">');\nel.rattr('title');\nconsole.log(el[0].outerHTML); // <div id=\"a\"></div>\n```\n\n### $(selector).rattrd(name, [name2], [...])\n\nType: `method`\n\nElimina atributos `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre del atributo sin `data-`. Cada argumento adicional elimina otro atributo. |\n\nReturns: `jQuery` La misma selección.\n\nExample: Eliminar atributos\n```js\nvar el = $('<div data-a=\"1\" data-b=\"2\" data-c=\"3\">');\nel.rattrd('a', 'b');\nconsole.log(el[0].outerHTML); // <div data-c=\"3\"></div>\n```\n\n### $(selector).rclass([name], [delay])\n\nType: `method`\n\nQuita una clase CSS, o todas.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | El nombre de la clase. |\n| `delay` | `Number` | no |  | El retardo en milisegundos. |\n\nReturns: `jQuery` La misma selección.\n\nSin `name`, se quitan todas las clases. Con `delay`, la clase se quita más tarde, y el cambio retardado funciona como en `aclass()`.\n\nExample: Quitar clases\n```js\nvar el = $('<div class=\"a b c\">');\nel.rclass('a');\nconsole.log(el.attr('class')); // b c\nel.rclass();\nconsole.log(el.attr('class') === ''); // true\n```\n\n### $(selector).rclass2(search, [delay])\n\nType: `method`\n\nQuita todas las clases CSS que contienen un texto o coinciden con un patrón.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | El texto que se busca o el patrón que se comprueba. |\n| `delay` | `Number` | no |  | El retardo en milisegundos. |\n\nReturns: `jQuery` La misma selección.\n\nCon `delay`, las clases se quitan más tarde, y el cambio retardado funciona como en `aclass()`.\n\nExample: Quitar por texto o patrón\n```js\nvar el = $('<div class=\"tab-1 tab-2 box\">');\nel.rclass2('tab-');\nconsole.log(el.attr('class')); // box\nvar other = $('<div class=\"tab-1 tab-2 box\">');\nother.rclass2(/1$/);\nconsole.log(other.attr('class')); // tab-2 box\n```\n\n### $(selector).scrollbar()\n\nType: `method`\n\nDevuelve la barra de desplazamiento personalizada más cercana creada con [SCROLLBAR()](../globals/).\n\nReturns: `Object` La instancia de la barra de desplazamiento, o `undefined` cuando no hay ninguna.\n\nLa búsqueda empieza en el primer elemento de la selección y recorre sus padres.\n\nExample: Buscar la barra de desplazamiento\n```html\n<div id=\"area\" style=\"height:50px\"><p id=\"text\"></p></div>\n<script>\nvar scrollbar = SCROLLBAR($('#area'));\nconsole.log($('#text').scrollbar() === scrollbar); // true\nconsole.log($('body').scrollbar() === undefined); // true\n</script>\n```\n\n### $(selector).SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nEjecuta una función cuando existe; en caso contrario, escribe un valor en un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La función o el path. |\n| `a` | `Object` | no |  | El primer argumento o el valor para el path. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\nUna función global, `plugin/method` y `?/method` se llaman con los argumentos. Cualquier otro nombre es un path, y `a` se escribe en él con [SET()](../globals/). El método no devuelve nada.\n\nExample: Función o path\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = (a, b) => out.push(a + b);\n});\nwindow.hello = name => out.push('hello ' + name);\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.SEEX('hello', 'Ana');\n\tbutton.SEEX('?/save', 1, 2);\n\tbutton.SEEX('common.count', 5);\n\tconsole.log(out); // [\"hello Ana\",3]\n\tconsole.log(GET('common.count')); // 5\n}, 300);\n</script>\n```\n\n### $(selector).SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nLlama a un método de los componentes que hay dentro de la selección.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Los componentes y el método. |\n| `a` | `Object` | no |  | El primer argumento. |\n| `b` | `Object` | no |  | El segundo argumento. |\n| `c` | `Object` | no |  | El tercer argumento. |\n| `d` | `Object` | no |  | El cuarto argumento. |\n\n`name` es `component/method`. En lugar del nombre del componente, `*` selecciona todos los componentes y `.path` selecciona los componentes enlazados a ese path. El método no devuelve nada.\n\nExample: Llamar a los componentes\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\" config=\"label:A\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\" config=\"label:B\"></ui-component></div>\n<script>\nvar out = [];\nCOMPONENT('note', function(self, config) {\n\tself.show = text => out.push(config.label + ' ' + text);\n});\nsetTimeout(function() {\n\t$('#left').SETTER('note/show', 'one');\n\t$('body').SETTER('*/show', 'two');\n\t$('body').SETTER('.common.b/show', 'three');\n\tconsole.log(out); // [\"A one\",\"A two\",\"B two\",\"B three\"]\n}, 300);\n</script>\n```\n\n### $(selector).tclass(name, [enable])\n\nType: `method`\n\nAlterna una clase CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | El nombre de la clase. |\n| `enable` | `Boolean` | no |  | `true` añade la clase y `false` la quita. |\n\nReturns: `jQuery` La misma selección.\n\nExample: Alternar\n```js\nvar el = $('<div>');\nel.tclass('open');\nconsole.log(el.hclass('open')); // true\nel.tclass('open');\nconsole.log(el.hclass('open')); // false\nel.tclass('open', true);\nconsole.log(el.hclass('open')); // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"$(selector).aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"$(selector).asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"$(selector).attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"$(selector).attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"$(selector).autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"$(selector).binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"$(selector).CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"$(selector).component()","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"$(selector).COMPONENTS()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"$(selector).EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"$(selector).hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"$(selector).multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"$(selector).plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"$(selector).psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"$(selector).rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"$(selector).rattrd(name, [name2], [...])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"$(selector).rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"$(selector).rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"scrollbar()","signature":"$(selector).scrollbar()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"$(selector).SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"$(selector).SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"$(selector).tclass(name, [enable])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcUf56o61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/jquery/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"fr","title":"Extensions jQuery","summary":"Les méthodes que jComponent ajoute à jQuery pour les classes, les attributs, le SVG, la recherche d'instances et les appels à la bibliothèque.","markdown":"---\ntitle: Extensions jQuery\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/reference/jquery/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Extensions jQuery\n\n> Les méthodes que jComponent ajoute à jQuery pour les classes, les attributs, le SVG, la recherche d'instances et les appels à la bibliothèque.\n\njComponent inclut jQuery et ajoute ces méthodes à chaque sélection jQuery. Elles servent surtout dans les composants et les plugins : voir [Créer des composants](../../guides/creating-components/) et [Plugins](../../guides/plugins/).\n\n## API\n\n### $(selector).aclass(name, [delay])\n\nType: `method`\n\nAjoute une classe CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la classe. |\n| `delay` | `Number` | no |  | Le délai en millisecondes. |\n\nReturns: `jQuery` La même sélection.\n\nAvec `delay`, la classe est ajoutée plus tard. Chaque élément conserve une seule modification de classe différée : un nouvel appel différé de `aclass()`, `rclass()` ou `rclass2()` remplace celui qui est en attente.\n\nExample: Ajouter une classe\n```js\nvar el = $('<div>');\nel.aclass('active');\nconsole.log(el.attr('class')); // active\n```\n\nExample: Ajouter une classe plus tard\n```js\nvar el = $('<div>');\nel.aclass('active', 50);\nconsole.log(el.hclass('active')); // false\nsetTimeout(function() {\n\tconsole.log(el.hclass('active')); // true\n}, 100);\n```\n\n### $(selector).asvg(tag)\n\nType: `method`\n\nAjoute un élément SVG à la fin.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Un nom de balise ou du balisage SVG. |\n\nReturns: `jQuery` Le nouvel élément quand `tag` est un nom de balise.\n\nAvec un nom de balise, la méthode crée l'élément dans l'espace de noms SVG et le renvoie. `tag` peut aussi être du balisage SVG, ajouté à la fin de la sélection.\n\nExample: Dessiner\n```js\nvar svg = $('<svg></svg>');\nvar circle = svg.asvg('circle');\ncircle.attr('r', 5);\nsvg.asvg('<rect width=\"5\"></rect>');\nconsole.log(circle[0].namespaceURI); // http://www.w3.org/2000/svg\nconsole.log(svg.html()); // <circle r=\"5\"></circle><rect width=\"5\"></rect>\n```\n\n### $(selector).attrd(name, [value])\n\nType: `method`\n\nLit ou écrit un attribut `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'attribut sans `data-`. |\n| `value` | `Object` | no |  | La valeur à écrire. |\n\nReturns: `String or jQuery` La valeur en lecture, ou la même sélection en écriture.\n\nExample: Lire et écrire\n```js\nvar el = $('<div data-id=\"7\">');\nconsole.log(el.attrd('id')); // 7\nel.attrd('name', 'box');\nconsole.log(el.attr('data-name')); // box\n```\n\n### $(selector).attrd2(name)\n\nType: `method`\n\nLit un attribut `data-` sur l'élément ou sur son parent le plus proche qui le possède.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'attribut sans `data-`. |\n\nReturns: `String` La valeur, ou `undefined` quand aucun élément ne possède l'attribut.\n\nLa recherche s'arrête à `<body>`.\n\nExample: Chercher dans les parents\n```html\n<div data-id=\"7\"><span><b id=\"item\"></b></span></div>\n<script>\nconsole.log($('#item').attrd2('id')); // 7\nconsole.log($('#item').attrd2('missing') === undefined); // true\n</script>\n```\n\n### $(selector).autofocus([selector])\n\nType: `method`\n\nDéplace le focus vers le premier champ visible de la sélection.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Les champs à rechercher. |\n\nReturns: `jQuery` La même sélection.\n\nLa méthode réessaie pendant un court instant quand aucun champ ne peut encore recevoir le focus. Elle ne fait rien sur les appareils mobiles.\n\nExample: Donner le focus à un formulaire\n```html\n<div id=\"form\"><input id=\"code\" type=\"hidden\"><input id=\"name\"></div>\n<script>\n$('#form').autofocus();\nconsole.log(document.activeElement.id); // name\n</script>\n```\n\n### $(selector).binder()\n\nType: `method`\n\nRenvoie l'instance [ui-bind](../ui-bind/) la plus proche.\n\nReturns: `Object` L'instance, ou `undefined` s'il n'y en a pas.\n\nLa recherche commence au premier élément de la sélection et remonte ses parents.\n\nExample: Trouver le binder\n```html\n<ui-bind id=\"title\" path=\"common.title\" config=\"text\"></ui-bind>\n<script>\nsetTimeout(function() {\n\tconsole.log($('#title').binder().element[0].tagName); // UI-BIND\n\tconsole.log($('body').binder() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nExécute une commande sur les composants situés dans la sélection.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La commande, éventuellement suivie de flags. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nSeuls les composants imbriqués dans les éléments sélectionnés sont atteints. Les composants enregistrent des commandes avec [command()](../component/), et la fonction globale [CMD()](../globals/) les atteint tous. La méthode ne renvoie rien.\n\nExample: Une commande dans un seul panneau\n```html\n<div id=\"left\"><ui-component name=\"list\" id=\"a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"list\" id=\"b\"></ui-component></div>\n<script>\nCOMPONENT('list', function(self) {\n\tself.command('clear', () => console.log('clear', self.element.attr('id')));\n});\nON('ready', function() {\n\t$('#left').CMD('clear'); // clear a\n});\n</script>\n```\n\n### $(selector).component()\n\nType: `method`\n\nRenvoie l'instance [Component](../component/) la plus proche.\n\nReturns: `Component` L'instance, ou `undefined` s'il n'y en a pas.\n\nLa recherche commence au premier élément de la sélection et remonte ses parents.\n\nExample: Trouver le composant\n```html\n<ui-component name=\"note\" path=\"common.note\"><b id=\"label\"></b></ui-component>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('#label').component().name); // note\n\tconsole.log($('body').component() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).COMPONENTS()\n\nType: `method`\n\nRenvoie les composants prêts situés dans la sélection.\n\nReturns: `Array` Les instances [Component](../component/).\n\nExample: Lister les composants\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\"></ui-component></div>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('body').COMPONENTS().length); // 2\n\tconsole.log($('#left').COMPONENTS()[0].path.toString()); // common.a\n}, 300);\n</script>\n```\n\n### $(selector).EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nExécute une fonction, une méthode de plugin, un événement ou un setter de composant.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Ce qu'il faut exécuter. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nLa forme de `name` détermine ce qui s'exécute :\n\n| Nom | Ce qui s'exécute |\n| --- | --- |\n| `myfunction` | Une fonction globale |\n| `FUNC.path` | La fonction située à un path |\n| `plugin/method` | Une méthode d'un plugin |\n| `?/method`, `\\|method` | Une méthode du plugin le plus proche |\n| `#name` | L'événement `name` |\n| `-component/method` | Un setter de composant |\n\nLa méthode ne renvoie rien.\n\nExample: Exécuter une fonction\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = id => out.push('save ' + id);\n});\nFUNC.hello = name => out.push('hello ' + name);\nON('saved', id => out.push('event ' + id));\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.EXEC('FUNC.hello', 'Ana');\n\tbutton.EXEC('orders/save', 1);\n\tbutton.EXEC('?/save', 2);\n\tbutton.EXEC('|save', 3);\n\tbutton.EXEC('#saved', 4);\n\tconsole.log(out); // [\"hello Ana\",\"save 1\",\"save 2\",\"save 3\",\"event 4\"]\n}, 300);\n</script>\n```\n\n### $(selector).hclass(name)\n\nType: `method`\n\nVérifie si l'élément possède une classe CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la classe. |\n\nReturns: `Boolean` `true` quand la classe est présente.\n\nExample: Vérifier une classe\n```js\nvar el = $('<div class=\"active\">');\nconsole.log(el.hclass('active')); // true\nconsole.log(el.hclass('hidden')); // false\n```\n\n### $(selector).multiple(selectors)\n\nType: `method`\n\nEffectue plusieurs recherches à la fois dans la sélection.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Les clés du résultat et leurs sélecteurs. |\n\nReturns: `Object` Une sélection jQuery pour chaque clé.\n\nExample: Trouver des éléments\n```js\nvar el = $('<div><input><input><button></button></div>');\nvar found = el.multiple({ fields: 'input', submit: 'button' });\nconsole.log(found.fields.length); // 2\nconsole.log(found.submit.length); // 1\n```\n\n### $(selector).plugin()\n\nType: `method`\n\nRenvoie l'instance [Plugin](../plugin/) la plus proche.\n\nReturns: `Plugin` L'instance, ou `undefined` s'il n'y en a pas.\n\nLa recherche commence au premier élément de la sélection et remonte ses parents.\n\nExample: Trouver le plugin\n```html\n<ui-plugin path=\"orders\"><b id=\"label\"></b></ui-plugin>\n<script>\nPLUGIN('orders', function(exports) {});\nsetTimeout(function() {\n\tconsole.log($('#label').plugin().name); // orders\n\tconsole.log($('body').plugin() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).psvg(tag)\n\nType: `method`\n\nInsère un élément SVG au début de la sélection.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Un nom de balise ou du balisage SVG. |\n\nReturns: `jQuery` Le nouvel élément quand `tag` est un nom de balise.\n\nAvec un nom de balise, la méthode crée l'élément dans l'espace de noms SVG et le renvoie. `tag` peut aussi être du balisage SVG, inséré au début de la sélection.\n\nExample: Insérer en premier\n```js\nvar svg = $('<svg><line></line></svg>');\nvar group = svg.psvg('g');\nsvg.psvg('<path></path>');\nconsole.log(group[0].tagName); // g\nconsole.log(svg.html()); // <path></path><g></g><line></line>\n```\n\n### $(selector).rattr(name)\n\nType: `method`\n\nRetire un attribut.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'attribut. |\n\nReturns: `jQuery` La même sélection.\n\nExample: Retirer un attribut\n```js\nvar el = $('<div title=\"x\" id=\"a\">');\nel.rattr('title');\nconsole.log(el[0].outerHTML); // <div id=\"a\"></div>\n```\n\n### $(selector).rattrd(name, [name2], [...])\n\nType: `method`\n\nRetire des attributs `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de l'attribut sans `data-`. Chaque argument suivant retire un attribut de plus. |\n\nReturns: `jQuery` La même sélection.\n\nExample: Retirer des attributs\n```js\nvar el = $('<div data-a=\"1\" data-b=\"2\" data-c=\"3\">');\nel.rattrd('a', 'b');\nconsole.log(el[0].outerHTML); // <div data-c=\"3\"></div>\n```\n\n### $(selector).rclass([name], [delay])\n\nType: `method`\n\nRetire une classe CSS, ou toutes les classes.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Le nom de la classe. |\n| `delay` | `Number` | no |  | Le délai en millisecondes. |\n\nReturns: `jQuery` La même sélection.\n\nSans `name`, toutes les classes sont retirées. Avec `delay`, la classe est retirée plus tard, et la modification différée fonctionne comme dans `aclass()`.\n\nExample: Retirer des classes\n```js\nvar el = $('<div class=\"a b c\">');\nel.rclass('a');\nconsole.log(el.attr('class')); // b c\nel.rclass();\nconsole.log(el.attr('class') === ''); // true\n```\n\n### $(selector).rclass2(search, [delay])\n\nType: `method`\n\nRetire toutes les classes CSS qui contiennent un texte ou correspondent à un motif.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | Le texte à trouver ou le motif à tester. |\n| `delay` | `Number` | no |  | Le délai en millisecondes. |\n\nReturns: `jQuery` La même sélection.\n\nAvec `delay`, les classes sont retirées plus tard, et la modification différée fonctionne comme dans `aclass()`.\n\nExample: Retirer par texte ou par motif\n```js\nvar el = $('<div class=\"tab-1 tab-2 box\">');\nel.rclass2('tab-');\nconsole.log(el.attr('class')); // box\nvar other = $('<div class=\"tab-1 tab-2 box\">');\nother.rclass2(/1$/);\nconsole.log(other.attr('class')); // tab-2 box\n```\n\n### $(selector).scrollbar()\n\nType: `method`\n\nRenvoie la barre de défilement personnalisée la plus proche, créée avec [SCROLLBAR()](../globals/).\n\nReturns: `Object` L'instance de la barre de défilement, ou `undefined` s'il n'y en a pas.\n\nLa recherche commence au premier élément de la sélection et remonte ses parents.\n\nExample: Trouver la barre de défilement\n```html\n<div id=\"area\" style=\"height:50px\"><p id=\"text\"></p></div>\n<script>\nvar scrollbar = SCROLLBAR($('#area'));\nconsole.log($('#text').scrollbar() === scrollbar); // true\nconsole.log($('body').scrollbar() === undefined); // true\n</script>\n```\n\n### $(selector).SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nExécute une fonction si elle existe, sinon écrit une valeur dans un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La fonction ou le path. |\n| `a` | `Object` | no |  | Le premier argument, ou la valeur du path. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\nUne fonction globale, `plugin/method` et `?/method` sont appelés avec les arguments. Tout autre nom est un path, dans lequel `a` est écrit avec [SET()](../globals/). La méthode ne renvoie rien.\n\nExample: Fonction ou path\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = (a, b) => out.push(a + b);\n});\nwindow.hello = name => out.push('hello ' + name);\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.SEEX('hello', 'Ana');\n\tbutton.SEEX('?/save', 1, 2);\n\tbutton.SEEX('common.count', 5);\n\tconsole.log(out); // [\"hello Ana\",3]\n\tconsole.log(GET('common.count')); // 5\n}, 300);\n</script>\n```\n\n### $(selector).SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nAppelle une méthode des composants situés dans la sélection.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Les composants et la méthode. |\n| `a` | `Object` | no |  | Le premier argument. |\n| `b` | `Object` | no |  | Le deuxième argument. |\n| `c` | `Object` | no |  | Le troisième argument. |\n| `d` | `Object` | no |  | Le quatrième argument. |\n\n`name` a la forme `component/method`. À la place du nom du composant, `*` sélectionne tous les composants et `.path` sélectionne les composants liés à ce path. La méthode ne renvoie rien.\n\nExample: Appeler des composants\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\" config=\"label:A\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\" config=\"label:B\"></ui-component></div>\n<script>\nvar out = [];\nCOMPONENT('note', function(self, config) {\n\tself.show = text => out.push(config.label + ' ' + text);\n});\nsetTimeout(function() {\n\t$('#left').SETTER('note/show', 'one');\n\t$('body').SETTER('*/show', 'two');\n\t$('body').SETTER('.common.b/show', 'three');\n\tconsole.log(out); // [\"A one\",\"A two\",\"B two\",\"B three\"]\n}, 300);\n</script>\n```\n\n### $(selector).tclass(name, [enable])\n\nType: `method`\n\nBascule une classe CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Le nom de la classe. |\n| `enable` | `Boolean` | no |  | `true` ajoute la classe et `false` la retire. |\n\nReturns: `jQuery` La même sélection.\n\nExample: Basculer\n```js\nvar el = $('<div>');\nel.tclass('open');\nconsole.log(el.hclass('open')); // true\nel.tclass('open');\nconsole.log(el.hclass('open')); // false\nel.tclass('open', true);\nconsole.log(el.hclass('open')); // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"$(selector).aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"$(selector).asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"$(selector).attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"$(selector).attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"$(selector).autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"$(selector).binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"$(selector).CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"$(selector).component()","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"$(selector).COMPONENTS()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"$(selector).EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"$(selector).hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"$(selector).multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"$(selector).plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"$(selector).psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"$(selector).rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"$(selector).rattrd(name, [name2], [...])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"$(selector).rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"$(selector).rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"scrollbar()","signature":"$(selector).scrollbar()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"$(selector).SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"$(selector).SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"$(selector).tclass(name, [enable])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcUf56o61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/jquery/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"it","title":"Estensioni di jQuery","summary":"I metodi che jComponent aggiunge a jQuery per classi, attributi, SVG, ricerca delle istanze e chiamate alla libreria.","markdown":"---\ntitle: Estensioni di jQuery\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/reference/jquery/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Estensioni di jQuery\n\n> I metodi che jComponent aggiunge a jQuery per classi, attributi, SVG, ricerca delle istanze e chiamate alla libreria.\n\njComponent include jQuery e aggiunge questi metodi a ogni selezione jQuery. Si usano soprattutto all'interno di componenti e plugin: vedi [Creare componenti](../../guides/creating-components/) e [Plugin](../../guides/plugins/).\n\n## API\n\n### $(selector).aclass(name, [delay])\n\nType: `method`\n\nAggiunge una classe CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome della classe. |\n| `delay` | `Number` | no |  | Il ritardo in millisecondi. |\n\nReturns: `jQuery` La stessa selezione.\n\nCon `delay`, la classe viene aggiunta in seguito. Ogni elemento conserva una sola modifica di classe ritardata: una nuova chiamata ritardata di `aclass()`, `rclass()` o `rclass2()` sostituisce quella in attesa.\n\nExample: Aggiungere una classe\n```js\nvar el = $('<div>');\nel.aclass('active');\nconsole.log(el.attr('class')); // active\n```\n\nExample: Aggiungere una classe in seguito\n```js\nvar el = $('<div>');\nel.aclass('active', 50);\nconsole.log(el.hclass('active')); // false\nsetTimeout(function() {\n\tconsole.log(el.hclass('active')); // true\n}, 100);\n```\n\n### $(selector).asvg(tag)\n\nType: `method`\n\nAggiunge un elemento SVG.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Il nome di un tag o markup SVG. |\n\nReturns: `jQuery` Il nuovo elemento, quando `tag` è il nome di un tag.\n\nCon il nome di un tag, il metodo crea l'elemento nel namespace SVG e lo restituisce. `tag` può essere anche markup SVG, che viene aggiunto alla selezione.\n\nExample: Disegnare\n```js\nvar svg = $('<svg></svg>');\nvar circle = svg.asvg('circle');\ncircle.attr('r', 5);\nsvg.asvg('<rect width=\"5\"></rect>');\nconsole.log(circle[0].namespaceURI); // http://www.w3.org/2000/svg\nconsole.log(svg.html()); // <circle r=\"5\"></circle><rect width=\"5\"></rect>\n```\n\n### $(selector).attrd(name, [value])\n\nType: `method`\n\nLegge o scrive un attributo `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'attributo senza `data-`. |\n| `value` | `Object` | no |  | Il valore da scrivere. |\n\nReturns: `String or jQuery` Il valore in lettura, oppure la stessa selezione in scrittura.\n\nExample: Leggere e scrivere\n```js\nvar el = $('<div data-id=\"7\">');\nconsole.log(el.attrd('id')); // 7\nel.attrd('name', 'box');\nconsole.log(el.attr('data-name')); // box\n```\n\n### $(selector).attrd2(name)\n\nType: `method`\n\nLegge un attributo `data-` dall'elemento o dal genitore più vicino che lo possiede.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'attributo senza `data-`. |\n\nReturns: `String` Il valore, oppure `undefined` quando nessun elemento ha l'attributo.\n\nLa ricerca termina in `<body>`.\n\nExample: Cercare tra i genitori\n```html\n<div data-id=\"7\"><span><b id=\"item\"></b></span></div>\n<script>\nconsole.log($('#item').attrd2('id')); // 7\nconsole.log($('#item').attrd2('missing') === undefined); // true\n</script>\n```\n\n### $(selector).autofocus([selector])\n\nType: `method`\n\nSposta il focus sul primo campo visibile all'interno della selezione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | I campi da cercare. |\n\nReturns: `jQuery` La stessa selezione.\n\nIl metodo riprova per un breve periodo quando nessun campo può ancora ricevere il focus. Sui dispositivi mobili non fa nulla.\n\nExample: Dare il focus a un modulo\n```html\n<div id=\"form\"><input id=\"code\" type=\"hidden\"><input id=\"name\"></div>\n<script>\n$('#form').autofocus();\nconsole.log(document.activeElement.id); // name\n</script>\n```\n\n### $(selector).binder()\n\nType: `method`\n\nRestituisce l'istanza di [ui-bind](../ui-bind/) più vicina.\n\nReturns: `Object` L'istanza, oppure `undefined` quando non ce n'è nessuna.\n\nLa ricerca parte dal primo elemento della selezione e risale attraverso i suoi genitori.\n\nExample: Trovare il binder\n```html\n<ui-bind id=\"title\" path=\"common.title\" config=\"text\"></ui-bind>\n<script>\nsetTimeout(function() {\n\tconsole.log($('#title').binder().element[0].tagName); // UI-BIND\n\tconsole.log($('body').binder() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nEsegue un comando sui componenti all'interno della selezione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il comando, eventualmente seguito da flag. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nVengono raggiunti solo i componenti annidati negli elementi selezionati. I componenti registrano i comandi con [command()](../component/) e la funzione globale [CMD()](../globals/) li raggiunge tutti. Il metodo non restituisce nulla.\n\nExample: Un comando in un solo pannello\n```html\n<div id=\"left\"><ui-component name=\"list\" id=\"a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"list\" id=\"b\"></ui-component></div>\n<script>\nCOMPONENT('list', function(self) {\n\tself.command('clear', () => console.log('clear', self.element.attr('id')));\n});\nON('ready', function() {\n\t$('#left').CMD('clear'); // clear a\n});\n</script>\n```\n\n### $(selector).component()\n\nType: `method`\n\nRestituisce l'istanza di [Componente](../component/) più vicina.\n\nReturns: `Component` L'istanza, oppure `undefined` quando non ce n'è nessuna.\n\nLa ricerca parte dal primo elemento della selezione e risale attraverso i suoi genitori.\n\nExample: Trovare il componente\n```html\n<ui-component name=\"note\" path=\"common.note\"><b id=\"label\"></b></ui-component>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('#label').component().name); // note\n\tconsole.log($('body').component() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).COMPONENTS()\n\nType: `method`\n\nRestituisce i componenti pronti all'interno della selezione.\n\nReturns: `Array` Le istanze di [Componente](../component/).\n\nExample: Elencare i componenti\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\"></ui-component></div>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('body').COMPONENTS().length); // 2\n\tconsole.log($('#left').COMPONENTS()[0].path.toString()); // common.a\n}, 300);\n</script>\n```\n\n### $(selector).EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nEsegue una funzione, un metodo di un plugin, un evento o un setter di un componente.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Che cosa eseguire. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nLa forma di `name` stabilisce che cosa viene eseguito:\n\n| Nome | Che cosa viene eseguito |\n| --- | --- |\n| `myfunction` | Una funzione globale |\n| `FUNC.path` | La funzione in un path |\n| `plugin/method` | Un metodo di un plugin |\n| `?/method`, `\\|method` | Un metodo del plugin più vicino |\n| `#name` | L'evento `name` |\n| `-component/method` | Un setter di un componente |\n\nIl metodo non restituisce nulla.\n\nExample: Eseguire una funzione\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = id => out.push('save ' + id);\n});\nFUNC.hello = name => out.push('hello ' + name);\nON('saved', id => out.push('event ' + id));\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.EXEC('FUNC.hello', 'Ana');\n\tbutton.EXEC('orders/save', 1);\n\tbutton.EXEC('?/save', 2);\n\tbutton.EXEC('|save', 3);\n\tbutton.EXEC('#saved', 4);\n\tconsole.log(out); // [\"hello Ana\",\"save 1\",\"save 2\",\"save 3\",\"event 4\"]\n}, 300);\n</script>\n```\n\n### $(selector).hclass(name)\n\nType: `method`\n\nControlla se l'elemento ha una classe CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome della classe. |\n\nReturns: `Boolean` `true` quando la classe è presente.\n\nExample: Controllare una classe\n```js\nvar el = $('<div class=\"active\">');\nconsole.log(el.hclass('active')); // true\nconsole.log(el.hclass('hidden')); // false\n```\n\n### $(selector).multiple(selectors)\n\nType: `method`\n\nEsegue più ricerche contemporaneamente all'interno della selezione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Le chiavi del risultato e i relativi selettori. |\n\nReturns: `Object` Una selezione jQuery per ogni chiave.\n\nExample: Trovare gli elementi\n```js\nvar el = $('<div><input><input><button></button></div>');\nvar found = el.multiple({ fields: 'input', submit: 'button' });\nconsole.log(found.fields.length); // 2\nconsole.log(found.submit.length); // 1\n```\n\n### $(selector).plugin()\n\nType: `method`\n\nRestituisce l'istanza di [Plugin](../plugin/) più vicina.\n\nReturns: `Plugin` L'istanza, oppure `undefined` quando non ce n'è nessuna.\n\nLa ricerca parte dal primo elemento della selezione e risale attraverso i suoi genitori.\n\nExample: Trovare il plugin\n```html\n<ui-plugin path=\"orders\"><b id=\"label\"></b></ui-plugin>\n<script>\nPLUGIN('orders', function(exports) {});\nsetTimeout(function() {\n\tconsole.log($('#label').plugin().name); // orders\n\tconsole.log($('body').plugin() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).psvg(tag)\n\nType: `method`\n\nInserisce un elemento SVG all'inizio della selezione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Il nome di un tag o markup SVG. |\n\nReturns: `jQuery` Il nuovo elemento, quando `tag` è il nome di un tag.\n\nCon il nome di un tag, il metodo crea l'elemento nel namespace SVG e lo restituisce. `tag` può essere anche markup SVG, che viene inserito all'inizio della selezione.\n\nExample: Inserire all'inizio\n```js\nvar svg = $('<svg><line></line></svg>');\nvar group = svg.psvg('g');\nsvg.psvg('<path></path>');\nconsole.log(group[0].tagName); // g\nconsole.log(svg.html()); // <path></path><g></g><line></line>\n```\n\n### $(selector).rattr(name)\n\nType: `method`\n\nRimuove un attributo.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'attributo. |\n\nReturns: `jQuery` La stessa selezione.\n\nExample: Rimuovere un attributo\n```js\nvar el = $('<div title=\"x\" id=\"a\">');\nel.rattr('title');\nconsole.log(el[0].outerHTML); // <div id=\"a\"></div>\n```\n\n### $(selector).rattrd(name, [name2], [...])\n\nType: `method`\n\nRimuove gli attributi `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome dell'attributo senza `data-`. Ogni argomento successivo rimuove un altro attributo. |\n\nReturns: `jQuery` La stessa selezione.\n\nExample: Rimuovere gli attributi\n```js\nvar el = $('<div data-a=\"1\" data-b=\"2\" data-c=\"3\">');\nel.rattrd('a', 'b');\nconsole.log(el[0].outerHTML); // <div data-c=\"3\"></div>\n```\n\n### $(selector).rclass([name], [delay])\n\nType: `method`\n\nRimuove una classe CSS, oppure tutte.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Il nome della classe. |\n| `delay` | `Number` | no |  | Il ritardo in millisecondi. |\n\nReturns: `jQuery` La stessa selezione.\n\nSenza `name`, vengono rimosse tutte le classi. Con `delay`, la classe viene rimossa in seguito, e la modifica ritardata funziona come in `aclass()`.\n\nExample: Rimuovere le classi\n```js\nvar el = $('<div class=\"a b c\">');\nel.rclass('a');\nconsole.log(el.attr('class')); // b c\nel.rclass();\nconsole.log(el.attr('class') === ''); // true\n```\n\n### $(selector).rclass2(search, [delay])\n\nType: `method`\n\nRimuove tutte le classi CSS che contengono un testo o che corrispondono a un pattern.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | Il testo da trovare o il pattern da verificare. |\n| `delay` | `Number` | no |  | Il ritardo in millisecondi. |\n\nReturns: `jQuery` La stessa selezione.\n\nCon `delay`, le classi vengono rimosse in seguito, e la modifica ritardata funziona come in `aclass()`.\n\nExample: Rimuovere per testo o pattern\n```js\nvar el = $('<div class=\"tab-1 tab-2 box\">');\nel.rclass2('tab-');\nconsole.log(el.attr('class')); // box\nvar other = $('<div class=\"tab-1 tab-2 box\">');\nother.rclass2(/1$/);\nconsole.log(other.attr('class')); // tab-2 box\n```\n\n### $(selector).scrollbar()\n\nType: `method`\n\nRestituisce la barra di scorrimento personalizzata più vicina creata con [SCROLLBAR()](../globals/).\n\nReturns: `Object` L'istanza della barra di scorrimento, oppure `undefined` quando non ce n'è nessuna.\n\nLa ricerca parte dal primo elemento della selezione e risale attraverso i suoi genitori.\n\nExample: Trovare la barra di scorrimento\n```html\n<div id=\"area\" style=\"height:50px\"><p id=\"text\"></p></div>\n<script>\nvar scrollbar = SCROLLBAR($('#area'));\nconsole.log($('#text').scrollbar() === scrollbar); // true\nconsole.log($('body').scrollbar() === undefined); // true\n</script>\n```\n\n### $(selector).SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nEsegue una funzione se esiste, altrimenti scrive un valore in un path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | La funzione o il path. |\n| `a` | `Object` | no |  | Il primo argomento, oppure il valore per il path. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\nUna funzione globale, `plugin/method` e `?/method` vengono chiamati con gli argomenti. Qualsiasi altro nome è un path, in cui `a` viene scritto con [SET()](../globals/). Il metodo non restituisce nulla.\n\nExample: Funzione o path\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = (a, b) => out.push(a + b);\n});\nwindow.hello = name => out.push('hello ' + name);\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.SEEX('hello', 'Ana');\n\tbutton.SEEX('?/save', 1, 2);\n\tbutton.SEEX('common.count', 5);\n\tconsole.log(out); // [\"hello Ana\",3]\n\tconsole.log(GET('common.count')); // 5\n}, 300);\n</script>\n```\n\n### $(selector).SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nChiama un metodo dei componenti all'interno della selezione.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | I componenti e il metodo. |\n| `a` | `Object` | no |  | Il primo argomento. |\n| `b` | `Object` | no |  | Il secondo argomento. |\n| `c` | `Object` | no |  | Il terzo argomento. |\n| `d` | `Object` | no |  | Il quarto argomento. |\n\n`name` ha la forma `component/method`. Al posto del nome del componente, `*` seleziona tutti i componenti e `.path` seleziona i componenti associati a quel path. Il metodo non restituisce nulla.\n\nExample: Chiamare i componenti\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\" config=\"label:A\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\" config=\"label:B\"></ui-component></div>\n<script>\nvar out = [];\nCOMPONENT('note', function(self, config) {\n\tself.show = text => out.push(config.label + ' ' + text);\n});\nsetTimeout(function() {\n\t$('#left').SETTER('note/show', 'one');\n\t$('body').SETTER('*/show', 'two');\n\t$('body').SETTER('.common.b/show', 'three');\n\tconsole.log(out); // [\"A one\",\"A two\",\"B two\",\"B three\"]\n}, 300);\n</script>\n```\n\n### $(selector).tclass(name, [enable])\n\nType: `method`\n\nAttiva o disattiva una classe CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Il nome della classe. |\n| `enable` | `Boolean` | no |  | `true` aggiunge la classe e `false` la rimuove. |\n\nReturns: `jQuery` La stessa selezione.\n\nExample: Attivare e disattivare\n```js\nvar el = $('<div>');\nel.tclass('open');\nconsole.log(el.hclass('open')); // true\nel.tclass('open');\nconsole.log(el.hclass('open')); // false\nel.tclass('open', true);\nconsole.log(el.hclass('open')); // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"$(selector).aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"$(selector).asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"$(selector).attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"$(selector).attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"$(selector).autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"$(selector).binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"$(selector).CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"$(selector).component()","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"$(selector).COMPONENTS()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"$(selector).EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"$(selector).hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"$(selector).multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"$(selector).plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"$(selector).psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"$(selector).rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"$(selector).rattrd(name, [name2], [...])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"$(selector).rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"$(selector).rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"scrollbar()","signature":"$(selector).scrollbar()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"$(selector).SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"$(selector).SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"$(selector).tclass(name, [enable])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcUf56o61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/jquery/","project":"jcomponent-v20","version":"20-015","section":"reference","language":"sk","title":"Rozšírenia jQuery","summary":"Metódy, ktoré jComponent pridáva do jQuery na prácu s triedami, atribútmi a SVG, hľadanie inštancií a volanie knižnice.","markdown":"---\ntitle: \"Rozšírenia jQuery\"\nproject: jComponent V20\nversion: 20.015\nsection: reference\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/reference/jquery/\nupdated: 2026-11-18T13:58:19.462Z\n---\n\n# Rozšírenia jQuery\n\n> Metódy, ktoré jComponent pridáva do jQuery na prácu s triedami, atribútmi a SVG, hľadanie inštancií a volanie knižnice.\n\njComponent obsahuje jQuery a pridáva tieto metódy každému výberu jQuery. Používajú sa najmä vnútri komponentov a pluginov: pozri [Vytváranie komponentov](../../guides/creating-components/) a [Pluginy](../../guides/plugins/).\n\n## API\n\n### $(selector).aclass(name, [delay])\n\nType: `method`\n\nPridá triedu CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov triedy. |\n| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `jQuery` Ten istý výber.\n\nS `delay` sa trieda pridá neskôr. Každý element uchováva jednu oneskorenú zmenu triedy: nové oneskorené volanie `aclass()`, `rclass()` alebo `rclass2()` nahradí tú, ktorá čaká.\n\nExample: Pridanie triedy\n```js\nvar el = $('<div>');\nel.aclass('active');\nconsole.log(el.attr('class')); // active\n```\n\nExample: Pridanie triedy neskôr\n```js\nvar el = $('<div>');\nel.aclass('active', 50);\nconsole.log(el.hclass('active')); // false\nsetTimeout(function() {\n\tconsole.log(el.hclass('active')); // true\n}, 100);\n```\n\n### $(selector).asvg(tag)\n\nType: `method`\n\nPripojí element SVG.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Názov značky alebo značky SVG. |\n\nReturns: `jQuery` Nový element, keď je `tag` názov značky.\n\nS názvom značky metóda vytvorí element v mennom priestore SVG a vráti ho. `tag` môžu byť aj značky SVG, ktoré sa pripoja k výberu.\n\nExample: Kreslenie\n```js\nvar svg = $('<svg></svg>');\nvar circle = svg.asvg('circle');\ncircle.attr('r', 5);\nsvg.asvg('<rect width=\"5\"></rect>');\nconsole.log(circle[0].namespaceURI); // http://www.w3.org/2000/svg\nconsole.log(svg.html()); // <circle r=\"5\"></circle><rect width=\"5\"></rect>\n```\n\n### $(selector).attrd(name, [value])\n\nType: `method`\n\nPrečíta alebo zapíše atribút `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov atribútu bez `data-`. |\n| `value` | `Object` | no |  | Hodnota na zápis. |\n\nReturns: `String or jQuery` Pri čítaní hodnota, pri zápise ten istý výber.\n\nExample: Čítanie a zápis\n```js\nvar el = $('<div data-id=\"7\">');\nconsole.log(el.attrd('id')); // 7\nel.attrd('name', 'box');\nconsole.log(el.attr('data-name')); // box\n```\n\n### $(selector).attrd2(name)\n\nType: `method`\n\nPrečíta atribút `data-` z elementu alebo z jeho najbližšieho nadradeného elementu, ktorý ho má.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov atribútu bez `data-`. |\n\nReturns: `String` Hodnota, alebo `undefined`, keď atribút nemá žiadny element.\n\nHľadanie sa končí pri `<body>`.\n\nExample: Hľadanie v nadradených elementoch\n```html\n<div data-id=\"7\"><span><b id=\"item\"></b></span></div>\n<script>\nconsole.log($('#item').attrd2('id')); // 7\nconsole.log($('#item').attrd2('missing') === undefined); // true\n</script>\n```\n\n### $(selector).autofocus([selector])\n\nType: `method`\n\nPresunie focus na prvé viditeľné pole vnútri výberu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selector` | `String` | no | `input,select,textarea` | Polia, ktoré sa majú prehľadať. |\n\nReturns: `jQuery` Ten istý výber.\n\nKeď focus ešte nemôže prijať žiadne pole, metóda to krátky čas skúša znova. Na mobilných zariadeniach nerobí nič.\n\nExample: Presun focusu do formulára\n```html\n<div id=\"form\"><input id=\"code\" type=\"hidden\"><input id=\"name\"></div>\n<script>\n$('#form').autofocus();\nconsole.log(document.activeElement.id); // name\n</script>\n```\n\n### $(selector).binder()\n\nType: `method`\n\nVráti najbližšiu inštanciu [ui-bind](../ui-bind/).\n\nReturns: `Object` Inštancia, alebo `undefined`, keď žiadna nie je.\n\nHľadanie sa začína pri prvom elemente výberu a pokračuje cez jeho nadradené elementy.\n\nExample: Hľadanie bindera\n```html\n<ui-bind id=\"title\" path=\"common.title\" config=\"text\"></ui-bind>\n<script>\nsetTimeout(function() {\n\tconsole.log($('#title').binder().element[0].tagName); // UI-BIND\n\tconsole.log($('body').binder() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).CMD(name, [a], [b], [c], [d])\n\nType: `method`\n\nSpustí príkaz na komponentoch vnútri výberu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Príkaz, voliteľne s flagmi za ním. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nPríkaz sa dostane iba ku komponentom vnoreným vo vybraných elementoch. Komponenty registrujú príkazy cez [command()](../component/) a globálne [CMD()](../globals/) sa dostane ku všetkým. Metóda nič nevracia.\n\nExample: Príkaz v jednom paneli\n```html\n<div id=\"left\"><ui-component name=\"list\" id=\"a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"list\" id=\"b\"></ui-component></div>\n<script>\nCOMPONENT('list', function(self) {\n\tself.command('clear', () => console.log('clear', self.element.attr('id')));\n});\nON('ready', function() {\n\t$('#left').CMD('clear'); // clear a\n});\n</script>\n```\n\n### $(selector).component()\n\nType: `method`\n\nVráti najbližšiu inštanciu [Component](../component/).\n\nReturns: `Component` Inštancia, alebo `undefined`, keď žiadna nie je.\n\nHľadanie sa začína pri prvom elemente výberu a pokračuje cez jeho nadradené elementy.\n\nExample: Hľadanie komponentu\n```html\n<ui-component name=\"note\" path=\"common.note\"><b id=\"label\"></b></ui-component>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('#label').component().name); // note\n\tconsole.log($('body').component() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).COMPONENTS()\n\nType: `method`\n\nVráti pripravené komponenty vnútri výberu.\n\nReturns: `Array` Inštancie [Component](../component/).\n\nExample: Výpis komponentov\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\"></ui-component></div>\n<script>\nCOMPONENT('note', function(self) {});\nsetTimeout(function() {\n\tconsole.log($('body').COMPONENTS().length); // 2\n\tconsole.log($('#left').COMPONENTS()[0].path.toString()); // common.a\n}, 300);\n</script>\n```\n\n### $(selector).EXEC(name, [a], [b], [c], [d])\n\nType: `method`\n\nSpustí funkciu, metódu pluginu, udalosť alebo setter komponentu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Čo sa má spustiť. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nTvar `name` určuje, čo sa spustí:\n\n| Názov | Čo sa spustí |\n| --- | --- |\n| `myfunction` | Globálna funkcia |\n| `FUNC.path` | Funkcia na path |\n| `plugin/method` | Metóda pluginu |\n| `?/method`, `\\|method` | Metóda najbližšieho pluginu |\n| `#name` | Udalosť `name` |\n| `-component/method` | Setter komponentu |\n\nMetóda nič nevracia.\n\nExample: Spustenie funkcie\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = id => out.push('save ' + id);\n});\nFUNC.hello = name => out.push('hello ' + name);\nON('saved', id => out.push('event ' + id));\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.EXEC('FUNC.hello', 'Ana');\n\tbutton.EXEC('orders/save', 1);\n\tbutton.EXEC('?/save', 2);\n\tbutton.EXEC('|save', 3);\n\tbutton.EXEC('#saved', 4);\n\tconsole.log(out); // [\"hello Ana\",\"save 1\",\"save 2\",\"save 3\",\"event 4\"]\n}, 300);\n</script>\n```\n\n### $(selector).hclass(name)\n\nType: `method`\n\nOverí, či má element triedu CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov triedy. |\n\nReturns: `Boolean` `true`, keď je trieda prítomná.\n\nExample: Kontrola triedy\n```js\nvar el = $('<div class=\"active\">');\nconsole.log(el.hclass('active')); // true\nconsole.log(el.hclass('hidden')); // false\n```\n\n### $(selector).multiple(selectors)\n\nType: `method`\n\nSpustí naraz niekoľko vyhľadávaní vnútri výberu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `selectors` | `Object` | yes |  | Kľúče výsledku a ich selektory. |\n\nReturns: `Object` Výber jQuery pre každý kľúč.\n\nExample: Hľadanie elementov\n```js\nvar el = $('<div><input><input><button></button></div>');\nvar found = el.multiple({ fields: 'input', submit: 'button' });\nconsole.log(found.fields.length); // 2\nconsole.log(found.submit.length); // 1\n```\n\n### $(selector).plugin()\n\nType: `method`\n\nVráti najbližšiu inštanciu [Plugin](../plugin/).\n\nReturns: `Plugin` Inštancia, alebo `undefined`, keď žiadna nie je.\n\nHľadanie sa začína pri prvom elemente výberu a pokračuje cez jeho nadradené elementy.\n\nExample: Hľadanie pluginu\n```html\n<ui-plugin path=\"orders\"><b id=\"label\"></b></ui-plugin>\n<script>\nPLUGIN('orders', function(exports) {});\nsetTimeout(function() {\n\tconsole.log($('#label').plugin().name); // orders\n\tconsole.log($('body').plugin() === undefined); // true\n}, 300);\n</script>\n```\n\n### $(selector).psvg(tag)\n\nType: `method`\n\nVloží element SVG na začiatok výberu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `tag` | `String` | yes |  | Názov značky alebo značky SVG. |\n\nReturns: `jQuery` Nový element, keď je `tag` názov značky.\n\nS názvom značky metóda vytvorí element v mennom priestore SVG a vráti ho. `tag` môžu byť aj značky SVG, ktoré sa vložia na začiatok výberu.\n\nExample: Vloženie na začiatok\n```js\nvar svg = $('<svg><line></line></svg>');\nvar group = svg.psvg('g');\nsvg.psvg('<path></path>');\nconsole.log(group[0].tagName); // g\nconsole.log(svg.html()); // <path></path><g></g><line></line>\n```\n\n### $(selector).rattr(name)\n\nType: `method`\n\nOdstráni atribút.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov atribútu. |\n\nReturns: `jQuery` Ten istý výber.\n\nExample: Odstránenie atribútu\n```js\nvar el = $('<div title=\"x\" id=\"a\">');\nel.rattr('title');\nconsole.log(el[0].outerHTML); // <div id=\"a\"></div>\n```\n\n### $(selector).rattrd(name, [name2], [...])\n\nType: `method`\n\nOdstráni atribúty `data-`.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov atribútu bez `data-`. Každý ďalší argument odstráni ďalší atribút. |\n\nReturns: `jQuery` Ten istý výber.\n\nExample: Odstránenie atribútov\n```js\nvar el = $('<div data-a=\"1\" data-b=\"2\" data-c=\"3\">');\nel.rattrd('a', 'b');\nconsole.log(el[0].outerHTML); // <div data-c=\"3\"></div>\n```\n\n### $(selector).rclass([name], [delay])\n\nType: `method`\n\nOdstráni triedu CSS alebo všetky triedy.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | no |  | Názov triedy. |\n| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `jQuery` Ten istý výber.\n\nBez `name` sa odstráni každá trieda. S `delay` sa trieda odstráni neskôr a oneskorená zmena funguje ako v `aclass()`.\n\nExample: Odstránenie tried\n```js\nvar el = $('<div class=\"a b c\">');\nel.rclass('a');\nconsole.log(el.attr('class')); // b c\nel.rclass();\nconsole.log(el.attr('class') === ''); // true\n```\n\n### $(selector).rclass2(search, [delay])\n\nType: `method`\n\nOdstráni všetky triedy CSS, ktoré obsahujú text alebo zodpovedajú vzoru.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `search` | `String or RegExp` | yes |  | Hľadaný text alebo testovaný vzor. |\n| `delay` | `Number` | no |  | Oneskorenie v milisekundách. |\n\nReturns: `jQuery` Ten istý výber.\n\nS `delay` sa triedy odstránia neskôr a oneskorená zmena funguje ako v `aclass()`.\n\nExample: Odstránenie podľa textu alebo vzoru\n```js\nvar el = $('<div class=\"tab-1 tab-2 box\">');\nel.rclass2('tab-');\nconsole.log(el.attr('class')); // box\nvar other = $('<div class=\"tab-1 tab-2 box\">');\nother.rclass2(/1$/);\nconsole.log(other.attr('class')); // tab-2 box\n```\n\n### $(selector).scrollbar()\n\nType: `method`\n\nVráti najbližší vlastný posuvník vytvorený pomocou [SCROLLBAR()](../globals/).\n\nReturns: `Object` Inštancia posuvníka, alebo `undefined`, keď žiadna nie je.\n\nHľadanie sa začína pri prvom elemente výberu a pokračuje cez jeho nadradené elementy.\n\nExample: Hľadanie posuvníka\n```html\n<div id=\"area\" style=\"height:50px\"><p id=\"text\"></p></div>\n<script>\nvar scrollbar = SCROLLBAR($('#area'));\nconsole.log($('#text').scrollbar() === scrollbar); // true\nconsole.log($('body').scrollbar() === undefined); // true\n</script>\n```\n\n### $(selector).SEEX(name, [a], [b], [c], [d])\n\nType: `method`\n\nSpustí funkciu, ak existuje, inak zapíše hodnotu na path.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Funkcia alebo path. |\n| `a` | `Object` | no |  | Prvý argument alebo hodnota pre path. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\nGlobálna funkcia, `plugin/method` a `?/method` sa zavolajú s argumentmi. Každý iný názov je path a `a` sa naň zapíše pomocou [SET()](../globals/). Metóda nič nevracia.\n\nExample: Funkcia alebo path\n```html\n<ui-plugin path=\"orders\"><button id=\"save\"></button></ui-plugin>\n<script>\nvar out = [];\nPLUGIN('orders', function(exports) {\n\texports.save = (a, b) => out.push(a + b);\n});\nwindow.hello = name => out.push('hello ' + name);\nsetTimeout(function() {\n\tvar button = $('#save');\n\tbutton.SEEX('hello', 'Ana');\n\tbutton.SEEX('?/save', 1, 2);\n\tbutton.SEEX('common.count', 5);\n\tconsole.log(out); // [\"hello Ana\",3]\n\tconsole.log(GET('common.count')); // 5\n}, 300);\n</script>\n```\n\n### $(selector).SETTER(name, [a], [b], [c], [d])\n\nType: `method`\n\nZavolá metódu komponentov vnútri výberu.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Komponenty a metóda. |\n| `a` | `Object` | no |  | Prvý argument. |\n| `b` | `Object` | no |  | Druhý argument. |\n| `c` | `Object` | no |  | Tretí argument. |\n| `d` | `Object` | no |  | Štvrtý argument. |\n\n`name` má tvar `component/method`. Namiesto názvu komponentu `*` vyberie všetky komponenty a `.path` komponenty naviazané na daný path. Metóda nič nevracia.\n\nExample: Volanie komponentov\n```html\n<div id=\"left\"><ui-component name=\"note\" path=\"common.a\" config=\"label:A\"></ui-component></div>\n<div id=\"right\"><ui-component name=\"note\" path=\"common.b\" config=\"label:B\"></ui-component></div>\n<script>\nvar out = [];\nCOMPONENT('note', function(self, config) {\n\tself.show = text => out.push(config.label + ' ' + text);\n});\nsetTimeout(function() {\n\t$('#left').SETTER('note/show', 'one');\n\t$('body').SETTER('*/show', 'two');\n\t$('body').SETTER('.common.b/show', 'three');\n\tconsole.log(out); // [\"A one\",\"A two\",\"B two\",\"B three\"]\n}, 300);\n</script>\n```\n\n### $(selector).tclass(name, [enable])\n\nType: `method`\n\nPrepne triedu CSS.\n\n| Parameter | Type | Required | Default | Description |\n| --- | --- | --- | --- | --- |\n| `name` | `String` | yes |  | Názov triedy. |\n| `enable` | `Boolean` | no |  | `true` triedu pridá a `false` ju odstráni. |\n\nReturns: `jQuery` Ten istý výber.\n\nExample: Prepínanie\n```js\nvar el = $('<div>');\nel.tclass('open');\nconsole.log(el.hclass('open')); // true\nel.tclass('open');\nconsole.log(el.hclass('open')); // false\nel.tclass('open', true);\nconsole.log(el.hclass('open')); // true\n```\n","entries":[{"type":"method","name":"aclass()","signature":"$(selector).aclass(name, [delay])","since":"","deprecated":false},{"type":"method","name":"asvg()","signature":"$(selector).asvg(tag)","since":"","deprecated":false},{"type":"method","name":"attrd()","signature":"$(selector).attrd(name, [value])","since":"","deprecated":false},{"type":"method","name":"attrd2()","signature":"$(selector).attrd2(name)","since":"","deprecated":false},{"type":"method","name":"autofocus()","signature":"$(selector).autofocus([selector])","since":"","deprecated":false},{"type":"method","name":"binder()","signature":"$(selector).binder()","since":"","deprecated":false},{"type":"method","name":"CMD()","signature":"$(selector).CMD(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"component()","signature":"$(selector).component()","since":"","deprecated":false},{"type":"method","name":"COMPONENTS()","signature":"$(selector).COMPONENTS()","since":"","deprecated":false},{"type":"method","name":"EXEC()","signature":"$(selector).EXEC(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"hclass()","signature":"$(selector).hclass(name)","since":"","deprecated":false},{"type":"method","name":"multiple()","signature":"$(selector).multiple(selectors)","since":"","deprecated":false},{"type":"method","name":"plugin()","signature":"$(selector).plugin()","since":"","deprecated":false},{"type":"method","name":"psvg()","signature":"$(selector).psvg(tag)","since":"","deprecated":false},{"type":"method","name":"rattr()","signature":"$(selector).rattr(name)","since":"","deprecated":false},{"type":"method","name":"rattrd()","signature":"$(selector).rattrd(name, [name2], [...])","since":"","deprecated":false},{"type":"method","name":"rclass()","signature":"$(selector).rclass([name], [delay])","since":"","deprecated":false},{"type":"method","name":"rclass2()","signature":"$(selector).rclass2(search, [delay])","since":"","deprecated":false},{"type":"method","name":"scrollbar()","signature":"$(selector).scrollbar()","since":"","deprecated":false},{"type":"method","name":"SEEX()","signature":"$(selector).SEEX(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"SETTER()","signature":"$(selector).SETTER(name, [a], [b], [c], [d])","since":"","deprecated":false},{"type":"method","name":"tclass()","signature":"$(selector).tclass(name, [enable])","since":"","deprecated":false}],"license":"MIT","updated":"2026-11-18T13:58:19.462Z"}
{"id":"JamcN61ed61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/faq/faq/","project":"jcomponent-v20","version":"20-015","section":"faq","language":"en","title":"FAQ","summary":"Answers to the questions developers ask when they start with jComponent.","markdown":"---\ntitle: FAQ\nproject: jComponent V20\nversion: 20.015\nsection: faq\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/faq/faq/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# FAQ\n\n> Answers to the questions developers ask when they start with jComponent.\n\nShort answers to the questions that come up first. Each answer links to the page that explains the topic in full.\n\n## Data and paths\n\n### Why does the page not update when I change a variable?\n\nA plain assignment does not tell anyone about the change. Write with `SET()`, or call `UPD()` after the assignment.\n\n```html\n<ui-bind path=\"profile.name\" config=\"text\"></ui-bind>\n\n<script>\nwindow.profile = { name: 'Ann' };\n\nprofile.name = 'Bob';     // the page still shows Ann\nUPD('profile.name');      // the page shows Bob\nSET('profile.name', 'Eve'); // the page shows Eve\n</script>\n```\n\nRead more in [Data binding](../../guides/data-binding/).\n\n### How do I run code when a value changes?\n\nUse `WATCH()`. A watcher also fires for changes in the paths below or above its own path.\n\n```js\nWATCH('filter.q', function(value, flags, path) {\n  console.log(path, value);\n});\n\nSET('filter.q', 'lamp'); // filter.q lamp\nSET('filter', { q: 'desk' }); // filter desk\n```\n\nRead more in [Paths](../../guides/paths/).\n\n### Where do I keep temporary values?\n\nA path that starts with `%` is stored in `DEF.tmp`, and a path that starts with `*` is stored in the global object `common`.\n\n```js\nSET('%search', 'lamp');\nconsole.log(DEF.tmp.search); // lamp\n\nSET('*theme', 'dark');\nconsole.log(common.theme);   // dark\n```\n\nRead more in [Paths](../../guides/paths/).\n\n### How do I load data from the server into a path?\n\nPass the path as the last argument of `AJAX()`. Bindings on that path render the response.\n\n```js\nAJAX('GET /api/users/', 'users');\n```\n\nThe [Global functions](../../reference/globals/) reference describes `AJAX()`.\n\n### Why does a value appear with HTML tags as text?\n\nOutput is encoded by default. In a template, use the `raw` helper. In `<ui-bind>`, use the `html` command in place of `text`. Do this only for content you trust.\n\n```js\nTangular.render('{{ text }}', { text: '<b>Hi</b>' });       // &lt;b&gt;Hi&lt;/b&gt;\nTangular.render('{{ text | raw }}', { text: '<b>Hi</b>' }); // <b>Hi</b>\n```\n\nRead more in [Templates with Tangular](../../guides/tangular/).\n\n### How do I render a list?\n\nUse the `template` command of `<ui-bind>` with a `foreach` loop.\n\n```html\n<ui-bind path=\"users\" config=\"template\">\n  <script type=\"text/html\">{{ foreach m in value }}<b>{{ m.name }}</b>{{ end }}</script>\n</ui-bind>\n```\n\nRead more in [Templates with Tangular](../../guides/tangular/).\n\n## Components and plugins\n\n### When is it safe to call a component?\n\nComponents start after the page loads, so they do not exist yet while your script runs for the first time. Wait for the `ready` event.\n\n```js\nconsole.log(FIND('clock') == null); // true\n\nON('ready', function() {\n  FIND('clock').show();\n});\n```\n\nRead more in [Using components](../../guides/using-components/).\n\n### Why does the console say that a component is being downloaded?\n\nNo `COMPONENT()` declaration exists for the name in `<ui-component>`, so the library tries to download it from the address in `DEF.fallback`. Declare the component in your code, or point `DEF.fallback` to your own server.\n\nRead more in [Using components](../../guides/using-components/).\n\n### What does `?` mean in a path?\n\nIt stands for the path of the closest plugin. In the plugin `profile`, `?.name` is the path `profile.name`.\n\n```html\n<ui-plugin path=\"profile\">\n  <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nRead more in [Plugins](../../guides/plugins/).\n\n### How do two plugins talk to each other?\n\nCall a method with `EXEC()`, or send a global event with `EMIT()`.\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.add = function(item) {\n    exports.push('items', item);\n  };\n  exports.on('checkout', function() {\n    console.log('checkout', exports.get('items').length);\n  });\n});\n\nPLUGIN('shop', function(exports) {\n  exports.buy = function() {\n    EXEC('cart/add', 'Lamp');\n    EMIT('checkout');\n  };\n});\n```\n\nRead more in [Plugins](../../guides/plugins/).\n\n### When does `destroy` run after I remove an element?\n\nThe library looks for removed components and plugins once per minute. Call `FREE()` to run the clean-up at once.\n\n```js\n$('#list').empty();\nFREE(); // calls destroy\n```\n\nRead more in [Creating components](../../guides/creating-components/).\n\n### Why do I not see any warnings in the console?\n\nMost warnings are off by default. Turn them on with `DEF.warnings`.\n\n```js\nDEF.warnings = true;\nEXEC('missing/run'); // jComponent: The plugin \"missing\" not found.\n```\n\nThe [DEF](../../reference/def/) reference lists the other settings.\n\n## Forms\n\n### How do I check a form ahead of sending it?\n\n`ERRORS()` returns the invalid components under a path.\n\n```js\nERRORS('form', function(components) {\n  if (!components.length)\n    AJAX('POST /api/contact/', GET('form'), NOOP);\n});\n```\n\nRead more in [Forms and validation](../../guides/forms/).\n\n### How do I hide the error until the user has touched a field?\n\nA required empty field is invalid from the start. Show the message only when `config.touched` is set.\n\n```js\nself.state = function() {\n  self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n};\n```\n\nRead more in [Forms and validation](../../guides/forms/).\n\n## Applications\n\n### Why do my links reload the page?\n\nA plain link is handled by the browser. Pass the links to `NAV.clientside()`.\n\n```js\nNAV.clientside('a.link');\n```\n\nRead more in [Routing](../../guides/routing/).\n\n### Why is my route not called?\n\nCheck these three things:\n\n- The URLs are compared in lowercase, so a route with a capital letter never matches.\n- A middleware that calls `next(false)` stops the route.\n- When a page opens directly at the URL, the server has to return the application page for that URL.\n\nRead more in [Routing](../../guides/routing/).\n\n### How do I load a script only once?\n\nAdd the `@singleton` flag to the URL.\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nRead more in [Importing content](../../guides/importing/).\n\n### Why is my `@(text)` not translated?\n\nOnly content loaded with `IMPORT()` or `<ui-import>` is translated automatically. Translate other strings with `TRANSLATE()`, and load the dictionary first.\n\n```js\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\nTRANSLATE('<button>@(Save)</button>'); // <button>Speichern</button>\n```\n\nRead more in [Localization](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcN61ed61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/faq/faq/","project":"jcomponent-v20","version":"20-015","section":"faq","language":"de","title":"FAQ","summary":"Antworten auf die Fragen, die Entwickler beim Einstieg in jComponent stellen.","markdown":"---\ntitle: FAQ\nproject: jComponent V20\nversion: 20.015\nsection: faq\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/faq/faq/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# FAQ\n\n> Antworten auf die Fragen, die Entwickler beim Einstieg in jComponent stellen.\n\nKurze Antworten auf die Fragen, die als Erstes aufkommen. Jede Antwort verweist auf die Seite, die das Thema ausführlich erklärt.\n\n## Daten und Paths\n\n### Warum wird die Seite nicht aktualisiert, wenn ich eine Variable ändere?\n\nEine einfache Zuweisung teilt niemandem die Änderung mit. Schreibe mit `SET()` oder rufe nach der Zuweisung `UPD()` auf.\n\n```html\n<ui-bind path=\"profile.name\" config=\"text\"></ui-bind>\n\n<script>\nwindow.profile = { name: 'Ann' };\n\nprofile.name = 'Bob';     // the page still shows Ann\nUPD('profile.name');      // the page shows Bob\nSET('profile.name', 'Eve'); // the page shows Eve\n</script>\n```\n\nMehr dazu in [Datenbindung](../../guides/data-binding/).\n\n### Wie führe ich Code aus, wenn sich ein Wert ändert?\n\nVerwende `WATCH()`. Ein Watcher reagiert auch auf Änderungen an den Paths unterhalb oder oberhalb seines eigenen Paths.\n\n```js\nWATCH('filter.q', function(value, flags, path) {\n  console.log(path, value);\n});\n\nSET('filter.q', 'lamp'); // filter.q lamp\nSET('filter', { q: 'desk' }); // filter desk\n```\n\nMehr dazu in [Paths](../../guides/paths/).\n\n### Wo bewahre ich temporäre Werte auf?\n\nEin Path, der mit `%` beginnt, wird in `DEF.tmp` gespeichert, und ein Path, der mit `*` beginnt, im globalen Objekt `common`.\n\n```js\nSET('%search', 'lamp');\nconsole.log(DEF.tmp.search); // lamp\n\nSET('*theme', 'dark');\nconsole.log(common.theme);   // dark\n```\n\nMehr dazu in [Paths](../../guides/paths/).\n\n### Wie lade ich Daten vom Server in einen Path?\n\nÜbergib den Path als letztes Argument von `AJAX()`. Bindungen an diesem Path rendern die Antwort.\n\n```js\nAJAX('GET /api/users/', 'users');\n```\n\nDie Referenz [Globale Funktionen](../../reference/globals/) beschreibt `AJAX()`.\n\n### Warum erscheint ein Wert mit HTML-Tags als Text?\n\nDie Ausgabe wird standardmäßig kodiert. Verwende in einem Template den Helper `raw`. Verwende in `<ui-bind>` den Befehl `html` statt `text`. Mach das nur bei Inhalten, denen du vertraust.\n\n```js\nTangular.render('{{ text }}', { text: '<b>Hi</b>' });       // &lt;b&gt;Hi&lt;/b&gt;\nTangular.render('{{ text | raw }}', { text: '<b>Hi</b>' }); // <b>Hi</b>\n```\n\nMehr dazu in [Templates mit Tangular](../../guides/tangular/).\n\n### Wie rendere ich eine Liste?\n\nVerwende den Befehl `template` von `<ui-bind>` mit einer `foreach`-Schleife.\n\n```html\n<ui-bind path=\"users\" config=\"template\">\n  <script type=\"text/html\">{{ foreach m in value }}<b>{{ m.name }}</b>{{ end }}</script>\n</ui-bind>\n```\n\nMehr dazu in [Templates mit Tangular](../../guides/tangular/).\n\n## Komponenten und Plugins\n\n### Wann kann ich eine Komponente sicher aufrufen?\n\nKomponenten starten, nachdem die Seite geladen ist. Beim ersten Durchlauf deines Skripts existieren sie also noch nicht. Warte auf das Event `ready`.\n\n```js\nconsole.log(FIND('clock') == null); // true\n\nON('ready', function() {\n  FIND('clock').show();\n});\n```\n\nMehr dazu in [Komponenten verwenden](../../guides/using-components/).\n\n### Warum meldet die Konsole, dass eine Komponente heruntergeladen wird?\n\nFür den Namen in `<ui-component>` gibt es keine `COMPONENT()`-Deklaration, also versucht die Bibliothek, sie von der Adresse in `DEF.fallback` herunterzuladen. Deklariere die Komponente in deinem Code oder lass `DEF.fallback` auf deinen eigenen Server zeigen.\n\nMehr dazu in [Komponenten verwenden](../../guides/using-components/).\n\n### Was bedeutet `?` in einem Path?\n\nEs steht für den Path des nächsten Plugins. Im Plugin `profile` ist `?.name` der Path `profile.name`.\n\n```html\n<ui-plugin path=\"profile\">\n  <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nMehr dazu in [Plugins](../../guides/plugins/).\n\n### Wie kommunizieren zwei Plugins miteinander?\n\nRufe mit `EXEC()` eine Methode auf oder sende mit `EMIT()` ein globales Event.\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.add = function(item) {\n    exports.push('items', item);\n  };\n  exports.on('checkout', function() {\n    console.log('checkout', exports.get('items').length);\n  });\n});\n\nPLUGIN('shop', function(exports) {\n  exports.buy = function() {\n    EXEC('cart/add', 'Lamp');\n    EMIT('checkout');\n  };\n});\n```\n\nMehr dazu in [Plugins](../../guides/plugins/).\n\n### Wann läuft `destroy`, nachdem ich ein Element entfernt habe?\n\nDie Bibliothek sucht einmal pro Minute nach entfernten Komponenten und Plugins. Rufe `FREE()` auf, um die Bereinigung sofort auszuführen.\n\n```js\n$('#list').empty();\nFREE(); // calls destroy\n```\n\nMehr dazu in [Komponenten erstellen](../../guides/creating-components/).\n\n### Warum sehe ich keine Warnungen in der Konsole?\n\nDie meisten Warnungen sind standardmäßig ausgeschaltet. Schalte sie mit `DEF.warnings` ein.\n\n```js\nDEF.warnings = true;\nEXEC('missing/run'); // jComponent: The plugin \"missing\" not found.\n```\n\nDie Referenz [DEF](../../reference/def/) listet die übrigen Einstellungen auf.\n\n## Formulare\n\n### Wie prüfe ich ein Formular vor dem Absenden?\n\n`ERRORS()` gibt die ungültigen Komponenten unter einem Path zurück.\n\n```js\nERRORS('form', function(components) {\n  if (!components.length)\n    AJAX('POST /api/contact/', GET('form'), NOOP);\n});\n```\n\nMehr dazu in [Formulare und Validierung](../../guides/forms/).\n\n### Wie verberge ich den Fehler, bis der Benutzer ein Feld berührt hat?\n\nEin leeres Pflichtfeld ist von Anfang an ungültig. Zeige die Meldung erst an, wenn `config.touched` gesetzt ist.\n\n```js\nself.state = function() {\n  self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n};\n```\n\nMehr dazu in [Formulare und Validierung](../../guides/forms/).\n\n## Anwendungen\n\n### Warum laden meine Links die Seite neu?\n\nEinen einfachen Link verarbeitet der Browser. Übergib die Links an `NAV.clientside()`.\n\n```js\nNAV.clientside('a.link');\n```\n\nMehr dazu in [Routing](../../guides/routing/).\n\n### Warum wird meine Route nicht aufgerufen?\n\nPrüfe diese drei Punkte:\n\n- Die URLs werden in Kleinschreibung verglichen, eine Route mit einem Großbuchstaben passt also nie.\n- Eine Middleware, die `next(false)` aufruft, stoppt die Route.\n- Wird eine Seite direkt über die URL geöffnet, muss der Server für diese URL die Anwendungsseite zurückgeben.\n\nMehr dazu in [Routing](../../guides/routing/).\n\n### Wie lade ich ein Skript nur einmal?\n\nFüge der URL das Flag `@singleton` hinzu.\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nMehr dazu in [Inhalte importieren](../../guides/importing/).\n\n### Warum wird mein `@(text)` nicht übersetzt?\n\nNur Inhalte, die mit `IMPORT()` oder `<ui-import>` geladen werden, werden automatisch übersetzt. Übersetze andere Strings mit `TRANSLATE()` und lade zuerst das Wörterbuch.\n\n```js\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\nTRANSLATE('<button>@(Save)</button>'); // <button>Speichern</button>\n```\n\nMehr dazu in [Lokalisierung](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcN61ed61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/faq/faq/","project":"jcomponent-v20","version":"20-015","section":"faq","language":"es","title":"Preguntas frecuentes","summary":"Respuestas a las preguntas que se hacen los desarrolladores cuando empiezan con jComponent.","markdown":"---\ntitle: Preguntas frecuentes\nproject: jComponent V20\nversion: 20.015\nsection: faq\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/faq/faq/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# Preguntas frecuentes\n\n> Respuestas a las preguntas que se hacen los desarrolladores cuando empiezan con jComponent.\n\nRespuestas breves a las primeras preguntas que surgen. Cada respuesta enlaza con la página que explica el tema en detalle.\n\n## Datos y paths\n\n### ¿Por qué no se actualiza la página cuando cambio una variable?\n\nUna asignación simple no avisa a nadie del cambio. Escribe con `SET()`, o llama a `UPD()` después de la asignación.\n\n```html\n<ui-bind path=\"profile.name\" config=\"text\"></ui-bind>\n\n<script>\nwindow.profile = { name: 'Ann' };\n\nprofile.name = 'Bob';     // the page still shows Ann\nUPD('profile.name');      // the page shows Bob\nSET('profile.name', 'Eve'); // the page shows Eve\n</script>\n```\n\nMás información en [Enlace de datos](../../guides/data-binding/).\n\n### ¿Cómo ejecuto código cuando cambia un valor?\n\nUsa `WATCH()`. Un observador también se dispara con los cambios en los paths que están por debajo o por encima del suyo.\n\n```js\nWATCH('filter.q', function(value, flags, path) {\n  console.log(path, value);\n});\n\nSET('filter.q', 'lamp'); // filter.q lamp\nSET('filter', { q: 'desk' }); // filter desk\n```\n\nMás información en [Paths](../../guides/paths/).\n\n### ¿Dónde guardo los valores temporales?\n\nUn path que empieza por `%` se guarda en `DEF.tmp`, y un path que empieza por `*` se guarda en el objeto global `common`.\n\n```js\nSET('%search', 'lamp');\nconsole.log(DEF.tmp.search); // lamp\n\nSET('*theme', 'dark');\nconsole.log(common.theme);   // dark\n```\n\nMás información en [Paths](../../guides/paths/).\n\n### ¿Cómo cargo datos del servidor en un path?\n\nPasa el path como último argumento de `AJAX()`. Los enlaces de ese path renderizan la respuesta.\n\n```js\nAJAX('GET /api/users/', 'users');\n```\n\nLa referencia de [Funciones globales](../../reference/globals/) describe `AJAX()`.\n\n### ¿Por qué un valor aparece con las etiquetas HTML como texto?\n\nLa salida se codifica de forma predeterminada. En una plantilla, usa el helper `raw`. En `<ui-bind>`, usa el comando `html` en lugar de `text`. Hazlo solo con contenido de confianza.\n\n```js\nTangular.render('{{ text }}', { text: '<b>Hi</b>' });       // &lt;b&gt;Hi&lt;/b&gt;\nTangular.render('{{ text | raw }}', { text: '<b>Hi</b>' }); // <b>Hi</b>\n```\n\nMás información en [Plantillas con Tangular](../../guides/tangular/).\n\n### ¿Cómo renderizo una lista?\n\nUsa el comando `template` de `<ui-bind>` con un bucle `foreach`.\n\n```html\n<ui-bind path=\"users\" config=\"template\">\n  <script type=\"text/html\">{{ foreach m in value }}<b>{{ m.name }}</b>{{ end }}</script>\n</ui-bind>\n```\n\nMás información en [Plantillas con Tangular](../../guides/tangular/).\n\n## Componentes y plugins\n\n### ¿Cuándo es seguro llamar a un componente?\n\nLos componentes arrancan después de cargarse la página, así que todavía no existen mientras tu script se ejecuta por primera vez. Espera al evento `ready`.\n\n```js\nconsole.log(FIND('clock') == null); // true\n\nON('ready', function() {\n  FIND('clock').show();\n});\n```\n\nMás información en [Usar componentes](../../guides/using-components/).\n\n### ¿Por qué la consola dice que se está descargando un componente?\n\nNo existe ninguna declaración `COMPONENT()` para el nombre de `<ui-component>`, así que la biblioteca intenta descargarla desde la dirección de `DEF.fallback`. Declara el componente en tu código o apunta `DEF.fallback` a tu propio servidor.\n\nMás información en [Usar componentes](../../guides/using-components/).\n\n### ¿Qué significa `?` en un path?\n\nRepresenta el path del plugin más cercano. En el plugin `profile`, `?.name` es el path `profile.name`.\n\n```html\n<ui-plugin path=\"profile\">\n  <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nMás información en [Plugins](../../guides/plugins/).\n\n### ¿Cómo se comunican dos plugins entre sí?\n\nLlama a un método con `EXEC()` o envía un evento global con `EMIT()`.\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.add = function(item) {\n    exports.push('items', item);\n  };\n  exports.on('checkout', function() {\n    console.log('checkout', exports.get('items').length);\n  });\n});\n\nPLUGIN('shop', function(exports) {\n  exports.buy = function() {\n    EXEC('cart/add', 'Lamp');\n    EMIT('checkout');\n  };\n});\n```\n\nMás información en [Plugins](../../guides/plugins/).\n\n### ¿Cuándo se ejecuta `destroy` después de eliminar un elemento?\n\nLa biblioteca busca los componentes y plugins eliminados una vez por minuto. Llama a `FREE()` para ejecutar la limpieza de inmediato.\n\n```js\n$('#list').empty();\nFREE(); // calls destroy\n```\n\nMás información en [Crear componentes](../../guides/creating-components/).\n\n### ¿Por qué no veo ninguna advertencia en la consola?\n\nLa mayoría de las advertencias están desactivadas de forma predeterminada. Actívalas con `DEF.warnings`.\n\n```js\nDEF.warnings = true;\nEXEC('missing/run'); // jComponent: The plugin \"missing\" not found.\n```\n\nLa referencia de [DEF](../../reference/def/) enumera los demás ajustes.\n\n## Formularios\n\n### ¿Cómo compruebo un formulario antes de enviarlo?\n\n`ERRORS()` devuelve los componentes no válidos que hay bajo un path.\n\n```js\nERRORS('form', function(components) {\n  if (!components.length)\n    AJAX('POST /api/contact/', GET('form'), NOOP);\n});\n```\n\nMás información en [Formularios y validación](../../guides/forms/).\n\n### ¿Cómo oculto el error hasta que el usuario haya tocado un campo?\n\nUn campo obligatorio vacío no es válido desde el principio. Muestra el mensaje solo cuando `config.touched` esté establecido.\n\n```js\nself.state = function() {\n  self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n};\n```\n\nMás información en [Formularios y validación](../../guides/forms/).\n\n## Aplicaciones\n\n### ¿Por qué mis enlaces recargan la página?\n\nEl navegador gestiona los enlaces normales. Pasa los enlaces a `NAV.clientside()`.\n\n```js\nNAV.clientside('a.link');\n```\n\nMás información en [Enrutamiento](../../guides/routing/).\n\n### ¿Por qué no se llama a mi ruta?\n\nComprueba estas tres cosas:\n\n- Las URL se comparan en minúsculas, así que una ruta con una mayúscula nunca coincide.\n- Un middleware que llama a `next(false)` detiene la ruta.\n- Cuando una página se abre directamente en la URL, el servidor tiene que devolver la página de la aplicación para esa URL.\n\nMás información en [Enrutamiento](../../guides/routing/).\n\n### ¿Cómo cargo un script una sola vez?\n\nAñade el flag `@singleton` a la URL.\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nMás información en [Importar contenido](../../guides/importing/).\n\n### ¿Por qué no se traduce mi `@(text)`?\n\nSolo se traduce automáticamente el contenido cargado con `IMPORT()` o `<ui-import>`. Traduce las demás cadenas con `TRANSLATE()` y carga antes el diccionario.\n\n```js\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\nTRANSLATE('<button>@(Save)</button>'); // <button>Speichern</button>\n```\n\nMás información en [Localización](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcN61ed61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/faq/faq/","project":"jcomponent-v20","version":"20-015","section":"faq","language":"fr","title":"FAQ","summary":"Les réponses aux questions que se posent les développeurs qui débutent avec jComponent.","markdown":"---\ntitle: FAQ\nproject: jComponent V20\nversion: 20.015\nsection: faq\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/faq/faq/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# FAQ\n\n> Les réponses aux questions que se posent les développeurs qui débutent avec jComponent.\n\nDes réponses courtes aux questions qui se posent en premier. Chaque réponse renvoie vers la page qui traite le sujet en détail.\n\n## Données et paths\n\n### Pourquoi la page ne se met-elle pas à jour quand je modifie une variable ?\n\nUne simple affectation ne signale le changement à personne. Écris avec `SET()`, ou appelle `UPD()` après l'affectation.\n\n```html\n<ui-bind path=\"profile.name\" config=\"text\"></ui-bind>\n\n<script>\nwindow.profile = { name: 'Ann' };\n\nprofile.name = 'Bob';     // the page still shows Ann\nUPD('profile.name');      // the page shows Bob\nSET('profile.name', 'Eve'); // the page shows Eve\n</script>\n```\n\nPour en savoir plus, consulte [Liaison de données](../../guides/data-binding/).\n\n### Comment exécuter du code quand une valeur change ?\n\nUtilise `WATCH()`. Un observateur se déclenche aussi pour les modifications des paths situés au-dessous ou au-dessus du sien.\n\n```js\nWATCH('filter.q', function(value, flags, path) {\n  console.log(path, value);\n});\n\nSET('filter.q', 'lamp'); // filter.q lamp\nSET('filter', { q: 'desk' }); // filter desk\n```\n\nPour en savoir plus, consulte [Paths](../../guides/paths/).\n\n### Où conserver des valeurs temporaires ?\n\nUn path qui commence par `%` est stocké dans `DEF.tmp`, et un path qui commence par `*` est stocké dans l'objet global `common`.\n\n```js\nSET('%search', 'lamp');\nconsole.log(DEF.tmp.search); // lamp\n\nSET('*theme', 'dark');\nconsole.log(common.theme);   // dark\n```\n\nPour en savoir plus, consulte [Paths](../../guides/paths/).\n\n### Comment charger des données du serveur dans un path ?\n\nPasse le path comme dernier argument de `AJAX()`. Les liaisons de ce path affichent la réponse.\n\n```js\nAJAX('GET /api/users/', 'users');\n```\n\nLa référence [Fonctions globales](../../reference/globals/) décrit `AJAX()`.\n\n### Pourquoi une valeur s'affiche-t-elle avec ses balises HTML sous forme de texte ?\n\nLa sortie est encodée par défaut. Dans un modèle, utilise le helper `raw`. Dans `<ui-bind>`, utilise la commande `html` à la place de `text`. Fais-le uniquement pour du contenu de confiance.\n\n```js\nTangular.render('{{ text }}', { text: '<b>Hi</b>' });       // &lt;b&gt;Hi&lt;/b&gt;\nTangular.render('{{ text | raw }}', { text: '<b>Hi</b>' }); // <b>Hi</b>\n```\n\nPour en savoir plus, consulte [Modèles avec Tangular](../../guides/tangular/).\n\n### Comment afficher une liste ?\n\nUtilise la commande `template` de `<ui-bind>` avec une boucle `foreach`.\n\n```html\n<ui-bind path=\"users\" config=\"template\">\n  <script type=\"text/html\">{{ foreach m in value }}<b>{{ m.name }}</b>{{ end }}</script>\n</ui-bind>\n```\n\nPour en savoir plus, consulte [Modèles avec Tangular](../../guides/tangular/).\n\n## Composants et plugins\n\n### À quel moment peut-on appeler un composant sans risque ?\n\nLes composants démarrent après le chargement de la page : ils n'existent donc pas encore lors de la première exécution de ton script. Attends l'événement `ready`.\n\n```js\nconsole.log(FIND('clock') == null); // true\n\nON('ready', function() {\n  FIND('clock').show();\n});\n```\n\nPour en savoir plus, consulte [Utiliser les composants](../../guides/using-components/).\n\n### Pourquoi la console indique-t-elle qu'un composant est en cours de téléchargement ?\n\nAucune déclaration `COMPONENT()` n'existe pour le nom indiqué dans `<ui-component>` : la bibliothèque essaie donc de le télécharger depuis l'adresse de `DEF.fallback`. Déclare le composant dans ton code, ou fais pointer `DEF.fallback` vers ton propre serveur.\n\nPour en savoir plus, consulte [Utiliser les composants](../../guides/using-components/).\n\n### Que signifie `?` dans un path ?\n\nIl représente le path du plugin le plus proche. Dans le plugin `profile`, `?.name` correspond au path `profile.name`.\n\n```html\n<ui-plugin path=\"profile\">\n  <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nPour en savoir plus, consulte [Plugins](../../guides/plugins/).\n\n### Comment deux plugins communiquent-ils entre eux ?\n\nAppelle une méthode avec `EXEC()`, ou envoie un événement global avec `EMIT()`.\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.add = function(item) {\n    exports.push('items', item);\n  };\n  exports.on('checkout', function() {\n    console.log('checkout', exports.get('items').length);\n  });\n});\n\nPLUGIN('shop', function(exports) {\n  exports.buy = function() {\n    EXEC('cart/add', 'Lamp');\n    EMIT('checkout');\n  };\n});\n```\n\nPour en savoir plus, consulte [Plugins](../../guides/plugins/).\n\n### Quand `destroy` s'exécute-t-il après la suppression d'un élément ?\n\nLa bibliothèque recherche les composants et les plugins supprimés une fois par minute. Appelle `FREE()` pour lancer le nettoyage immédiatement.\n\n```js\n$('#list').empty();\nFREE(); // calls destroy\n```\n\nPour en savoir plus, consulte [Créer des composants](../../guides/creating-components/).\n\n### Pourquoi ne vois-je aucun avertissement dans la console ?\n\nLa plupart des avertissements sont désactivés par défaut. Active-les avec `DEF.warnings`.\n\n```js\nDEF.warnings = true;\nEXEC('missing/run'); // jComponent: The plugin \"missing\" not found.\n```\n\nLa référence [DEF](../../reference/def/) liste les autres réglages.\n\n## Formulaires\n\n### Comment vérifier un formulaire avant de l'envoyer ?\n\n`ERRORS()` renvoie les composants invalides situés sous un path.\n\n```js\nERRORS('form', function(components) {\n  if (!components.length)\n    AJAX('POST /api/contact/', GET('form'), NOOP);\n});\n```\n\nPour en savoir plus, consulte [Formulaires et validation](../../guides/forms/).\n\n### Comment masquer l'erreur tant que l'utilisateur n'a pas touché un champ ?\n\nUn champ obligatoire vide est invalide dès le départ. Affiche le message uniquement quand `config.touched` est défini.\n\n```js\nself.state = function() {\n  self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n};\n```\n\nPour en savoir plus, consulte [Formulaires et validation](../../guides/forms/).\n\n## Applications\n\n### Pourquoi mes liens rechargent-ils la page ?\n\nUn lien simple est géré par le navigateur. Passe les liens à `NAV.clientside()`.\n\n```js\nNAV.clientside('a.link');\n```\n\nPour en savoir plus, consulte [Routage](../../guides/routing/).\n\n### Pourquoi ma route n'est-elle pas appelée ?\n\nVérifie ces trois points :\n\n- Les URL sont comparées en minuscules : une route contenant une majuscule ne correspond donc jamais.\n- Un middleware qui appelle `next(false)` arrête la route.\n- Quand une page s'ouvre directement à l'URL, le serveur doit renvoyer la page de l'application pour cette URL.\n\nPour en savoir plus, consulte [Routage](../../guides/routing/).\n\n### Comment charger un script une seule fois ?\n\nAjoute le flag `@singleton` à l'URL.\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nPour en savoir plus, consulte [Importer du contenu](../../guides/importing/).\n\n### Pourquoi mon `@(text)` n'est-il pas traduit ?\n\nSeul le contenu chargé avec `IMPORT()` ou `<ui-import>` est traduit automatiquement. Traduis les autres chaînes avec `TRANSLATE()`, et charge d'abord le dictionnaire.\n\n```js\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\nTRANSLATE('<button>@(Save)</button>'); // <button>Speichern</button>\n```\n\nPour en savoir plus, consulte [Localisation](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcN61ed61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/faq/faq/","project":"jcomponent-v20","version":"20-015","section":"faq","language":"it","title":"FAQ","summary":"Le risposte alle domande che gli sviluppatori si pongono quando iniziano a usare jComponent.","markdown":"---\ntitle: FAQ\nproject: jComponent V20\nversion: 20.015\nsection: faq\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/faq/faq/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# FAQ\n\n> Le risposte alle domande che gli sviluppatori si pongono quando iniziano a usare jComponent.\n\nRisposte brevi alle domande che emergono per prime. Ogni risposta rimanda alla pagina che spiega l'argomento nel dettaglio.\n\n## Dati e path\n\n### Perché la pagina non si aggiorna quando cambio una variabile?\n\nUna semplice assegnazione non comunica a nessuno la modifica. Scrivi con `SET()`, oppure chiama `UPD()` dopo l'assegnazione.\n\n```html\n<ui-bind path=\"profile.name\" config=\"text\"></ui-bind>\n\n<script>\nwindow.profile = { name: 'Ann' };\n\nprofile.name = 'Bob';     // the page still shows Ann\nUPD('profile.name');      // the page shows Bob\nSET('profile.name', 'Eve'); // the page shows Eve\n</script>\n```\n\nApprofondisci in [Associazione dei dati](../../guides/data-binding/).\n\n### Come eseguo del codice quando un valore cambia?\n\nUsa `WATCH()`. Un osservatore scatta anche per le modifiche nei path sotto o sopra il proprio path.\n\n```js\nWATCH('filter.q', function(value, flags, path) {\n  console.log(path, value);\n});\n\nSET('filter.q', 'lamp'); // filter.q lamp\nSET('filter', { q: 'desk' }); // filter desk\n```\n\nApprofondisci in [Path](../../guides/paths/).\n\n### Dove conservo i valori temporanei?\n\nUn path che inizia con `%` viene memorizzato in `DEF.tmp`, mentre un path che inizia con `*` viene memorizzato nell'oggetto globale `common`.\n\n```js\nSET('%search', 'lamp');\nconsole.log(DEF.tmp.search); // lamp\n\nSET('*theme', 'dark');\nconsole.log(common.theme);   // dark\n```\n\nApprofondisci in [Path](../../guides/paths/).\n\n### Come carico i dati dal server in un path?\n\nPassa il path come ultimo argomento di `AJAX()`. Le associazioni su quel path renderizzano la risposta.\n\n```js\nAJAX('GET /api/users/', 'users');\n```\n\nIl riferimento [Funzioni globali](../../reference/globals/) descrive `AJAX()`.\n\n### Perché un valore appare con i tag HTML come testo?\n\nL'output viene codificato per impostazione predefinita. In un template, usa l'helper `raw`. In `<ui-bind>`, usa il comando `html` al posto di `text`. Fallo solo per i contenuti di cui ti fidi.\n\n```js\nTangular.render('{{ text }}', { text: '<b>Hi</b>' });       // &lt;b&gt;Hi&lt;/b&gt;\nTangular.render('{{ text | raw }}', { text: '<b>Hi</b>' }); // <b>Hi</b>\n```\n\nApprofondisci in [Template con Tangular](../../guides/tangular/).\n\n### Come renderizzo un elenco?\n\nUsa il comando `template` di `<ui-bind>` con un ciclo `foreach`.\n\n```html\n<ui-bind path=\"users\" config=\"template\">\n  <script type=\"text/html\">{{ foreach m in value }}<b>{{ m.name }}</b>{{ end }}</script>\n</ui-bind>\n```\n\nApprofondisci in [Template con Tangular](../../guides/tangular/).\n\n## Componenti e plugin\n\n### Quando posso chiamare un componente in sicurezza?\n\nI componenti si avviano dopo il caricamento della pagina, quindi non esistono ancora durante la prima esecuzione del tuo script. Attendi l'evento `ready`.\n\n```js\nconsole.log(FIND('clock') == null); // true\n\nON('ready', function() {\n  FIND('clock').show();\n});\n```\n\nApprofondisci in [Usare i componenti](../../guides/using-components/).\n\n### Perché la console dice che un componente è in fase di download?\n\nNon esiste una dichiarazione `COMPONENT()` per il nome indicato in `<ui-component>`, quindi la libreria prova a scaricarla dall'indirizzo in `DEF.fallback`. Dichiara il componente nel tuo codice, oppure fai puntare `DEF.fallback` al tuo server.\n\nApprofondisci in [Usare i componenti](../../guides/using-components/).\n\n### Che cosa significa `?` in un path?\n\nRappresenta il path del plugin più vicino. Nel plugin `profile`, `?.name` è il path `profile.name`.\n\n```html\n<ui-plugin path=\"profile\">\n  <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nApprofondisci in [Plugin](../../guides/plugins/).\n\n### Come comunicano tra loro due plugin?\n\nChiama un metodo con `EXEC()`, oppure invia un evento globale con `EMIT()`.\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.add = function(item) {\n    exports.push('items', item);\n  };\n  exports.on('checkout', function() {\n    console.log('checkout', exports.get('items').length);\n  });\n});\n\nPLUGIN('shop', function(exports) {\n  exports.buy = function() {\n    EXEC('cart/add', 'Lamp');\n    EMIT('checkout');\n  };\n});\n```\n\nApprofondisci in [Plugin](../../guides/plugins/).\n\n### Quando viene eseguito `destroy` dopo che rimuovo un elemento?\n\nLa libreria cerca i componenti e i plugin rimossi una volta al minuto. Chiama `FREE()` per eseguire subito la pulizia.\n\n```js\n$('#list').empty();\nFREE(); // calls destroy\n```\n\nApprofondisci in [Creare componenti](../../guides/creating-components/).\n\n### Perché non vedo nessun avviso nella console?\n\nLa maggior parte degli avvisi è disattivata per impostazione predefinita. Attivali con `DEF.warnings`.\n\n```js\nDEF.warnings = true;\nEXEC('missing/run'); // jComponent: The plugin \"missing\" not found.\n```\n\nIl riferimento [DEF](../../reference/def/) elenca le altre impostazioni.\n\n## Moduli\n\n### Come controllo un modulo prima di inviarlo?\n\n`ERRORS()` restituisce i componenti non validi sotto un path.\n\n```js\nERRORS('form', function(components) {\n  if (!components.length)\n    AJAX('POST /api/contact/', GET('form'), NOOP);\n});\n```\n\nApprofondisci in [Moduli e validazione](../../guides/forms/).\n\n### Come nascondo l'errore finché l'utente non ha toccato un campo?\n\nUn campo obbligatorio vuoto è non valido fin dall'inizio. Mostra il messaggio solo quando `config.touched` è impostato.\n\n```js\nself.state = function() {\n  self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n};\n```\n\nApprofondisci in [Moduli e validazione](../../guides/forms/).\n\n## Applicazioni\n\n### Perché i miei link ricaricano la pagina?\n\nUn link semplice viene gestito dal browser. Passa i link a `NAV.clientside()`.\n\n```js\nNAV.clientside('a.link');\n```\n\nApprofondisci in [Routing](../../guides/routing/).\n\n### Perché la mia rotta non viene chiamata?\n\nControlla questi tre punti:\n\n- Gli URL vengono confrontati in minuscolo, quindi una rotta con una lettera maiuscola non corrisponde mai.\n- Un middleware che chiama `next(false)` blocca la rotta.\n- Quando una pagina viene aperta direttamente da un URL, il server deve restituire la pagina dell'applicazione per quell'URL.\n\nApprofondisci in [Routing](../../guides/routing/).\n\n### Come carico uno script una sola volta?\n\nAggiungi il flag `@singleton` all'URL.\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nApprofondisci in [Importare contenuti](../../guides/importing/).\n\n### Perché il mio `@(text)` non viene tradotto?\n\nViene tradotto automaticamente solo il contenuto caricato con `IMPORT()` o `<ui-import>`. Traduci le altre stringhe con `TRANSLATE()` e carica prima il dizionario.\n\n```js\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\nTRANSLATE('<button>@(Save)</button>'); // <button>Speichern</button>\n```\n\nApprofondisci in [Localizzazione](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcN61ed61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/faq/faq/","project":"jcomponent-v20","version":"20-015","section":"faq","language":"sk","title":"Časté otázky","summary":"Odpovede na otázky, ktoré si vývojári kladú, keď začínajú s jComponent.","markdown":"---\ntitle: \"Časté otázky\"\nproject: jComponent V20\nversion: 20.015\nsection: faq\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/faq/faq/\nupdated: 2026-11-18T13:55:29.124Z\n---\n\n# Časté otázky\n\n> Odpovede na otázky, ktoré si vývojári kladú, keď začínajú s jComponent.\n\nKrátke odpovede na otázky, ktoré prichádzajú ako prvé. Každá odpoveď odkazuje na stránku, ktorá tému vysvetľuje podrobne.\n\n## Dáta a paths\n\n### Prečo sa stránka neaktualizuje, keď zmením premennú?\n\nObyčajné priradenie o zmene nikoho neinformuje. Zapisuj pomocou `SET()` alebo po priradení zavolaj `UPD()`.\n\n```html\n<ui-bind path=\"profile.name\" config=\"text\"></ui-bind>\n\n<script>\nwindow.profile = { name: 'Ann' };\n\nprofile.name = 'Bob';     // the page still shows Ann\nUPD('profile.name');      // the page shows Bob\nSET('profile.name', 'Eve'); // the page shows Eve\n</script>\n```\n\nViac nájdeš v časti [Dátová väzba](../../guides/data-binding/).\n\n### Ako spustím kód, keď sa zmení hodnota?\n\nPouži `WATCH()`. Sledovač sa spustí aj pri zmenách v paths pod jeho vlastným path alebo nad ním.\n\n```js\nWATCH('filter.q', function(value, flags, path) {\n  console.log(path, value);\n});\n\nSET('filter.q', 'lamp'); // filter.q lamp\nSET('filter', { q: 'desk' }); // filter desk\n```\n\nViac nájdeš v časti [Paths](../../guides/paths/).\n\n### Kde mám uchovávať dočasné hodnoty?\n\nPath, ktorý sa začína znakom `%`, sa ukladá do `DEF.tmp` a path, ktorý sa začína znakom `*`, sa ukladá do globálneho objektu `common`.\n\n```js\nSET('%search', 'lamp');\nconsole.log(DEF.tmp.search); // lamp\n\nSET('*theme', 'dark');\nconsole.log(common.theme);   // dark\n```\n\nViac nájdeš v časti [Paths](../../guides/paths/).\n\n### Ako načítam dáta zo servera na path?\n\nOdovzdaj path ako posledný argument `AJAX()`. Väzby na tomto path vykreslia odpoveď.\n\n```js\nAJAX('GET /api/users/', 'users');\n```\n\n`AJAX()` opisuje referencia [Globálne funkcie](../../reference/globals/).\n\n### Prečo sa hodnota zobrazuje so značkami HTML ako text?\n\nVýstup sa predvolene kóduje. V šablóne použi helper `raw`. V `<ui-bind>` použi namiesto `text` príkaz `html`. Rob to iba pri obsahu, ktorému dôveruješ.\n\n```js\nTangular.render('{{ text }}', { text: '<b>Hi</b>' });       // &lt;b&gt;Hi&lt;/b&gt;\nTangular.render('{{ text | raw }}', { text: '<b>Hi</b>' }); // <b>Hi</b>\n```\n\nViac nájdeš v časti [Šablóny s Tangularom](../../guides/tangular/).\n\n### Ako vykreslím zoznam?\n\nPouži príkaz `template` elementu `<ui-bind>` s cyklom `foreach`.\n\n```html\n<ui-bind path=\"users\" config=\"template\">\n  <script type=\"text/html\">{{ foreach m in value }}<b>{{ m.name }}</b>{{ end }}</script>\n</ui-bind>\n```\n\nViac nájdeš v časti [Šablóny s Tangularom](../../guides/tangular/).\n\n## Komponenty a pluginy\n\n### Kedy môžem komponent bezpečne zavolať?\n\nKomponenty sa spúšťajú po načítaní stránky, takže pri prvom behu tvojho skriptu ešte neexistujú. Počkaj na udalosť `ready`.\n\n```js\nconsole.log(FIND('clock') == null); // true\n\nON('ready', function() {\n  FIND('clock').show();\n});\n```\n\nViac nájdeš v časti [Používanie komponentov](../../guides/using-components/).\n\n### Prečo konzola hlási, že sa sťahuje komponent?\n\nPre názov v `<ui-component>` neexistuje deklarácia `COMPONENT()`, preto sa ho knižnica pokúša stiahnuť z adresy v `DEF.fallback`. Deklaruj komponent vo svojom kóde alebo nasmeruj `DEF.fallback` na vlastný server.\n\nViac nájdeš v časti [Používanie komponentov](../../guides/using-components/).\n\n### Čo znamená `?` v path?\n\nZastupuje path najbližšieho pluginu. V plugine `profile` je `?.name` path `profile.name`.\n\n```html\n<ui-plugin path=\"profile\">\n  <ui-bind path=\"?.name\" config=\"text\"></ui-bind>\n</ui-plugin>\n```\n\nViac nájdeš v časti [Pluginy](../../guides/plugins/).\n\n### Ako spolu komunikujú dva pluginy?\n\nZavolaj metódu pomocou `EXEC()` alebo pošli globálnu udalosť pomocou `EMIT()`.\n\n```js\nPLUGIN('cart', function(exports) {\n  exports.add = function(item) {\n    exports.push('items', item);\n  };\n  exports.on('checkout', function() {\n    console.log('checkout', exports.get('items').length);\n  });\n});\n\nPLUGIN('shop', function(exports) {\n  exports.buy = function() {\n    EXEC('cart/add', 'Lamp');\n    EMIT('checkout');\n  };\n});\n```\n\nViac nájdeš v časti [Pluginy](../../guides/plugins/).\n\n### Kedy sa spustí `destroy` po odstránení elementu?\n\nKnižnica hľadá odstránené komponenty a pluginy raz za minútu. Ak chceš čistenie spustiť hneď, zavolaj `FREE()`.\n\n```js\n$('#list').empty();\nFREE(); // calls destroy\n```\n\nViac nájdeš v časti [Vytváranie komponentov](../../guides/creating-components/).\n\n### Prečo v konzole nevidím žiadne upozornenia?\n\nVäčšina upozornení je predvolene vypnutá. Zapneš ich pomocou `DEF.warnings`.\n\n```js\nDEF.warnings = true;\nEXEC('missing/run'); // jComponent: The plugin \"missing\" not found.\n```\n\nOstatné nastavenia uvádza referencia [DEF](../../reference/def/).\n\n## Formuláre\n\n### Ako skontrolujem formulár pred odoslaním?\n\n`ERRORS()` vráti neplatné komponenty pod daným path.\n\n```js\nERRORS('form', function(components) {\n  if (!components.length)\n    AJAX('POST /api/contact/', GET('form'), NOOP);\n});\n```\n\nViac nájdeš v časti [Formuláre a validácia](../../guides/forms/).\n\n### Ako skryjem chybu, kým sa používateľ poľa nedotkne?\n\nPovinné prázdne pole je neplatné od začiatku. Správu zobraz až vtedy, keď je nastavené `config.touched`.\n\n```js\nself.state = function() {\n  self.find('em').text(config.touched && config.invalid ? config.invalid : '');\n};\n```\n\nViac nájdeš v časti [Formuláre a validácia](../../guides/forms/).\n\n## Aplikácie\n\n### Prečo moje odkazy znova načítavajú stránku?\n\nObyčajný odkaz spracuje prehliadač. Odovzdaj odkazy do `NAV.clientside()`.\n\n```js\nNAV.clientside('a.link');\n```\n\nViac nájdeš v časti [Smerovanie](../../guides/routing/).\n\n### Prečo sa moja trasa nezavolá?\n\nSkontroluj tieto tri veci:\n\n- Adresy URL sa porovnávajú malými písmenami, takže trasa s veľkým písmenom nikdy nezodpovedá.\n- Middleware, ktorý zavolá `next(false)`, trasu zastaví.\n- Keď sa stránka otvorí priamo na danej adrese URL, server musí pre túto adresu vrátiť stránku aplikácie.\n\nViac nájdeš v časti [Smerovanie](../../guides/routing/).\n\n### Ako načítam skript iba raz?\n\nPridaj k adrese URL flag `@singleton`.\n\n```js\nIMPORT('/js/charts.js @singleton', function() {\n  console.log('ready to use');\n});\n```\n\nViac nájdeš v časti [Import obsahu](../../guides/importing/).\n\n### Prečo sa môj `@(text)` nepreložil?\n\nAutomaticky sa prekladá iba obsah načítaný pomocou `IMPORT()` alebo `<ui-import>`. Ostatné reťazce prelož pomocou `TRANSLATE()` a najprv načítaj slovník.\n\n```js\nLOCALIZE(HASH('Save').toString(36) + ' : Speichern');\nTRANSLATE('<button>@(Save)</button>'); // <button>Speichern</button>\n```\n\nViac nájdeš v časti [Lokalizácia](../../guides/localization/).\n","entries":[],"license":"MIT","updated":"2026-11-18T13:55:29.124Z"}
{"id":"JamcN31cd61f","url":"https://totaljs.es/docs/jcomponent-v20/20-015/changelog/20-015/","project":"jcomponent-v20","version":"20-015","section":"changelog","language":"en","title":"20.015","summary":"The official list of changes of jComponent, up to release 20.015.","markdown":"---\ntitle: 20.015\nproject: jComponent V20\nversion: 20.015\nsection: changelog\nlanguage: en\nlicense: MIT\nurl: https://totaljs.es/docs/jcomponent-v20/20-015/changelog/20-015/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# 20.015\n\n> The official list of changes of jComponent, up to release 20.015.\n\n## 20.015\n\n- added missing `plugin.unwatch(path, [callback])` method\n- added `abort` and `timeout` handling to the `AJAX()` method\n- added error handling for scripts and styles to the `IMPORT()` method (the callback is executed even if the import fails)\n- improved performance of `SET()` (compiled setters are cached)\n- improved performance of `Array.prototype.quicksort()` (shared `Intl.Collator` instance)\n- improved `inDOM()` by using `element.isConnected`\n- improved `COOKIES.set()`, the `expire` argument is optional and it doesn't modify `NOW`\n- __changed__: `Number.prototype.format()` rounds decimals instead of cutting them\n- __changed__: `Date.prototype.format('iso')` returns a real UTC date\n- __changed__: `<ui-bind>` commands `html`, `text`, `value`, `title`, `href` and `src` render `0` instead of the `empty` value\n- __changed__: `EXTENSION()` executes the callback for existing instances with the same arguments as for new instances `(instance, config, cls)`\n- __changed__: `AJAX()` evaluates a response as an error from the status code `400` (before `399`)\n- __changed__: `WAIT(path, callback)` waits for a truthy value\n- fixed collisions in the cache of paths (different paths could return the same value)\n- fixed `SET(path, function(value))`\n- fixed `CMD()`, `plugin.cmd()` and `$(element).CMD()` methods\n- fixed `OFF(name, callback)` for unregistered events\n- fixed emitting of events when a handler unregisters itself\n- fixed infinite loop in the `autofocus()` method\n- fixed infinite loop in the `TRANSLATE()` method with unclosed `@(` markup\n- fixed `$` characters in translations in the `TRANSLATE()` method\n- fixed `CONFIG('.path', config)` for components without a path\n- fixed counting of pending elements for the `ready` event\n- fixed `?1|` (parent plugin) in paths\n- fixed `plugin.watch()` with multiple paths `path1 + path2`\n- fixed `plugin.set(object)`\n- fixed `plugin.modified` property\n- fixed `component.unwatch()` (it affected `component.datasource()` too)\n- fixed `component.autofill()` and processing of auto-filled values\n- fixed `component.setPath()` with the `?` character\n- fixed `component.caniuse()` with the `|` separator\n- fixed the previous value in the `component.configure(key, value, init, prev)` delegate\n- fixed `checkbox` in the default `component.setter()`\n- fixed internal `component.$setter()` without flags\n- fixed duplicated `component.attr()` declaration\n- fixed multiple commands `html+title` in `<ui-bind>`\n- fixed using of a previous value in `<ui-bind>` when a command throws an error\n- fixed arguments in `$(element).SEEX()`\n- fixed double execution of callbacks in cached `AJAX()` requests\n- fixed `opt.respond()` in the `request` event\n- fixed sending of `String` data in the `AJAX()` method\n- fixed implicit global variable `arr` in the `AJAX()` response\n- fixed `encrypt` argument in the `STRINGIFY()` method\n- fixed restoring of values in the `CACHEPATH()` method\n- fixed HTTP method parsing with `!` in the `CLINIT()` method\n- fixed a possible interval leak in the `WAIT()` method\n- fixed `COOKIES.set()` with a number of days and `COOKIES.get()` for values with the `=` character\n- fixed `localStorage` errors in the `BLOCKED()` method and in the initialization\n- fixed 12-hour clock (`hh`, `h`, `am/pm`) in `String.prototype.parseDate()` and `Date.prototype.format()`\n- fixed a missing day and milliseconds in `String.prototype.parseDate()`\n- fixed apostrophes and environment variables in `Date.prototype.format()`\n- fixed `Number.prototype.add()` with a number\n- fixed `Number.prototype.format()` with exponential notation\n- fixed `Number.prototype.pluralize()` without all arguments\n- fixed `String.prototype.parseExpire()` without a unit\n- fixed `String.prototype.parseSource()` with the `number` type\n- fixed `Array.prototype.findValue()` with cache\n- fixed sorting of different data types by the same key in `Array.prototype.quicksort()`\n- fixed short HEX colors in the `APPEARANCE()` method\n- fixed `VISIBLE()` for elements placed directly in the `<body>`\n- fixed checking of window size in the internal resize handler\n- fixed `resize` handler, animations and `destroy()` in the `SCROLLBAR()`\n\n## 20.014\n\n- added missing `ENCRYPT(str, key, type)` method\n- added missing `DECRYPT(hex, key, type)` method\n\n## 20.013\n\n- fixed `Number.prototype.round()`\n- added missing `CMD(name, [a], [b], [c], [d])` method\n- added `EXE()` alias to `EXEC()`\n\n## 20.012\n\n- added missing `component.$ready` property for several components (j-Layout, j-Windows, etc.) that implement it\n- added missing `API(url, name, data, callback, [scope])` method\n\n## 20.011\n\n- fixed `SYNC` keyword in the `AJAX()` method\n- added a missing `onprogress` handler to the `AJAX()` and `UPLOAD()` method\n\n## 20.009\n\n- jComponent initialization for Samsumg mobile\n- added missing `COOKIES`\n\n## 20.008\n\n- added support for `@method_name` for the `component.EXEC()` method (it executes parent component method)\n- renamed the `CSS()` method to the `STYLE()`\n- added `window.jc_globals = { ... }` object for disabling jComponent globals method:\n\t- it only supports one method: `CSS: false`, which disables the registration of the `CSS()` method\n- fixed the `target` option for the `ui-import` element\n- fixed the `class` option for the `ui-import` element\n- fixed the `init` option for the `ui-import` element\n- fixed `ui-bind` with custom `template` selector\n- fixed the virtual DOM operator `-->` with two dashes\n\n## 20.007\n\n- fixed `plugin.get()` method\n- fixed adding `DEF.version` to all AJAX `.html` requests\n- fixed adding `DEF.language` to all AJAX  requests\n- improved `ui-bind` by adding:\n\t- compatibility with v19 with only visible elements to be rendered\n\t- `forcerender` command that allows rendering in hidden elements\n- fixed `NEWUIBIND()` method\n- fixed internal `.exec` functionality\n- improved downloading components from CDN\n- added missing `plugin.off()` and `component.off()` method\n- extended `component.autobind20([delay], [realtimebinding])` method by adding two arguments\n- added missing `component.closest(selector)` method\n- fixed functionality with dynamic plugins\n- fixed plugin `class` config option\n- improved loading plugin instance\n- fixed functionality in the `CLRELOAD()` method\n- fixed evaluating code lists in paths `path #codelist1 #codelist2`\n- added support for flags in the `CMD()` method\n- fixed importing dependencies defined in components\n- added global variable `REPO`\n\n## 20.006\n\n- added missing `Date.toUTC([ticks])` method\n- fixed a warning information about downloading UI components from CDN\n- fixed appending `array` in the `plugin.push()` method\n- added TAPI alternative:\n\t- `DEF.pipe = '/total-api-endpoint/'`\n\t- `plugin.pipe(name, [data], [path|callback])`\n\t- `PIPE(name, [data], [path|callback])`\n- improved `Thelpers.empty(value, [def], [raw])` by adding `raw` argument\n- added old `knockknock` event\n- added `native: Boolean` option to the custom `SCROLLBAR()`\n- fixed links with `@` in the `IMPORT()` method\n- fixed \"complex\" paths in plugins\n- fixed parsing of empty keys when using `String.parseConfig()`\n\n## 20.005\n\n- fixed obtaining plugin path in the form `?1/something` or `?1.something`\n\n## 20.004\n\n- added `component.setPath(path)` method\n- added `$(element).scrollbar()` for finding the closest custom scrollbar instance\n- added a new attribute `source=\"URL address\"` for `ui-component` element\n- extended `component.bind()` by adding `notify` flag (it notifies all components within the path about the component state)\n\n## 20.003\n\n- fixed cache in the `AJAX()` method\n- added `Array.group(key)` method\n\n## 20.001\n\n- fixed `EXEC()` calls\n- fixed `CLINIT()` with `extend` argument\n- fixed `track` option in `<ui-bind>`\n- fixed `format` option in `<ui-bind>`\n- fixed reconfiguring unintialized components in `<ui-bind>`\n- extended jQuery by adding `$.autofocus([selector])` method\n- fixed unexpected removing of custom scrollbars\n- fixed component's dependencies\n- added missing `component.push()` method\n- fixed `enabled` and `disabled` of `<ui-bind>` commands for HTML controls\n- fixed `PREF` functionality\n- fixed `@singleton` in the `IMPORT()` method\n- added missing `UNAUTHORIZED()` method\n- increased delay after importing 3rd party content via the `IMPORT()` method\n- fixed `real-time` binding values in the `component.autobind20()` method\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcN31cd61f-de","url":"https://totaljs.es/docs/de/jcomponent-v20/20-015/changelog/20-015/","project":"jcomponent-v20","version":"20-015","section":"changelog","language":"de","title":"20.015","summary":"Die offizielle Liste der Änderungen an jComponent bis zum Release 20.015.","markdown":"---\ntitle: 20.015\nproject: jComponent V20\nversion: 20.015\nsection: changelog\nlanguage: de\nlicense: MIT\nurl: https://totaljs.es/docs/de/jcomponent-v20/20-015/changelog/20-015/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# 20.015\n\n> Die offizielle Liste der Änderungen an jComponent bis zum Release 20.015.\n\n## 20.015\n\n- fehlende Methode `plugin.unwatch(path, [callback])` hinzugefügt\n- Behandlung von `abort` und `timeout` in der Methode `AJAX()` hinzugefügt\n- Fehlerbehandlung für Skripte und Styles in der Methode `IMPORT()` hinzugefügt (der Callback wird auch ausgeführt, wenn der Import fehlschlägt)\n- Performance von `SET()` verbessert (kompilierte Setter werden im Cache gehalten)\n- Performance von `Array.prototype.quicksort()` verbessert (gemeinsame `Intl.Collator`-Instanz)\n- `inDOM()` durch die Verwendung von `element.isConnected` verbessert\n- `COOKIES.set()` verbessert: Das Argument `expire` ist optional, und `NOW` wird nicht mehr verändert\n- __geändert__: `Number.prototype.format()` rundet Dezimalstellen, statt sie abzuschneiden\n- __geändert__: `Date.prototype.format('iso')` gibt ein echtes UTC-Datum zurück\n- __geändert__: Die `<ui-bind>`-Befehle `html`, `text`, `value`, `title`, `href` und `src` rendern `0` statt des `empty`-Werts\n- __geändert__: `EXTENSION()` führt den Callback für vorhandene Instanzen mit denselben Argumenten aus wie für neue Instanzen `(instance, config, cls)`\n- __geändert__: `AJAX()` wertet eine Antwort ab dem Statuscode `400` als Fehler (vorher `399`)\n- __geändert__: `WAIT(path, callback)` wartet auf einen truthy Wert\n- Kollisionen im Cache der Paths behoben (verschiedene Paths konnten denselben Wert zurückgeben)\n- `SET(path, function(value))` behoben\n- Methoden `CMD()`, `plugin.cmd()` und `$(element).CMD()` behoben\n- `OFF(name, callback)` für nicht registrierte Events behoben\n- Auslösen von Events behoben, wenn sich ein Handler selbst abmeldet\n- Endlosschleife in der Methode `autofocus()` behoben\n- Endlosschleife in der Methode `TRANSLATE()` bei nicht geschlossenem `@(`-Markup behoben\n- `$`-Zeichen in Übersetzungen in der Methode `TRANSLATE()` behoben\n- `CONFIG('.path', config)` für Komponenten ohne Path behoben\n- Zählung ausstehender Elemente für das Event `ready` behoben\n- `?1|` (übergeordnetes Plugin) in Paths behoben\n- `plugin.watch()` mit mehreren Paths `path1 + path2` behoben\n- `plugin.set(object)` behoben\n- Eigenschaft `plugin.modified` behoben\n- `component.unwatch()` behoben (es betraf auch `component.datasource()`)\n- `component.autofill()` und die Verarbeitung automatisch ausgefüllter Werte behoben\n- `component.setPath()` mit dem Zeichen `?` behoben\n- `component.caniuse()` mit dem Trennzeichen `|` behoben\n- vorherigen Wert im Delegate `component.configure(key, value, init, prev)` behoben\n- `checkbox` im Standard-`component.setter()` behoben\n- internes `component.$setter()` ohne Flags behoben\n- doppelte Deklaration von `component.attr()` behoben\n- mehrere Befehle `html+title` in `<ui-bind>` behoben\n- Verwendung eines vorherigen Werts in `<ui-bind>` behoben, wenn ein Befehl einen Fehler wirft\n- Argumente in `$(element).SEEX()` behoben\n- doppelte Ausführung von Callbacks bei gecachten `AJAX()`-Anfragen behoben\n- `opt.respond()` im Event `request` behoben\n- Senden von `String`-Daten in der Methode `AJAX()` behoben\n- implizite globale Variable `arr` in der Antwort von `AJAX()` behoben\n- Argument `encrypt` in der Methode `STRINGIFY()` behoben\n- Wiederherstellen von Werten in der Methode `CACHEPATH()` behoben\n- Parsen der HTTP-Methode mit `!` in der Methode `CLINIT()` behoben\n- mögliches Interval-Leak in der Methode `WAIT()` behoben\n- `COOKIES.set()` mit einer Anzahl von Tagen und `COOKIES.get()` für Werte mit dem Zeichen `=` behoben\n- `localStorage`-Fehler in der Methode `BLOCKED()` und bei der Initialisierung behoben\n- 12-Stunden-Format (`hh`, `h`, `am/pm`) in `String.prototype.parseDate()` und `Date.prototype.format()` behoben\n- fehlenden Tag und Millisekunden in `String.prototype.parseDate()` behoben\n- Apostrophe und Umgebungsvariablen in `Date.prototype.format()` behoben\n- `Number.prototype.add()` mit einer Zahl behoben\n- `Number.prototype.format()` mit Exponentialschreibweise behoben\n- `Number.prototype.pluralize()` ohne alle Argumente behoben\n- `String.prototype.parseExpire()` ohne Einheit behoben\n- `String.prototype.parseSource()` mit dem Typ `number` behoben\n- `Array.prototype.findValue()` mit Cache behoben\n- Sortierung verschiedener Datentypen nach demselben Schlüssel in `Array.prototype.quicksort()` behoben\n- kurze HEX-Farben in der Methode `APPEARANCE()` behoben\n- `VISIBLE()` für Elemente direkt im `<body>` behoben\n- Prüfung der Fenstergröße im internen Resize-Handler behoben\n- `resize`-Handler, Animationen und `destroy()` in `SCROLLBAR()` behoben\n\n## 20.014\n\n- fehlende Methode `ENCRYPT(str, key, type)` hinzugefügt\n- fehlende Methode `DECRYPT(hex, key, type)` hinzugefügt\n\n## 20.013\n\n- `Number.prototype.round()` behoben\n- fehlende Methode `CMD(name, [a], [b], [c], [d])` hinzugefügt\n- Alias `EXE()` für `EXEC()` hinzugefügt\n\n## 20.012\n\n- fehlende Eigenschaft `component.$ready` für mehrere Komponenten (j-Layout, j-Windows usw.) hinzugefügt, die sie implementieren\n- fehlende Methode `API(url, name, data, callback, [scope])` hinzugefügt\n\n## 20.011\n\n- Schlüsselwort `SYNC` in der Methode `AJAX()` behoben\n- fehlenden Handler `onprogress` in den Methoden `AJAX()` und `UPLOAD()` hinzugefügt\n\n## 20.009\n\n- jComponent-Initialisierung für Samsung-Mobilgeräte\n- fehlendes `COOKIES` hinzugefügt\n\n## 20.008\n\n- Unterstützung für `@method_name` in der Methode `component.EXEC()` hinzugefügt (führt eine Methode der übergeordneten Komponente aus)\n- Methode `CSS()` in `STYLE()` umbenannt\n- Objekt `window.jc_globals = { ... }` zum Deaktivieren globaler Methoden von jComponent hinzugefügt:\n\t- es unterstützt nur eine Methode: `CSS: false`, das die Registrierung der Methode `CSS()` deaktiviert\n- Option `target` für das Element `ui-import` behoben\n- Option `class` für das Element `ui-import` behoben\n- Option `init` für das Element `ui-import` behoben\n- `ui-bind` mit eigenem `template`-Selektor behoben\n- virtuellen DOM-Operator `-->` mit zwei Bindestrichen behoben\n\n## 20.007\n\n- Methode `plugin.get()` behoben\n- Hinzufügen von `DEF.version` zu allen AJAX-Anfragen für `.html` behoben\n- Hinzufügen von `DEF.language` zu allen AJAX-Anfragen behoben\n- `ui-bind` verbessert durch:\n\t- Kompatibilität mit v19, bei der nur sichtbare Elemente gerendert werden\n\t- Befehl `forcerender`, der das Rendern in verborgenen Elementen erlaubt\n- Methode `NEWUIBIND()` behoben\n- interne `.exec`-Funktionalität behoben\n- Herunterladen von Komponenten vom CDN verbessert\n- fehlende Methoden `plugin.off()` und `component.off()` hinzugefügt\n- Methode `component.autobind20([delay], [realtimebinding])` um zwei Argumente erweitert\n- fehlende Methode `component.closest(selector)` hinzugefügt\n- Funktionalität mit dynamischen Plugins behoben\n- Config-Option `class` von Plugins behoben\n- Laden der Plugin-Instanz verbessert\n- Funktionalität der Methode `CLRELOAD()` behoben\n- Auswertung von Codelisten in Paths `path #codelist1 #codelist2` behoben\n- Unterstützung für Flags in der Methode `CMD()` hinzugefügt\n- Import von in Komponenten definierten Abhängigkeiten behoben\n- globale Variable `REPO` hinzugefügt\n\n## 20.006\n\n- fehlende Methode `Date.toUTC([ticks])` hinzugefügt\n- Warnhinweis zum Herunterladen von UI-Komponenten vom CDN behoben\n- Anhängen eines `array` in der Methode `plugin.push()` behoben\n- TAPI-Alternative hinzugefügt:\n\t- `DEF.pipe = '/total-api-endpoint/'`\n\t- `plugin.pipe(name, [data], [path|callback])`\n\t- `PIPE(name, [data], [path|callback])`\n- `Thelpers.empty(value, [def], [raw])` durch das Argument `raw` verbessert\n- altes Event `knockknock` hinzugefügt\n- Option `native: Boolean` für das benutzerdefinierte `SCROLLBAR()` hinzugefügt\n- Links mit `@` in der Methode `IMPORT()` behoben\n- \"komplexe\" Paths in Plugins behoben\n- Parsen leerer Schlüssel bei Verwendung von `String.parseConfig()` behoben\n\n## 20.005\n\n- Ermittlung des Plugin-Paths in der Form `?1/something` oder `?1.something` behoben\n\n## 20.004\n\n- Methode `component.setPath(path)` hinzugefügt\n- `$(element).scrollbar()` zum Finden der nächsten Instanz einer benutzerdefinierten Scrollbar hinzugefügt\n- neues Attribut `source=\"URL address\"` für das Element `ui-component` hinzugefügt\n- `component.bind()` um das Flag `notify` erweitert (es benachrichtigt alle Komponenten innerhalb des Paths über den Zustand der Komponente)\n\n## 20.003\n\n- Cache in der Methode `AJAX()` behoben\n- Methode `Array.group(key)` hinzugefügt\n\n## 20.001\n\n- `EXEC()`-Aufrufe behoben\n- `CLINIT()` mit dem Argument `extend` behoben\n- Option `track` in `<ui-bind>` behoben\n- Option `format` in `<ui-bind>` behoben\n- Neukonfiguration nicht initialisierter Komponenten in `<ui-bind>` behoben\n- jQuery um die Methode `$.autofocus([selector])` erweitert\n- unerwartetes Entfernen benutzerdefinierter Scrollbars behoben\n- Abhängigkeiten von Komponenten behoben\n- fehlende Methode `component.push()` hinzugefügt\n- `enabled` und `disabled` der `<ui-bind>`-Befehle für HTML-Formularelemente behoben\n- Funktionalität von `PREF` behoben\n- `@singleton` in der Methode `IMPORT()` behoben\n- fehlende Methode `UNAUTHORIZED()` hinzugefügt\n- Verzögerung nach dem Import von Drittanbieter-Inhalten über die Methode `IMPORT()` erhöht\n- `real-time`-Bindung von Werten in der Methode `component.autobind20()` behoben\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcN31cd61f-es","url":"https://totaljs.es/docs/es/jcomponent-v20/20-015/changelog/20-015/","project":"jcomponent-v20","version":"20-015","section":"changelog","language":"es","title":"20.015","summary":"La lista oficial de cambios de jComponent, hasta la versión 20.015.","markdown":"---\ntitle: 20.015\nproject: jComponent V20\nversion: 20.015\nsection: changelog\nlanguage: es\nlicense: MIT\nurl: https://totaljs.es/docs/es/jcomponent-v20/20-015/changelog/20-015/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# 20.015\n\n> La lista oficial de cambios de jComponent, hasta la versión 20.015.\n\n## 20.015\n\n- añadido el método `plugin.unwatch(path, [callback])` que faltaba\n- añadida la gestión de `abort` y `timeout` en el método `AJAX()`\n- añadida la gestión de errores de scripts y estilos en el método `IMPORT()` (el callback se ejecuta aunque la importación falle)\n- mejorado el rendimiento de `SET()` (los setters compilados se guardan en caché)\n- mejorado el rendimiento de `Array.prototype.quicksort()` (instancia compartida de `Intl.Collator`)\n- mejorado `inDOM()` usando `element.isConnected`\n- mejorado `COOKIES.set()`: el argumento `expire` es opcional y no modifica `NOW`\n- __cambiado__: `Number.prototype.format()` redondea los decimales en lugar de recortarlos\n- __cambiado__: `Date.prototype.format('iso')` devuelve una fecha UTC real\n- __cambiado__: los comandos `html`, `text`, `value`, `title`, `href` y `src` de `<ui-bind>` renderizan `0` en lugar del valor de `empty`\n- __cambiado__: `EXTENSION()` ejecuta el callback de las instancias existentes con los mismos argumentos que el de las instancias nuevas `(instance, config, cls)`\n- __cambiado__: `AJAX()` considera una respuesta como error a partir del código de estado `400` (antes `399`)\n- __cambiado__: `WAIT(path, callback)` espera un valor verdadero\n- corregidas las colisiones en la caché de paths (paths distintos podían devolver el mismo valor)\n- corregido `SET(path, function(value))`\n- corregidos los métodos `CMD()`, `plugin.cmd()` y `$(element).CMD()`\n- corregido `OFF(name, callback)` con eventos no registrados\n- corregida la emisión de eventos cuando un manejador se da de baja a sí mismo\n- corregido un bucle infinito en el método `autofocus()`\n- corregido un bucle infinito en el método `TRANSLATE()` con la marca `@(` sin cerrar\n- corregidos los caracteres `$` en las traducciones del método `TRANSLATE()`\n- corregido `CONFIG('.path', config)` con componentes sin path\n- corregido el recuento de elementos pendientes del evento `ready`\n- corregido `?1|` (plugin padre) en los paths\n- corregido `plugin.watch()` con varios paths `path1 + path2`\n- corregido `plugin.set(object)`\n- corregida la propiedad `plugin.modified`\n- corregido `component.unwatch()` (también afectaba a `component.datasource()`)\n- corregidos `component.autofill()` y el procesamiento de los valores autorrellenados\n- corregido `component.setPath()` con el carácter `?`\n- corregido `component.caniuse()` con el separador `|`\n- corregido el valor anterior en el delegado `component.configure(key, value, init, prev)`\n- corregido `checkbox` en el `component.setter()` predeterminado\n- corregido el `component.$setter()` interno sin flags\n- corregida la declaración duplicada de `component.attr()`\n- corregidos varios comandos `html+title` en `<ui-bind>`\n- corregido el uso de un valor anterior en `<ui-bind>` cuando un comando lanza un error\n- corregidos los argumentos de `$(element).SEEX()`\n- corregida la doble ejecución de callbacks en las peticiones `AJAX()` en caché\n- corregido `opt.respond()` en el evento `request`\n- corregido el envío de datos `String` en el método `AJAX()`\n- corregida la variable global implícita `arr` en la respuesta de `AJAX()`\n- corregido el argumento `encrypt` del método `STRINGIFY()`\n- corregida la restauración de valores en el método `CACHEPATH()`\n- corregido el análisis del método HTTP con `!` en el método `CLINIT()`\n- corregida una posible fuga de intervalos en el método `WAIT()`\n- corregido `COOKIES.set()` con un número de días y `COOKIES.get()` con valores que contienen el carácter `=`\n- corregidos los errores de `localStorage` en el método `BLOCKED()` y en la inicialización\n- corregido el formato de 12 horas (`hh`, `h`, `am/pm`) en `String.prototype.parseDate()` y `Date.prototype.format()`\n- corregidos un día que faltaba y los milisegundos en `String.prototype.parseDate()`\n- corregidos los apóstrofos y las variables de entorno en `Date.prototype.format()`\n- corregido `Number.prototype.add()` con un número\n- corregido `Number.prototype.format()` con notación exponencial\n- corregido `Number.prototype.pluralize()` sin todos los argumentos\n- corregido `String.prototype.parseExpire()` sin unidad\n- corregido `String.prototype.parseSource()` con el tipo `number`\n- corregido `Array.prototype.findValue()` con caché\n- corregida la ordenación de distintos tipos de datos por la misma clave en `Array.prototype.quicksort()`\n- corregidos los colores HEX cortos en el método `APPEARANCE()`\n- corregido `VISIBLE()` con elementos colocados directamente en el `<body>`\n- corregida la comprobación del tamaño de la ventana en el manejador interno de redimensionado\n- corregidos el manejador `resize`, las animaciones y `destroy()` en `SCROLLBAR()`\n\n## 20.014\n\n- añadido el método `ENCRYPT(str, key, type)` que faltaba\n- añadido el método `DECRYPT(hex, key, type)` que faltaba\n\n## 20.013\n\n- corregido `Number.prototype.round()`\n- añadido el método `CMD(name, [a], [b], [c], [d])` que faltaba\n- añadido el alias `EXE()` de `EXEC()`\n\n## 20.012\n\n- añadida la propiedad `component.$ready` que faltaba en varios componentes (j-Layout, j-Windows, etc.) que la implementan\n- añadido el método `API(url, name, data, callback, [scope])` que faltaba\n\n## 20.011\n\n- corregida la palabra clave `SYNC` en el método `AJAX()`\n- añadido el manejador `onprogress` que faltaba en los métodos `AJAX()` y `UPLOAD()`\n\n## 20.009\n\n- inicialización de jComponent en móviles Samsung\n- añadido `COOKIES`, que faltaba\n\n## 20.008\n\n- añadida la compatibilidad con `@method_name` en el método `component.EXEC()` (ejecuta el método del componente padre)\n- renombrado el método `CSS()` a `STYLE()`\n- añadido el objeto `window.jc_globals = { ... }` para desactivar métodos globales de jComponent:\n\t- solo admite un método: `CSS: false`, que desactiva el registro del método `CSS()`\n- corregida la opción `target` del elemento `ui-import`\n- corregida la opción `class` del elemento `ui-import`\n- corregida la opción `init` del elemento `ui-import`\n- corregido `ui-bind` con un selector `template` personalizado\n- corregido el operador del DOM virtual `-->` con dos guiones\n\n## 20.007\n\n- corregido el método `plugin.get()`\n- corregida la adición de `DEF.version` a todas las peticiones AJAX de `.html`\n- corregida la adición de `DEF.language` a todas las peticiones AJAX\n- mejorado `ui-bind` con:\n\t- compatibilidad con v19 para renderizar solo los elementos visibles\n\t- el comando `forcerender`, que permite renderizar en elementos ocultos\n- corregido el método `NEWUIBIND()`\n- corregida la funcionalidad interna de `.exec`\n- mejorada la descarga de componentes desde el CDN\n- añadidos los métodos `plugin.off()` y `component.off()` que faltaban\n- ampliado el método `component.autobind20([delay], [realtimebinding])` con dos argumentos\n- añadido el método `component.closest(selector)` que faltaba\n- corregida la funcionalidad de los plugins dinámicos\n- corregida la opción de configuración `class` de los plugins\n- mejorada la carga de la instancia del plugin\n- corregida la funcionalidad del método `CLRELOAD()`\n- corregida la evaluación de las listas de códigos en paths `path #codelist1 #codelist2`\n- añadida la compatibilidad con flags en el método `CMD()`\n- corregida la importación de las dependencias definidas en los componentes\n- añadida la variable global `REPO`\n\n## 20.006\n\n- añadido el método `Date.toUTC([ticks])` que faltaba\n- corregida una advertencia sobre la descarga de componentes de UI desde el CDN\n- corregida la adición de un `array` en el método `plugin.push()`\n- añadida una alternativa a TAPI:\n\t- `DEF.pipe = '/total-api-endpoint/'`\n\t- `plugin.pipe(name, [data], [path|callback])`\n\t- `PIPE(name, [data], [path|callback])`\n- mejorado `Thelpers.empty(value, [def], [raw])` con el argumento `raw`\n- añadido el antiguo evento `knockknock`\n- añadida la opción `native: Boolean` a la función personalizada `SCROLLBAR()`\n- corregidos los enlaces con `@` en el método `IMPORT()`\n- corregidos los paths \"complejos\" en los plugins\n- corregido el análisis de claves vacías al usar `String.parseConfig()`\n\n## 20.005\n\n- corregida la obtención del path del plugin con la forma `?1/something` o `?1.something`\n\n## 20.004\n\n- añadido el método `component.setPath(path)`\n- añadido `$(element).scrollbar()` para buscar la instancia de barra de desplazamiento personalizada más cercana\n- añadido el nuevo atributo `source=\"URL address\"` al elemento `ui-component`\n- ampliado `component.bind()` con el flag `notify` (notifica el estado del componente a todos los componentes del path)\n\n## 20.003\n\n- corregida la caché del método `AJAX()`\n- añadido el método `Array.group(key)`\n\n## 20.001\n\n- corregidas las llamadas a `EXEC()`\n- corregido `CLINIT()` con el argumento `extend`\n- corregida la opción `track` en `<ui-bind>`\n- corregida la opción `format` en `<ui-bind>`\n- corregida la reconfiguración de componentes no inicializados en `<ui-bind>`\n- ampliado jQuery con el método `$.autofocus([selector])`\n- corregida la eliminación inesperada de las barras de desplazamiento personalizadas\n- corregidas las dependencias de los componentes\n- añadido el método `component.push()` que faltaba\n- corregidos `enabled` y `disabled` de los comandos de `<ui-bind>` para los controles HTML\n- corregida la funcionalidad de `PREF`\n- corregido `@singleton` en el método `IMPORT()`\n- añadido el método `UNAUTHORIZED()` que faltaba\n- aumentado el retardo después de importar contenido de terceros mediante el método `IMPORT()`\n- corregidos los valores de enlace `real-time` en el método `component.autobind20()`\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcN31cd61f-fr","url":"https://totaljs.es/docs/fr/jcomponent-v20/20-015/changelog/20-015/","project":"jcomponent-v20","version":"20-015","section":"changelog","language":"fr","title":"20.015","summary":"La liste officielle des modifications de jComponent, jusqu'à la version 20.015.","markdown":"---\ntitle: 20.015\nproject: jComponent V20\nversion: 20.015\nsection: changelog\nlanguage: fr\nlicense: MIT\nurl: https://totaljs.es/docs/fr/jcomponent-v20/20-015/changelog/20-015/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# 20.015\n\n> La liste officielle des modifications de jComponent, jusqu'à la version 20.015.\n\n## 20.015\n\n- ajout de la méthode manquante `plugin.unwatch(path, [callback])`\n- ajout de la gestion de `abort` et de `timeout` à la méthode `AJAX()`\n- ajout de la gestion des erreurs des scripts et des styles à la méthode `IMPORT()` (le callback s'exécute même si l'importation échoue)\n- amélioration des performances de `SET()` (les setters compilés sont mis en cache)\n- amélioration des performances de `Array.prototype.quicksort()` (instance `Intl.Collator` partagée)\n- amélioration de `inDOM()` grâce à `element.isConnected`\n- amélioration de `COOKIES.set()` : l'argument `expire` est facultatif et ne modifie pas `NOW`\n- __modifié__ : `Number.prototype.format()` arrondit les décimales au lieu de les tronquer\n- __modifié__ : `Date.prototype.format('iso')` renvoie une vraie date UTC\n- __modifié__ : les commandes `html`, `text`, `value`, `title`, `href` et `src` de `<ui-bind>` affichent `0` au lieu de la valeur `empty`\n- __modifié__ : `EXTENSION()` exécute le callback pour les instances existantes avec les mêmes arguments que pour les nouvelles instances `(instance, config, cls)`\n- __modifié__ : `AJAX()` considère une réponse comme une erreur à partir du code de statut `400` (avant `399`)\n- __modifié__ : `WAIT(path, callback)` attend une valeur truthy\n- correction des collisions dans le cache des paths (des paths différents pouvaient renvoyer la même valeur)\n- correction de `SET(path, function(value))`\n- correction des méthodes `CMD()`, `plugin.cmd()` et `$(element).CMD()`\n- correction de `OFF(name, callback)` pour les événements non enregistrés\n- correction de l'émission des événements quand un gestionnaire se désenregistre lui-même\n- correction d'une boucle infinie dans la méthode `autofocus()`\n- correction d'une boucle infinie dans la méthode `TRANSLATE()` avec un balisage `@(` non fermé\n- correction des caractères `$` dans les traductions de la méthode `TRANSLATE()`\n- correction de `CONFIG('.path', config)` pour les composants sans path\n- correction du comptage des éléments en attente pour l'événement `ready`\n- correction de `?1|` (plugin parent) dans les paths\n- correction de `plugin.watch()` avec plusieurs paths `path1 + path2`\n- correction de `plugin.set(object)`\n- correction de la propriété `plugin.modified`\n- correction de `component.unwatch()` (qui affectait aussi `component.datasource()`)\n- correction de `component.autofill()` et du traitement des valeurs remplies automatiquement\n- correction de `component.setPath()` avec le caractère `?`\n- correction de `component.caniuse()` avec le séparateur `|`\n- correction de la valeur précédente dans le délégué `component.configure(key, value, init, prev)`\n- correction de `checkbox` dans le `component.setter()` par défaut\n- correction de la méthode interne `component.$setter()` sans flags\n- correction de la déclaration en double de `component.attr()`\n- correction des commandes multiples `html+title` dans `<ui-bind>`\n- correction de l'utilisation d'une valeur précédente dans `<ui-bind>` quand une commande lève une erreur\n- correction des arguments de `$(element).SEEX()`\n- correction de la double exécution des callbacks dans les requêtes `AJAX()` mises en cache\n- correction de `opt.respond()` dans l'événement `request`\n- correction de l'envoi de données `String` dans la méthode `AJAX()`\n- correction de la variable globale implicite `arr` dans la réponse de `AJAX()`\n- correction de l'argument `encrypt` dans la méthode `STRINGIFY()`\n- correction de la restauration des valeurs dans la méthode `CACHEPATH()`\n- correction de l'analyse de la méthode HTTP avec `!` dans la méthode `CLINIT()`\n- correction d'une possible fuite d'intervalle dans la méthode `WAIT()`\n- correction de `COOKIES.set()` avec un nombre de jours et de `COOKIES.get()` pour les valeurs contenant le caractère `=`\n- correction des erreurs de `localStorage` dans la méthode `BLOCKED()` et pendant l'initialisation\n- correction de l'horloge sur 12 heures (`hh`, `h`, `am/pm`) dans `String.prototype.parseDate()` et `Date.prototype.format()`\n- correction d'un jour manquant et des millisecondes dans `String.prototype.parseDate()`\n- correction des apostrophes et des variables d'environnement dans `Date.prototype.format()`\n- correction de `Number.prototype.add()` avec un nombre\n- correction de `Number.prototype.format()` avec la notation exponentielle\n- correction de `Number.prototype.pluralize()` sans tous les arguments\n- correction de `String.prototype.parseExpire()` sans unité\n- correction de `String.prototype.parseSource()` avec le type `number`\n- correction de `Array.prototype.findValue()` avec le cache\n- correction du tri de types de données différents par la même clé dans `Array.prototype.quicksort()`\n- correction des couleurs HEX courtes dans la méthode `APPEARANCE()`\n- correction de `VISIBLE()` pour les éléments placés directement dans le `<body>`\n- correction de la vérification de la taille de la fenêtre dans le gestionnaire interne de redimensionnement\n- correction du gestionnaire `resize`, des animations et de `destroy()` dans `SCROLLBAR()`\n\n## 20.014\n\n- ajout de la méthode manquante `ENCRYPT(str, key, type)`\n- ajout de la méthode manquante `DECRYPT(hex, key, type)`\n\n## 20.013\n\n- correction de `Number.prototype.round()`\n- ajout de la méthode manquante `CMD(name, [a], [b], [c], [d])`\n- ajout de l'alias `EXE()` pour `EXEC()`\n\n## 20.012\n\n- ajout de la propriété manquante `component.$ready` pour plusieurs composants (j-Layout, j-Windows, etc.) qui l'implémentent\n- ajout de la méthode manquante `API(url, name, data, callback, [scope])`\n\n## 20.011\n\n- correction du mot-clé `SYNC` dans la méthode `AJAX()`\n- ajout d'un gestionnaire `onprogress` manquant dans les méthodes `AJAX()` et `UPLOAD()`\n\n## 20.009\n\n- initialisation de jComponent sur les mobiles Samsung\n- ajout de `COOKIES`, qui manquait\n\n## 20.008\n\n- ajout de la prise en charge de `@method_name` dans la méthode `component.EXEC()` (exécute la méthode du composant parent)\n- renommage de la méthode `CSS()` en `STYLE()`\n- ajout de l'objet `window.jc_globals = { ... }` pour désactiver les méthodes globales de jComponent :\n\t- il ne prend en charge qu'une seule méthode : `CSS: false`, qui désactive l'enregistrement de la méthode `CSS()`\n- correction de l'option `target` de l'élément `ui-import`\n- correction de l'option `class` de l'élément `ui-import`\n- correction de l'option `init` de l'élément `ui-import`\n- correction de `ui-bind` avec un sélecteur `template` personnalisé\n- correction de l'opérateur de DOM virtuel `-->` à deux tirets\n\n## 20.007\n\n- correction de la méthode `plugin.get()`\n- correction de l'ajout de `DEF.version` à toutes les requêtes AJAX `.html`\n- correction de l'ajout de `DEF.language` à toutes les requêtes AJAX\n- amélioration de `ui-bind` avec :\n\t- la compatibilité avec la v19, où seuls les éléments visibles sont rendus\n\t- la commande `forcerender`, qui permet le rendu dans les éléments masqués\n- correction de la méthode `NEWUIBIND()`\n- correction de la fonctionnalité interne `.exec`\n- amélioration du téléchargement des composants depuis le CDN\n- ajout des méthodes manquantes `plugin.off()` et `component.off()`\n- extension de la méthode `component.autobind20([delay], [realtimebinding])` avec deux arguments\n- ajout de la méthode manquante `component.closest(selector)`\n- correction du fonctionnement des plugins dynamiques\n- correction de l'option de configuration `class` des plugins\n- amélioration du chargement de l'instance de plugin\n- correction du fonctionnement de la méthode `CLRELOAD()`\n- correction de l'évaluation des listes de codes dans les paths `path #codelist1 #codelist2`\n- ajout de la prise en charge des flags dans la méthode `CMD()`\n- correction de l'importation des dépendances définies dans les composants\n- ajout de la variable globale `REPO`\n\n## 20.006\n\n- ajout de la méthode manquante `Date.toUTC([ticks])`\n- correction d'un message d'avertissement sur le téléchargement des composants d'interface depuis le CDN\n- correction de l'ajout d'un `array` dans la méthode `plugin.push()`\n- ajout d'une alternative à TAPI :\n\t- `DEF.pipe = '/total-api-endpoint/'`\n\t- `plugin.pipe(name, [data], [path|callback])`\n\t- `PIPE(name, [data], [path|callback])`\n- amélioration de `Thelpers.empty(value, [def], [raw])` avec l'argument `raw`\n- ajout de l'ancien événement `knockknock`\n- ajout de l'option `native: Boolean` à la méthode `SCROLLBAR()` personnalisée\n- correction des liens contenant `@` dans la méthode `IMPORT()`\n- correction des paths \"complexes\" dans les plugins\n- correction de l'analyse des clés vides avec `String.parseConfig()`\n\n## 20.005\n\n- correction de l'obtention du path d'un plugin sous la forme `?1/something` ou `?1.something`\n\n## 20.004\n\n- ajout de la méthode `component.setPath(path)`\n- ajout de `$(element).scrollbar()` pour trouver l'instance de barre de défilement personnalisée la plus proche\n- ajout d'un nouvel attribut `source=\"URL address\"` pour l'élément `ui-component`\n- extension de `component.bind()` avec le flag `notify` (il notifie tous les composants du path de l'état du composant)\n\n## 20.003\n\n- correction du cache dans la méthode `AJAX()`\n- ajout de la méthode `Array.group(key)`\n\n## 20.001\n\n- correction des appels à `EXEC()`\n- correction de `CLINIT()` avec l'argument `extend`\n- correction de l'option `track` dans `<ui-bind>`\n- correction de l'option `format` dans `<ui-bind>`\n- correction de la reconfiguration des composants non initialisés dans `<ui-bind>`\n- extension de jQuery avec la méthode `$.autofocus([selector])`\n- correction de la suppression inattendue des barres de défilement personnalisées\n- correction des dépendances des composants\n- ajout de la méthode manquante `component.push()`\n- correction des commandes `enabled` et `disabled` de `<ui-bind>` pour les contrôles HTML\n- correction du fonctionnement de `PREF`\n- correction de `@singleton` dans la méthode `IMPORT()`\n- ajout de la méthode manquante `UNAUTHORIZED()`\n- augmentation du délai après l'importation de contenu tiers avec la méthode `IMPORT()`\n- correction des valeurs de liaison `real-time` dans la méthode `component.autobind20()`\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcN31cd61f-it","url":"https://totaljs.es/docs/it/jcomponent-v20/20-015/changelog/20-015/","project":"jcomponent-v20","version":"20-015","section":"changelog","language":"it","title":"20.015","summary":"L'elenco ufficiale delle modifiche di jComponent, fino alla release 20.015.","markdown":"---\ntitle: 20.015\nproject: jComponent V20\nversion: 20.015\nsection: changelog\nlanguage: it\nlicense: MIT\nurl: https://totaljs.es/docs/it/jcomponent-v20/20-015/changelog/20-015/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# 20.015\n\n> L'elenco ufficiale delle modifiche di jComponent, fino alla release 20.015.\n\n## 20.015\n\n- aggiunto il metodo mancante `plugin.unwatch(path, [callback])`\n- aggiunta la gestione di `abort` e `timeout` al metodo `AJAX()`\n- aggiunta la gestione degli errori di script e stili al metodo `IMPORT()` (la callback viene eseguita anche se l'importazione non riesce)\n- migliorate le prestazioni di `SET()` (i setter compilati vengono memorizzati nella cache)\n- migliorate le prestazioni di `Array.prototype.quicksort()` (istanza condivisa di `Intl.Collator`)\n- migliorato `inDOM()` con l'uso di `element.isConnected`\n- migliorato `COOKIES.set()`: l'argomento `expire` è facoltativo e non modifica `NOW`\n- __modificato__: `Number.prototype.format()` arrotonda i decimali invece di troncarli\n- __modificato__: `Date.prototype.format('iso')` restituisce una vera data UTC\n- __modificato__: i comandi `html`, `text`, `value`, `title`, `href` e `src` di `<ui-bind>` visualizzano `0` invece del valore `empty`\n- __modificato__: `EXTENSION()` esegue la callback per le istanze esistenti con gli stessi argomenti delle nuove istanze `(instance, config, cls)`\n- __modificato__: `AJAX()` considera una risposta un errore a partire dal codice di stato `400` (prima `399`)\n- __modificato__: `WAIT(path, callback)` attende un valore truthy\n- corrette le collisioni nella cache dei path (path diversi potevano restituire lo stesso valore)\n- corretto `SET(path, function(value))`\n- corretti i metodi `CMD()`, `plugin.cmd()` e `$(element).CMD()`\n- corretto `OFF(name, callback)` per gli eventi non registrati\n- corretta l'emissione degli eventi quando un gestore annulla la propria registrazione\n- corretto un ciclo infinito nel metodo `autofocus()`\n- corretto un ciclo infinito nel metodo `TRANSLATE()` con un markup `@(` non chiuso\n- corretti i caratteri `$` nelle traduzioni nel metodo `TRANSLATE()`\n- corretto `CONFIG('.path', config)` per i componenti senza path\n- corretto il conteggio degli elementi in attesa per l'evento `ready`\n- corretto `?1|` (plugin genitore) nei path\n- corretto `plugin.watch()` con più path `path1 + path2`\n- corretto `plugin.set(object)`\n- corretta la proprietà `plugin.modified`\n- corretto `component.unwatch()` (influiva anche su `component.datasource()`)\n- corretti `component.autofill()` e l'elaborazione dei valori compilati automaticamente\n- corretto `component.setPath()` con il carattere `?`\n- corretto `component.caniuse()` con il separatore `|`\n- corretto il valore precedente nel delegato `component.configure(key, value, init, prev)`\n- corretto `checkbox` nel `component.setter()` predefinito\n- corretto il metodo interno `component.$setter()` senza flag\n- corretta la dichiarazione duplicata di `component.attr()`\n- corretti i comandi multipli `html+title` in `<ui-bind>`\n- corretto l'uso di un valore precedente in `<ui-bind>` quando un comando genera un errore\n- corretti gli argomenti di `$(element).SEEX()`\n- corretta la doppia esecuzione delle callback nelle richieste `AJAX()` in cache\n- corretto `opt.respond()` nell'evento `request`\n- corretto l'invio di dati `String` nel metodo `AJAX()`\n- corretta la variabile globale implicita `arr` nella risposta di `AJAX()`\n- corretto l'argomento `encrypt` nel metodo `STRINGIFY()`\n- corretto il ripristino dei valori nel metodo `CACHEPATH()`\n- corretta l'analisi del metodo HTTP con `!` nel metodo `CLINIT()`\n- corretta una possibile perdita di intervalli nel metodo `WAIT()`\n- corretti `COOKIES.set()` con un numero di giorni e `COOKIES.get()` per i valori con il carattere `=`\n- corretti gli errori di `localStorage` nel metodo `BLOCKED()` e nell'inizializzazione\n- corretto il formato a 12 ore (`hh`, `h`, `am/pm`) in `String.prototype.parseDate()` e `Date.prototype.format()`\n- corretti il giorno mancante e i millisecondi in `String.prototype.parseDate()`\n- corretti gli apostrofi e le variabili d'ambiente in `Date.prototype.format()`\n- corretto `Number.prototype.add()` con un numero\n- corretto `Number.prototype.format()` con la notazione esponenziale\n- corretto `Number.prototype.pluralize()` senza tutti gli argomenti\n- corretto `String.prototype.parseExpire()` senza unità\n- corretto `String.prototype.parseSource()` con il tipo `number`\n- corretto `Array.prototype.findValue()` con la cache\n- corretto l'ordinamento di tipi di dati diversi in base alla stessa chiave in `Array.prototype.quicksort()`\n- corretti i colori HEX brevi nel metodo `APPEARANCE()`\n- corretto `VISIBLE()` per gli elementi posizionati direttamente nel `<body>`\n- corretto il controllo della dimensione della finestra nel gestore interno di ridimensionamento\n- corretti il gestore `resize`, le animazioni e `destroy()` in `SCROLLBAR()`\n\n## 20.014\n\n- aggiunto il metodo mancante `ENCRYPT(str, key, type)`\n- aggiunto il metodo mancante `DECRYPT(hex, key, type)`\n\n## 20.013\n\n- corretto `Number.prototype.round()`\n- aggiunto il metodo mancante `CMD(name, [a], [b], [c], [d])`\n- aggiunto l'alias `EXE()` di `EXEC()`\n\n## 20.012\n\n- aggiunta la proprietà mancante `component.$ready` per diversi componenti (j-Layout, j-Windows, ecc.) che la implementano\n- aggiunto il metodo mancante `API(url, name, data, callback, [scope])`\n\n## 20.011\n\n- corretta la parola chiave `SYNC` nel metodo `AJAX()`\n- aggiunto un gestore `onprogress` mancante ai metodi `AJAX()` e `UPLOAD()`\n\n## 20.009\n\n- inizializzazione di jComponent per i dispositivi mobili Samsung\n- aggiunto `COOKIES`, che mancava\n\n## 20.008\n\n- aggiunto il supporto per `@method_name` nel metodo `component.EXEC()` (esegue il metodo del componente genitore)\n- rinominato il metodo `CSS()` in `STYLE()`\n- aggiunto l'oggetto `window.jc_globals = { ... }` per disattivare i metodi globali di jComponent:\n\t- supporta un solo metodo: `CSS: false`, che disattiva la registrazione del metodo `CSS()`\n- corretta l'opzione `target` dell'elemento `ui-import`\n- corretta l'opzione `class` dell'elemento `ui-import`\n- corretta l'opzione `init` dell'elemento `ui-import`\n- corretto `ui-bind` con un selettore `template` personalizzato\n- corretto l'operatore del DOM virtuale `-->` con due trattini\n\n## 20.007\n\n- corretto il metodo `plugin.get()`\n- corretta l'aggiunta di `DEF.version` a tutte le richieste AJAX `.html`\n- corretta l'aggiunta di `DEF.language` a tutte le richieste AJAX\n- migliorato `ui-bind` con l'aggiunta di:\n\t- compatibilità con la v19, con il rendering dei soli elementi visibili\n\t- il comando `forcerender`, che consente il rendering negli elementi nascosti\n- corretto il metodo `NEWUIBIND()`\n- corretta la funzionalità interna `.exec`\n- migliorato il download dei componenti dal CDN\n- aggiunti i metodi mancanti `plugin.off()` e `component.off()`\n- esteso il metodo `component.autobind20([delay], [realtimebinding])` con l'aggiunta di due argomenti\n- aggiunto il metodo mancante `component.closest(selector)`\n- corretta la funzionalità dei plugin dinamici\n- corretta l'opzione di configurazione `class` dei plugin\n- migliorato il caricamento dell'istanza del plugin\n- corretta la funzionalità del metodo `CLRELOAD()`\n- corretta la valutazione degli elenchi di codici nei path `path #codelist1 #codelist2`\n- aggiunto il supporto per i flag nel metodo `CMD()`\n- corretta l'importazione delle dipendenze definite nei componenti\n- aggiunta la variabile globale `REPO`\n\n## 20.006\n\n- aggiunto il metodo mancante `Date.toUTC([ticks])`\n- corretto un avviso relativo al download dei componenti UI dal CDN\n- corretta l'aggiunta di un `array` nel metodo `plugin.push()`\n- aggiunta un'alternativa a TAPI:\n\t- `DEF.pipe = '/total-api-endpoint/'`\n\t- `plugin.pipe(name, [data], [path|callback])`\n\t- `PIPE(name, [data], [path|callback])`\n- migliorato `Thelpers.empty(value, [def], [raw])` con l'aggiunta dell'argomento `raw`\n- aggiunto il vecchio evento `knockknock`\n- aggiunta l'opzione `native: Boolean` al metodo `SCROLLBAR()` personalizzato\n- corretti i link con `@` nel metodo `IMPORT()`\n- corretti i path \"complessi\" nei plugin\n- corretta l'analisi delle chiavi vuote con `String.parseConfig()`\n\n## 20.005\n\n- corretto il recupero del path del plugin nella forma `?1/something` o `?1.something`\n\n## 20.004\n\n- aggiunto il metodo `component.setPath(path)`\n- aggiunto `$(element).scrollbar()` per trovare l'istanza della barra di scorrimento personalizzata più vicina\n- aggiunto il nuovo attributo `source=\"URL address\"` per l'elemento `ui-component`\n- esteso `component.bind()` con l'aggiunta del flag `notify` (notifica a tutti i componenti nel path lo stato del componente)\n\n## 20.003\n\n- corretta la cache nel metodo `AJAX()`\n- aggiunto il metodo `Array.group(key)`\n\n## 20.001\n\n- corrette le chiamate a `EXEC()`\n- corretto `CLINIT()` con l'argomento `extend`\n- corretta l'opzione `track` in `<ui-bind>`\n- corretta l'opzione `format` in `<ui-bind>`\n- corretta la riconfigurazione dei componenti non inizializzati in `<ui-bind>`\n- esteso jQuery con l'aggiunta del metodo `$.autofocus([selector])`\n- corretta la rimozione imprevista delle barre di scorrimento personalizzate\n- corrette le dipendenze dei componenti\n- aggiunto il metodo mancante `component.push()`\n- corretti i comandi `enabled` e `disabled` di `<ui-bind>` per i controlli HTML\n- corretta la funzionalità di `PREF`\n- corretto `@singleton` nel metodo `IMPORT()`\n- aggiunto il metodo mancante `UNAUTHORIZED()`\n- aumentato il ritardo dopo l'importazione di contenuti di terze parti tramite il metodo `IMPORT()`\n- corretti i valori di associazione `real-time` nel metodo `component.autobind20()`\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
{"id":"JamcN31cd61f-sk","url":"https://totaljs.es/docs/sk/jcomponent-v20/20-015/changelog/20-015/","project":"jcomponent-v20","version":"20-015","section":"changelog","language":"sk","title":"20.015","summary":"Oficiálny zoznam zmien jComponent až po vydanie 20.015.","markdown":"---\ntitle: 20.015\nproject: jComponent V20\nversion: 20.015\nsection: changelog\nlanguage: sk\nlicense: MIT\nurl: https://totaljs.es/docs/sk/jcomponent-v20/20-015/changelog/20-015/\nupdated: 2026-11-22T18:41:52.302Z\n---\n\n# 20.015\n\n> Oficiálny zoznam zmien jComponent až po vydanie 20.015.\n\n## 20.015\n\n- pridaná chýbajúca metóda `plugin.unwatch(path, [callback])`\n- pridané spracovanie `abort` a `timeout` do metódy `AJAX()`\n- pridané spracovanie chýb skriptov a štýlov do metódy `IMPORT()` (callback sa spustí, aj keď import zlyhá)\n- vylepšený výkon `SET()` (skompilované settery sa ukladajú do cache)\n- vylepšený výkon `Array.prototype.quicksort()` (zdieľaná inštancia `Intl.Collator`)\n- vylepšené `inDOM()` pomocou `element.isConnected`\n- vylepšené `COOKIES.set()`, argument `expire` je voliteľný a nemení `NOW`\n- __zmenené__: `Number.prototype.format()` desatinné miesta zaokrúhľuje namiesto orezávania\n- __zmenené__: `Date.prototype.format('iso')` vracia skutočný dátum v UTC\n- __zmenené__: príkazy `html`, `text`, `value`, `title`, `href` a `src` elementu `<ui-bind>` vykreslia `0` namiesto hodnoty `empty`\n- __zmenené__: `EXTENSION()` spúšťa callback pre existujúce inštancie s rovnakými argumentmi ako pre nové inštancie `(instance, config, cls)`\n- __zmenené__: `AJAX()` vyhodnotí odpoveď ako chybu od stavového kódu `400` (predtým `399`)\n- __zmenené__: `WAIT(path, callback)` čaká na pravdivú hodnotu\n- opravené kolízie v cache paths (rôzne paths mohli vrátiť rovnakú hodnotu)\n- opravené `SET(path, function(value))`\n- opravené metódy `CMD()`, `plugin.cmd()` a `$(element).CMD()`\n- opravené `OFF(name, callback)` pre nezaregistrované udalosti\n- opravené vysielanie udalostí, keď sa obslužná funkcia sama odregistruje\n- opravený nekonečný cyklus v metóde `autofocus()`\n- opravený nekonečný cyklus v metóde `TRANSLATE()` s neuzavretým zápisom `@(`\n- opravené znaky `$` v prekladoch v metóde `TRANSLATE()`\n- opravené `CONFIG('.path', config)` pre komponenty bez path\n- opravené počítanie čakajúcich elementov pre udalosť `ready`\n- opravené `?1|` (nadradený plugin) v paths\n- opravené `plugin.watch()` s viacerými paths `path1 + path2`\n- opravené `plugin.set(object)`\n- opravená vlastnosť `plugin.modified`\n- opravené `component.unwatch()` (ovplyvňovalo aj `component.datasource()`)\n- opravené `component.autofill()` a spracovanie automaticky vyplnených hodnôt\n- opravené `component.setPath()` so znakom `?`\n- opravené `component.caniuse()` s oddeľovačom `|`\n- opravená predchádzajúca hodnota v delegáte `component.configure(key, value, init, prev)`\n- opravený `checkbox` v predvolenom `component.setter()`\n- opravený interný `component.$setter()` bez flagov\n- opravená duplicitná deklarácia `component.attr()`\n- opravené viacnásobné príkazy `html+title` v `<ui-bind>`\n- opravené používanie predchádzajúcej hodnoty v `<ui-bind>`, keď príkaz vyhodí chybu\n- opravené argumenty v `$(element).SEEX()`\n- opravené dvojité spúšťanie callbackov pri požiadavkách `AJAX()` z cache\n- opravené `opt.respond()` v udalosti `request`\n- opravené odosielanie dát typu `String` v metóde `AJAX()`\n- opravená implicitná globálna premenná `arr` v odpovedi `AJAX()`\n- opravený argument `encrypt` v metóde `STRINGIFY()`\n- opravené obnovovanie hodnôt v metóde `CACHEPATH()`\n- opravená analýza metódy HTTP so znakom `!` v metóde `CLINIT()`\n- opravený možný únik intervalu v metóde `WAIT()`\n- opravené `COOKIES.set()` s počtom dní a `COOKIES.get()` pre hodnoty so znakom `=`\n- opravené chyby `localStorage` v metóde `BLOCKED()` a pri inicializácii\n- opravený 12-hodinový formát času (`hh`, `h`, `am/pm`) v `String.prototype.parseDate()` a `Date.prototype.format()`\n- opravený chýbajúci deň a milisekundy v `String.prototype.parseDate()`\n- opravené apostrofy a premenné prostredia v `Date.prototype.format()`\n- opravené `Number.prototype.add()` s číslom\n- opravené `Number.prototype.format()` s exponenciálnym zápisom\n- opravené `Number.prototype.pluralize()` bez všetkých argumentov\n- opravené `String.prototype.parseExpire()` bez jednotky\n- opravené `String.prototype.parseSource()` s typom `number`\n- opravené `Array.prototype.findValue()` s cache\n- opravené triedenie rôznych dátových typov podľa rovnakého kľúča v `Array.prototype.quicksort()`\n- opravené krátke HEX farby v metóde `APPEARANCE()`\n- opravené `VISIBLE()` pre elementy umiestnené priamo v `<body>`\n- opravená kontrola veľkosti okna v internej obslužnej funkcii zmeny veľkosti\n- opravená obslužná funkcia `resize`, animácie a `destroy()` v `SCROLLBAR()`\n\n## 20.014\n\n- pridaná chýbajúca metóda `ENCRYPT(str, key, type)`\n- pridaná chýbajúca metóda `DECRYPT(hex, key, type)`\n\n## 20.013\n\n- opravená metóda `Number.prototype.round()`\n- pridaná chýbajúca metóda `CMD(name, [a], [b], [c], [d])`\n- pridaný alias `EXE()` pre `EXEC()`\n\n## 20.012\n\n- pridaná chýbajúca vlastnosť `component.$ready` pre viaceré komponenty (j-Layout, j-Windows atď.), ktoré ju implementujú\n- pridaná chýbajúca metóda `API(url, name, data, callback, [scope])`\n\n## 20.011\n\n- opravené kľúčové slovo `SYNC` v metóde `AJAX()`\n- pridaná chýbajúca obslužná funkcia `onprogress` do metód `AJAX()` a `UPLOAD()`\n\n## 20.009\n\n- inicializácia jComponent na mobilných zariadeniach Samsung\n- pridané chýbajúce `COOKIES`\n\n## 20.008\n\n- pridaná podpora pre `@method_name` v metóde `component.EXEC()` (spustí metódu nadradeného komponentu)\n- metóda `CSS()` premenovaná na `STYLE()`\n- pridaný objekt `window.jc_globals = { ... }` na vypnutie globálnych metód jComponent:\n\t- podporuje iba jednu metódu: `CSS: false`, ktorá vypne registráciu metódy `CSS()`\n- opravená možnosť `target` elementu `ui-import`\n- opravená možnosť `class` elementu `ui-import`\n- opravená možnosť `init` elementu `ui-import`\n- opravený `ui-bind` s vlastným selektorom `template`\n- opravený operátor virtuálneho DOM `-->` s dvoma pomlčkami\n\n## 20.007\n\n- opravená metóda `plugin.get()`\n- opravené pridávanie `DEF.version` do všetkých požiadaviek AJAX na `.html`\n- opravené pridávanie `DEF.language` do všetkých požiadaviek AJAX\n- vylepšený `ui-bind` pridaním:\n\t- kompatibility s v19, pri ktorej sa vykresľujú iba viditeľné elementy\n\t- príkazu `forcerender`, ktorý umožňuje vykresľovanie v skrytých elementoch\n- opravená metóda `NEWUIBIND()`\n- opravená interná funkcionalita `.exec`\n- vylepšené sťahovanie komponentov z CDN\n- pridané chýbajúce metódy `plugin.off()` a `component.off()`\n- metóda `component.autobind20([delay], [realtimebinding])` rozšírená o dva argumenty\n- pridaná chýbajúca metóda `component.closest(selector)`\n- opravená funkcionalita dynamických pluginov\n- opravená konfiguračná možnosť pluginu `class`\n- vylepšené načítavanie inštancie pluginu\n- opravená funkcionalita metódy `CLRELOAD()`\n- opravené vyhodnocovanie zoznamov kódov v paths `path #codelist1 #codelist2`\n- pridaná podpora flagov v metóde `CMD()`\n- opravený import závislostí definovaných v komponentoch\n- pridaná globálna premenná `REPO`\n\n## 20.006\n\n- pridaná chýbajúca metóda `Date.toUTC([ticks])`\n- opravené upozornenie o sťahovaní komponentov UI z CDN\n- opravené pridávanie `array` v metóde `plugin.push()`\n- pridaná alternatíva k TAPI:\n\t- `DEF.pipe = '/total-api-endpoint/'`\n\t- `plugin.pipe(name, [data], [path|callback])`\n\t- `PIPE(name, [data], [path|callback])`\n- vylepšený `Thelpers.empty(value, [def], [raw])` pridaním argumentu `raw`\n- pridaná stará udalosť `knockknock`\n- pridaná možnosť `native: Boolean` do vlastného `SCROLLBAR()`\n- opravené odkazy so znakom `@` v metóde `IMPORT()`\n- opravené „zložité“ paths v pluginoch\n- opravená analýza prázdnych kľúčov pri používaní `String.parseConfig()`\n\n## 20.005\n\n- opravené získavanie path pluginu v tvare `?1/something` alebo `?1.something`\n\n## 20.004\n\n- pridaná metóda `component.setPath(path)`\n- pridané `$(element).scrollbar()` na nájdenie najbližšej inštancie vlastného posuvníka\n- pridaný nový atribút `source=\"URL address\"` pre element `ui-component`\n- `component.bind()` rozšírený o flag `notify` (upozorní všetky komponenty na danom path na stav komponentu)\n\n## 20.003\n\n- opravená cache v metóde `AJAX()`\n- pridaná metóda `Array.group(key)`\n\n## 20.001\n\n- opravené volania `EXEC()`\n- opravené `CLINIT()` s argumentom `extend`\n- opravená možnosť `track` v `<ui-bind>`\n- opravená možnosť `format` v `<ui-bind>`\n- opravená rekonfigurácia neinicializovaných komponentov v `<ui-bind>`\n- jQuery rozšírené o metódu `$.autofocus([selector])`\n- opravené neočakávané odstraňovanie vlastných posuvníkov\n- opravené závislosti komponentov\n- pridaná chýbajúca metóda `component.push()`\n- opravené príkazy `enabled` a `disabled` elementu `<ui-bind>` pre ovládacie prvky HTML\n- opravená funkcionalita `PREF`\n- opravený `@singleton` v metóde `IMPORT()`\n- pridaná chýbajúca metóda `UNAUTHORIZED()`\n- predĺžené oneskorenie po importe obsahu tretích strán cez metódu `IMPORT()`\n- opravené hodnoty väzby `real-time` v metóde `component.autobind20()`\n","entries":[],"license":"MIT","updated":"2026-11-22T18:41:52.302Z"}
